[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: Limiting hops



"Marc Erickson" <marcerickson@xxxxxxxxx> wrote:
>I use Tor on my laptop to encrypt wireless packets when connecting to
>an unsecured wireless network.  Is there a way to limit the number of
>hops the packets take through the servers so that I can better the
>speed?  I only need one hop.  I'm running Windows XP.

If you know how to compile Tor, you can try this patch which adds a torrc option ClientCircuitLen which can be set to either 2, 3, or random (randomizes between 2 and 3).

Like was said earlier, Tor discourages (and prevents IIRC) using one-hop circuits.

Patch attached.



      
Index: src/or/config.c
===================================================================
--- src/or/config.c	(revision 14305)
+++ src/or/config.c	(working copy)
@@ -159,6 +159,7 @@
   V(BridgeRelay,                 BOOL,     "0"),
   V(CircuitBuildTimeout,         INTERVAL, "1 minute"),
   V(CircuitIdleTimeout,          INTERVAL, "1 hour"),
+  V(ClientCircuitLen,            STRING,   "3"),
   V(ClientDNSRejectInternalAddresses, BOOL,"1"),
   V(ClientOnly,                  BOOL,     "0"),
   V(ConnLimit,                   UINT,     "1000"),
@@ -425,6 +426,8 @@
   { "AllowNonRFC953Hostnames", "If set to 1, we don't automatically reject "
     "hostnames for having invalid characters." },
   /*  CircuitBuildTimeout, CircuitIdleTimeout */
+  { "ClientCircuitLen", "Sets the number of hops for client circuits "
+    "to 3, 2, or random." },
   { "ClientOnly", "If set to 1, Tor will under no circumstances run as a "
     "server, even if ORPort is enabled." },
   { "EntryNodes", "A list of preferred entry nodes to use for the first hop "
@@ -3324,6 +3327,11 @@
     });
   }
 
+  if (strcmp(options->ClientCircuitLen, "3") &&
+      strcmp(options->ClientCircuitLen, "2") &&
+      strcasecmp(options->ClientCircuitLen, "random"))
+    REJECT("ClientCircuitLen must be 3, 2, or random.");
+
   return 0;
 #undef REJECT
 #undef COMPLAIN
Index: src/or/or.h
===================================================================
--- src/or/or.h	(revision 14305)
+++ src/or/or.h	(working copy)
@@ -442,6 +442,7 @@
 #define CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED 11
 /** Client-side circuit purpose: at Alice, rendezvous established. */
 #define CIRCUIT_PURPOSE_C_REND_JOINED 12
+#define _CIRCUIT_PURPOSE_C_MAX 12
 
 /** Hidden-service-side circuit purpose: at Bob, waiting for introductions. */
 #define CIRCUIT_PURPOSE_S_ESTABLISH_INTRO 13
@@ -2347,6 +2348,8 @@
   /** Optionally, a file with GeoIP data. */
   char *GeoIPFile;
 
+  char *ClientCircuitLen;
+
 } or_options_t;
 
 /** Persistent state for an onion router, as saved to disk. */
Index: src/or/circuitbuild.c
===================================================================
--- src/or/circuitbuild.c	(revision 14305)
+++ src/or/circuitbuild.c	(working copy)
@@ -1036,10 +1036,19 @@
 {
   int num_acceptable_routers;
   int routelen;
+  or_options_t *options = get_options();
 
   tor_assert(routers);
 
-  routelen = 3;
+  if (purpose <= _CIRCUIT_PURPOSE_C_MAX &&
+      strcmp(options->ClientCircuitLen, "3")) {
+    routelen = 2;
+    if (!strcasecmp(options->ClientCircuitLen, "random") &&
+        crypto_rand_int(2))
+      routelen++;
+  } else {
+    routelen = 3;
+  }
   if (exit &&
       purpose != CIRCUIT_PURPOSE_TESTING &&
       purpose != CIRCUIT_PURPOSE_S_ESTABLISH_INTRO)