proxy server

If %{proxy_host} is set, all connections will go through a proxy server (firewall) defined by %proxy_host and %proxy_port. Note that %{proxy_host} should usually not be set if TF has been compiled to use SOCKS.

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 invoke the CONNECT and LOGIN hooks (which, by default, bring the world into the foreground and perform an automatic login).

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

The proxy connection command is done with this standard macro:

/def -i proxy_connect = telnet ${world_host} ${world_port}
If your proxy server requires a different command, you should redefine proxy_connect. That will be sufficient for most proxy servers. (Before version 5.0, a custom connect command required you to redefine proxy_command. This should be avoided now if possible.)

If your proxy server has more complex requirements, or you want better error detection, you will need to redefine the proxy_command macro. By default, proxy_command immediately calls /proxy_connect, enables localecho, and invokes the CONNECT and LOGIN hooks. There are several reasons you might want to redefine proxy_command:

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. So, you could use this definition:

/def proxy_command =\
    /def -p10000 -w -1 -h'PROMPT tn-gw->' =\
        /proxy_connect%%; \
        /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 invokes the CONNECT and LOGIN hooks. The error hook undefines the success trigger and disconnects from the proxy.

See: /addworld, %proxy_host, %proxy_port


Back to index
Back to tf home page
Copyright © 1995, 1996, 1997, 1998, 1999, 2002, 2003, 2004, 2005, 2006-2007 Ken Keys