proxy server

If %{proxy_host} is set, all connections will go through a proxy server (firewall) defined by %proxy_host and %proxy_port.

When the connection to %proxy_host %proxy_port is made, only the PROXY hook is called; the CONNECT and LOGIN hooks which are normally called after making a connection are not called when a proxy is used. A PROXY hook defined in the standard library calls /proxy_command, which by default sends "telnet ${world_host} ${world_port}", and then calls the CONNECT and LOGIN hooks. If your proxy server requires a different command, you should redefine /proxy_command.

Before the connection is made, ${world_host}, ${world_port}, error messages, and /listsockets refer to the proxy server; after the connection is made, they refer to the server defined in /addworld.

Note that tf has no way of knowing if the command sent to the proxy server actually succeeded in opening a connection to the destination server; if it failed, the default /proxy_command will happily call the LOGIN hook and send your login command to the proxy server instead of the destination. However, since the CONNECT and LOGIN hooks are called by /proxy_command, not tf, you can define your own /proxy_command that waits for specific error and success messages sent by your particular proxy server.

For example, say you use a Gauntlet telnet proxy that leaves localecho off; prints a "tn-gw-> " prompt; requires you to send "telnet hostname port" to connect; after a successful connection, prints "Connected to hostname"; and after a failed connection prints an error message and prints another prompt. For such a proxy server, you could use this /proxy_command:

/def proxy_command =    /def -p10000 -w -1 -h'PROMPT tn-gw->*' =        telnet $${world_host} $${world_port}%%;         /localecho on%%;         /def -p10002 -w -1 -h'PROMPT tn-gw->*' proxy_error_$${world_name} =            /undef proxy_success_$$${world_name}%%%;            /dc%%;        /def -p10002 -w -1 -t'Connected to *' proxy_success_$${world_name} =            /undef proxy_error_$$${world_name}%%%;            /trigger -hCONNECT $$${world_name}%%%;            /if ($$${world_character} !~ "" & $$${world_login})                 /trigger -hLOGIN ${world_name}%%%;            /endif
The first /def waits for the first prompt before doing anything. It then sends the connection command, turns localecho back on, and sets up macros to catch the results of the connection command. The success trigger undefines the error hook, and calls the CONNECT and LOGIN hooks. The error hook undefines the success trigger and disconnects from the proxy.

For systems that use SOCKS, tf should be compiled with the SOCKS option, instead of using the method described here. See the README file for details.

See: /addworld, %proxy_host, %proxy_port


Back to index
Back to tf home page
Copyright © 1995 - 1999 Ken Keys