[DGD] Binary connections that look like telnet connections...

Noah Gibbs noah_gibbs at yahoo.com
Tue Apr 12 23:40:01 CEST 2005


  For people using the Kernel Library - there's a really neat technique that
the LPC SSH code uses.  I thought I'd mention it.

  The Kernel library allocates a binary or telnet connection automatically when
a user connects.  It then queries your TelnetD or equivalent to find out what
to send initially, and how long to wait for a first response.  Then it calls
select() with the first input (first line for a line-mode connection, first
send for a binary connection) to get a user object.

  If you return an object that inherits from both LIB_USER and LIB_CONN, you
get a user object that also believes itself to be a network connection.  The
LIB_CONN object, when it first gets input, queries the userd (which queries
your telnet connection handler or binary connection handler) with the input,
which gets passed to select().  So if the first object you pass back from
select filters input carefully and only sometimes passes input through to the
user, you can filter (decrypt, decompress, filter out telnet sequences,
whatever) the input and still have it Just Work as a telnet connection.

  The only real restriction I know of is that you can't set a port number if
you do this, so the underlying user object will always think it came from the
first telnet port or the first binary port.  There's probably some way around
that by using a different method (some kind of temporary "unresolved" user type
and the redirect() call?), but it's a restriction I don't mind, so I'm sticking
with it :-)

  For those who care, I'm using this to filter telnet sequences.  Phantasmal
should shortly allow things like ANSI color sequences and support for enhanced
MUD protocols like Pueblo and MXP.  The basics are already in CVS but I've got
some telnet options I need to handle better before it's fully releasable.





		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/



More information about the DGD mailing list