14 Sep 2004 elanthis   » (Journeyer)

Telnet Proxy

Mr. Ellis of MUDMagic.com offerred me a contract to develop a simple but robust telnet proxy for his site. He has made available a new Java MUD client applet. However, applets, for security reasons, can only connect to the host the applet is run from. Therefor, to be able to support connecting to all the MUDs listed on mudmagic.com, a proxy is necessary. The original coder didn't write a very nice proxy, however, as it apparantly had all sorts of lockups and the like.

The proxy I wrote for him is running much nicer. I didn't really accept the contract; I instead offerred to write it for free, as sort of a community contribution thing. It's actually my first real threaded application. And works perfectly. Go me. ^_^

It really is a super simplistic app. It listens on a port for connections. For each connection it spawns a thread. The thread waits for a single command line of the form "connect [host] [port]". Once it gets that, it checks in a list of host/port combination read in from a simple text file to see if the connection should be allowed. if so, it connects to the server, and just forwards bytes back and forth between the two connections. That's it.

I need to do a few more small features for it, and it's complete. For example, it needs to timeout connections if they aren't active. I'd also like to have it track the number of connections from each client address. Currently, we have a limit on the number of clients; a malicious user could DoS the service by just making a ton of connections. With a per address limit, it will then at least require a DDoS - and there's not a whole lot you can do about that kind of stuff anyhow.

I also noticed that I should probably clean up the code that loads in the host list. It locks and unlocks many times as it runs. (Actually, it doesn't do any locking - but calls a lot of functions that do.) A client could connect in the middle of a host list refresh and, as the list is incomplete, get booted off and flaged for trying to access a host that isn't allowed. Moving all the code to the reload function (the only function that calls the other functions) and just using one lock/unlock set would fix that.

The proxy is BSD licensed, btw.

[#] Comments

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!