Viktor Radnai - 2007-06-06

Hi there,

I have modified tsocks a long time ago to allow me to connect directly by default and proxy only to selected secure networks. To accomplish this, only a very simple patch is needed (attached at the bottom of this post).
The purpose of the patch is as follows: If the default server isn't set in tsocks.conf, tsocks will fall back to a direct connection (and print a warning) instead of refusing the connection. This way I just alias ssh='tsocks ssh' and I no longer have to worry about which networks tsocks is needed for. It will work automatically based on the rules in tsocks.conf.

Please merge this into tsocks if you think it's useful.

Viktor Radnai

--- tsocks-1.8beta5/tsocks.c    2002-07-16 00:50:52.000000000 +0200
+++ tsocks-1.8beta5vik/tsocks.c 2005-08-19 19:43:21.000000000 +0200
@@ -289,12 +289,13 @@
    show_msg(MSGDEBUG, "Picked server %s for connection\n",
             (path->address ? path->address : "(Not Provided)"));
    if (path->address == NULL) {
-      if (path == &(config->defaultserver))
-         show_msg(MSGERR, "Connection needs to be made "
+      if (path == &(config->defaultserver)) {
+         show_msg(MSGDEBUG, "Connection needs to be made "
                           "via default server but "
                           "the default server has not "
-                          "been specified\n");
-      else
+                          "been specified. Falling back to direct connection.\n");
+             return(realconnect(__fd, __addr, __len));
+      } else
          show_msg(MSGERR, "Connection needs to be made "
                           "via path specified at line "
                           "%d in configuration file but "