Explorar o código

more cleanups, including a shiny new XXX012

svn:r9250
Roger Dingledine %!s(int64=19) %!d(string=hai) anos
pai
achega
50e36dc11b
Modificáronse 6 ficheiros con 41 adicións e 35 borrados
  1. 6 3
      doc/address-spec.txt
  2. 1 1
      doc/control-spec.txt
  3. 20 22
      src/or/config.c
  4. 7 2
      src/or/dirserv.c
  5. 1 1
      src/or/hibernate.c
  6. 6 6
      src/or/or.h

+ 6 - 3
doc/address-spec.txt

@@ -28,7 +28,10 @@ $Id$
   the exit node.  If no "hostname" component is given, Tor defaults to the
   the exit node.  If no "hostname" component is given, Tor defaults to the
   published IPv4 address of the exit node.
   published IPv4 address of the exit node.
 
 
-  It is valid to try to resolve hostnames 
+  It is valid to try to resolve hostnames, and in fact upon success Tor
+  will cache an internal mapaddress of the form
+  "www.google.com.foo.exit=64.233.161.99.foo.exit" to speed subsequent
+  lookups.
 
 
   EXAMPLES:
   EXAMPLES:
      www.example.com.exampletornode.exit
      www.example.com.exampletornode.exit
@@ -42,7 +45,7 @@ $Id$
 
 
 3. .onion
 3. .onion
 
 
-  SYNTAX [digest].onion
+  SYNTAX:  [digest].onion
 
 
   The digest is the first eighty bits of a SHA1 hash of the identity key for
   The digest is the first eighty bits of a SHA1 hash of the identity key for
   a hidden service, encoded in base32.
   a hidden service, encoded in base32.
@@ -52,7 +55,7 @@ $Id$
 
 
 4. .noconnect
 4. .noconnect
 
 
-  SYNTAX: [string].noconnect
+  SYNTAX:  [string].noconnect
 
 
   When Tor sees an address in this format, it immediately closes the
   When Tor sees an address in this format, it immediately closes the
   connection without attaching it to any circuit.  This is useful for
   connection without attaching it to any circuit.  This is useful for

+ 1 - 1
doc/control-spec.txt

@@ -1143,7 +1143,7 @@ do for each. -RD]
   Syntax:
   Syntax:
      "650" SP "GUARDS" SP Type SP Name SP Status ... CRLF
      "650" SP "GUARDS" SP Type SP Name SP Status ... CRLF
      Type = "ENTRY"
      Type = "ENTRY"
-     Name = The (possibly verbose) nickname of the guard effected.
+     Name = The (possibly verbose) nickname of the guard affected.
      Status = "NEW" | "UP" | "DOWN" | "BAD" | "GOOD" | "DROPPED"
      Status = "NEW" | "UP" | "DOWN" | "BAD" | "GOOD" | "DROPPED"
 
 
   [explain states. XXX]
   [explain states. XXX]

+ 20 - 22
src/or/config.c

@@ -208,7 +208,7 @@ static config_var_t _option_vars[] = {
   VAR("OutboundBindAddress", STRING,   OutboundBindAddress,  NULL),
   VAR("OutboundBindAddress", STRING,   OutboundBindAddress,  NULL),
   VAR("PathlenCoinWeight",   DOUBLE,   PathlenCoinWeight,    "0.3"),
   VAR("PathlenCoinWeight",   DOUBLE,   PathlenCoinWeight,    "0.3"),
   VAR("PidFile",             STRING,   PidFile,              NULL),
   VAR("PidFile",             STRING,   PidFile,              NULL),
-  VAR("PreferTunneledDirConns", BOOL,  PreferTunneledDirConns, "1"),
+  VAR("PreferTunneledDirConns", BOOL,  PreferTunneledDirConns, "0"),
   VAR("ProtocolWarnings",    BOOL,     ProtocolWarnings,     "0"),
   VAR("ProtocolWarnings",    BOOL,     ProtocolWarnings,     "0"),
   VAR("PublishServerDescriptor",BOOL,  PublishServerDescriptor,"1"),
   VAR("PublishServerDescriptor",BOOL,  PublishServerDescriptor,"1"),
   VAR("PublishHidServDescriptors",BOOL,PublishHidServDescriptors, "1"),
   VAR("PublishHidServDescriptors",BOOL,PublishHidServDescriptors, "1"),
@@ -251,7 +251,7 @@ static config_var_t _option_vars[] = {
   OBSOLETE("TrafficShaping"),
   OBSOLETE("TrafficShaping"),
   VAR("TransListenAddress",  LINELIST, TransListenAddress,   NULL),
   VAR("TransListenAddress",  LINELIST, TransListenAddress,   NULL),
   VAR("TransPort",           UINT,     TransPort,            "0"),
   VAR("TransPort",           UINT,     TransPort,            "0"),
-  VAR("TunnelDirConns",      BOOL,     TunnelDirConns,       "1"),
+  VAR("TunnelDirConns",      BOOL,     TunnelDirConns,       "0"),
   VAR("UseEntryGuards",      BOOL,     UseEntryGuards,       "1"),
   VAR("UseEntryGuards",      BOOL,     UseEntryGuards,       "1"),
   VAR("User",                STRING,   User,                 NULL),
   VAR("User",                STRING,   User,                 NULL),
   VAR("V1AuthoritativeDirectory",BOOL, V1AuthoritativeDir,   "0"),
   VAR("V1AuthoritativeDirectory",BOOL, V1AuthoritativeDir,   "0"),
@@ -319,7 +319,7 @@ static config_var_description_t options_description[] = {
     "control-spec.txt).", },
     "control-spec.txt).", },
   { "CookieAuthentication", "If this option is set to 1, don't allow any "
   { "CookieAuthentication", "If this option is set to 1, don't allow any "
     "connections to the control port except when the connecting process "
     "connections to the control port except when the connecting process "
-    "can read a file that Tor creates in its data directory. " },
+    "can read a file that Tor creates in its data directory." },
   { "DataDirectory", "Store working data, state, keys, and caches here." },
   { "DataDirectory", "Store working data, state, keys, and caches here." },
   { "DirServer", "Tor only trusts directories signed with one of these "
   { "DirServer", "Tor only trusts directories signed with one of these "
     "servers' keys.  Used to override the standard list of directory "
     "servers' keys.  Used to override the standard list of directory "
@@ -344,7 +344,7 @@ static config_var_description_t options_description[] = {
   { "Log", "Where to send logging messages.  Format is "
   { "Log", "Where to send logging messages.  Format is "
     "minSeverity[-maxSeverity] (stderr|stdout|syslog|file FILENAME)." },
     "minSeverity[-maxSeverity] (stderr|stdout|syslog|file FILENAME)." },
   { "OutboundBindAddress", "Make all outbound connections originate from the "
   { "OutboundBindAddress", "Make all outbound connections originate from the "
-    "provided IP address (only usefol for multiple network interfaces)." },
+    "provided IP address (only useful for multiple network interfaces)." },
   { "PIDFile", "On startup, write our PID to this file. On clean shutdown, "
   { "PIDFile", "On startup, write our PID to this file. On clean shutdown, "
     "remove the file." },
     "remove the file." },
   /* PreferTunneledDirConns */
   /* PreferTunneledDirConns */
@@ -365,25 +365,25 @@ static config_var_description_t options_description[] = {
     "hostnames for having invalid characters." },
     "hostnames for having invalid characters." },
   /*  CircuitBuildTimeout, CircuitIdleTimeout */
   /*  CircuitBuildTimeout, CircuitIdleTimeout */
   { "ClientOnly", "If set to 1, Tor will under no circumstances run as a "
   { "ClientOnly", "If set to 1, Tor will under no circumstances run as a "
-    "server, even if ORPort is as configued." },
+    "server, even if ORPort is enabled." },
   { "EntryNodes", "A list of preferred entry nodes to use for the first hop "
   { "EntryNodes", "A list of preferred entry nodes to use for the first hop "
-    "in circuits, if possible." },
+    "in circuits, when possible." },
   /* { "EnforceDistinctSubnets" , "" }, */
   /* { "EnforceDistinctSubnets" , "" }, */
   { "ExitNodes", "A list of preferred nodes to use for the last hop in "
   { "ExitNodes", "A list of preferred nodes to use for the last hop in "
     "circuits, when possible." },
     "circuits, when possible." },
   { "ExcludeNodes", "A list of nodes never to use when building a circuit." },
   { "ExcludeNodes", "A list of nodes never to use when building a circuit." },
   { "FascistFirewall", "If set, Tor will only create outgoing connections to "
   { "FascistFirewall", "If set, Tor will only create outgoing connections to "
-    "ORs running on the ports listed in FirewallPorts." },
-  { "FirewallPorts", "A list of ports that we cann connect to.  Only used "
+    "servers running on the ports listed in FirewallPorts." },
+  { "FirewallPorts", "A list of ports that we can connect to.  Only used "
     "when FascistFirewall is set." },
     "when FascistFirewall is set." },
   { "LongLivedPorts", "A list of ports for services that tend to require "
   { "LongLivedPorts", "A list of ports for services that tend to require "
-    "long-lived connections." },
+    "high-uptime connections." },
   { "MapAddress", "Force Tor to treat all requests for one address as if "
   { "MapAddress", "Force Tor to treat all requests for one address as if "
     "they were for another." },
     "they were for another." },
   { "NewCircuitPeriod", "Force Tor to consider whether to build a new circuit "
   { "NewCircuitPeriod", "Force Tor to consider whether to build a new circuit "
-    "every NUM sections." },
+    "every NUM seconds." },
   { "MaxCircuitDirtiness", "Do not attach new streams to a circuit that has "
   { "MaxCircuitDirtiness", "Do not attach new streams to a circuit that has "
-    "been used up to this many seconds ago." },
+    "been used more than this many seconds ago." },
   /* NatdPort, NatdListenAddress */
   /* NatdPort, NatdListenAddress */
   { "NodeFamily", "A list of servers that constitute a 'family' and should "
   { "NodeFamily", "A list of servers that constitute a 'family' and should "
     "never be used in the same circuit." },
     "never be used in the same circuit." },
@@ -393,7 +393,7 @@ static config_var_description_t options_description[] = {
     "By default, we assume all addresses are reachable." },
     "By default, we assume all addresses are reachable." },
   /* reachablediraddresses, reachableoraddresses. */
   /* reachablediraddresses, reachableoraddresses. */
   { "RendNodes", "A list of preferred nodes to use for a rendezvous point, "
   { "RendNodes", "A list of preferred nodes to use for a rendezvous point, "
-    "if possible." },
+    "when possible." },
   { "RendExcludenodes", "A list of nodes never to use as rendezvous points." },
   { "RendExcludenodes", "A list of nodes never to use as rendezvous points." },
   /* SafeSOCKS */
   /* SafeSOCKS */
   { "SOCKSPort", "The port where we listen for SOCKS connections from "
   { "SOCKSPort", "The port where we listen for SOCKS connections from "
@@ -409,13 +409,13 @@ static config_var_description_t options_description[] = {
     "configured EntryNodes can be used." },
     "configured EntryNodes can be used." },
   /* TestSocks */
   /* TestSocks */
   { "TrackHostsExit", "Hosts and domains which should, if possible, be "
   { "TrackHostsExit", "Hosts and domains which should, if possible, be "
-    "acccessed from the same exit node each time we connect to them." },
+    "accessed from the same exit node each time we connect to them." },
   { "TrackHostsExitExpire", "Time after which we forget which exit we were "
   { "TrackHostsExitExpire", "Time after which we forget which exit we were "
     "using to connect to hosts in TrackHostsExit." },
     "using to connect to hosts in TrackHostsExit." },
   /* "TransPort", "TransListenAddress */
   /* "TransPort", "TransListenAddress */
   { "UseEntryGuards", "Set to 0 if we want to pick from the whole set of "
   { "UseEntryGuards", "Set to 0 if we want to pick from the whole set of "
-    "entry nodes for each server, rather than picking a set of 'Guards' to "
-    "prevent profiling attacks." },
+    "servers for the first position in each circuit, rather than picking a "
+    "set of 'Guards' to prevent profiling attacks." },
 
 
   /* === server options */
   /* === server options */
   { "Address", "The advertised (external) address we should use." },
   { "Address", "The advertised (external) address we should use." },
@@ -442,8 +442,7 @@ static config_var_description_t options_description[] = {
   { "ORListenAddress", "Bind to this address to listen for connections from "
   { "ORListenAddress", "Bind to this address to listen for connections from "
     "clients and servers, instead of the default 0.0.0.0:ORPort." },
     "clients and servers, instead of the default 0.0.0.0:ORPort." },
   { "PublishServerDescriptors", "Set to 0 in order to keep the server from "
   { "PublishServerDescriptors", "Set to 0 in order to keep the server from "
-    "uploading info to the directory authorities.  This prevents clients "
-    "from using your server." },
+    "uploading info to the directory authorities." },
   /*{ "RedirectExit", "When an outgoing connection tries to connect to a "
   /*{ "RedirectExit", "When an outgoing connection tries to connect to a "
    *"given address, redirect it to another address instead." },
    *"given address, redirect it to another address instead." },
    */
    */
@@ -452,10 +451,10 @@ static config_var_description_t options_description[] = {
     "shutting down because of a SIGINT." },
     "shutting down because of a SIGINT." },
   /* { "TestVia", } */
   /* { "TestVia", } */
 
 
-  /* === directory cache optoins */
+  /* === directory cache options */
   { "DirPort", "Serve directory information from this port, and act as a "
   { "DirPort", "Serve directory information from this port, and act as a "
     "directory cache." },
     "directory cache." },
-  { "DirListenAddress", "Bind to this address to listen for connnections from "
+  { "DirListenAddress", "Bind to this address to listen for connections from "
     "clients and servers, instead of the default 0.0.0.0:DirPort." },
     "clients and servers, instead of the default 0.0.0.0:DirPort." },
   { "DirPolicy", "Set a policy to limit who can connect to the directory "
   { "DirPolicy", "Set a policy to limit who can connect to the directory "
     "port" },
     "port" },
@@ -2250,7 +2249,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
 {
 {
   int i, r;
   int i, r;
   config_line_t *cl;
   config_line_t *cl;
-  const char *uname;
+  const char *uname = get_uname();
   char buf[1024];
   char buf[1024];
 #define REJECT(arg) \
 #define REJECT(arg) \
   do { *msg = tor_strdup(arg); return -1; } while (0)
   do { *msg = tor_strdup(arg); return -1; } while (0)
@@ -2262,7 +2261,6 @@ options_validate(or_options_t *old_options, or_options_t *options,
   if (options->ORPort < 0 || options->ORPort > 65535)
   if (options->ORPort < 0 || options->ORPort > 65535)
     REJECT("ORPort option out of bounds.");
     REJECT("ORPort option out of bounds.");
 
 
-  uname = get_uname();
   if (server_mode(options) &&
   if (server_mode(options) &&
       (!strcmpstart(uname, "Windows 95") ||
       (!strcmpstart(uname, "Windows 95") ||
        !strcmpstart(uname, "Windows 98") ||
        !strcmpstart(uname, "Windows 98") ||
@@ -2270,7 +2268,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
     log(LOG_WARN, LD_CONFIG, "Tor is running as a server, but you are "
     log(LOG_WARN, LD_CONFIG, "Tor is running as a server, but you are "
         "running %s; this probably won't work. See "
         "running %s; this probably won't work. See "
         "http://wiki.noreply.org/noreply/TheOnionRouter/TorFAQ#ServerOS "
         "http://wiki.noreply.org/noreply/TheOnionRouter/TorFAQ#ServerOS "
-        "for details.", get_uname());
+        "for details.", uname);
   }
   }
 
 
   if (options->ORPort == 0 && options->ORListenAddress != NULL)
   if (options->ORPort == 0 && options->ORListenAddress != NULL)

+ 7 - 2
src/or/dirserv.c

@@ -1359,6 +1359,11 @@ dirserv_compute_performance_thresholds(routerlist_t *rl)
       *bw = router_get_advertised_bandwidth(ri);
       *bw = router_get_advertised_bandwidth(ri);
       total_bandwidth += *bw;
       total_bandwidth += *bw;
       total_exit_bandwidth += *bw;
       total_exit_bandwidth += *bw;
+      /* XXX012 The above line doesn't actually count exit bandwidth. */
+      /* While we're at it, we might want to avoid BadExit nodes when
+       * counting exit bandwidth. */
+      /* Also, we might want to document the one-third behavior in
+       * dir-spec.txt. */
       smartlist_add(bandwidths, bw);
       smartlist_add(bandwidths, bw);
     }
     }
   });
   });
@@ -1495,7 +1500,7 @@ generate_v2_networkstatus(void)
 
 
   dirserv_compute_performance_thresholds(rl);
   dirserv_compute_performance_thresholds(rl);
 
 
-  exits_can_be_guards = total_exit_bandwidth > (total_bandwidth / 3);
+  exits_can_be_guards = total_exit_bandwidth >= (total_bandwidth / 3);
 
 
   SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri, {
   SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri, {
     if (ri->cache_info.published_on >= cutoff) {
     if (ri->cache_info.published_on >= cutoff) {
@@ -1516,7 +1521,7 @@ generate_v2_networkstatus(void)
       int f_named = naming && ri->is_named;
       int f_named = naming && ri->is_named;
       int f_valid = ri->is_valid;
       int f_valid = ri->is_valid;
       int f_guard = f_fast && f_stable &&
       int f_guard = f_fast && f_stable &&
-        router_get_advertised_bandwidth(ri) > guard_bandwidth &&
+        router_get_advertised_bandwidth(ri) >= guard_bandwidth &&
         (!f_exit || exits_can_be_guards);
         (!f_exit || exits_can_be_guards);
       int f_bad_exit = listbadexits && ri->is_bad_exit;
       int f_bad_exit = listbadexits && ri->is_bad_exit;
       /* 0.1.1.9-alpha is the first version to support fetch by descriptor
       /* 0.1.1.9-alpha is the first version to support fetch by descriptor

+ 1 - 1
src/or/hibernate.c

@@ -725,7 +725,7 @@ static int
 hibernate_soft_limit_reached(void)
 hibernate_soft_limit_reached(void)
 {
 {
   uint64_t soft_limit = DBL_TO_U64(U64_TO_DBL(get_options()->AccountingMax)
   uint64_t soft_limit = DBL_TO_U64(U64_TO_DBL(get_options()->AccountingMax)
-                                    * .95);
+                                   * .95);
   if (!soft_limit)
   if (!soft_limit)
     return 0;
     return 0;
   return n_bytes_read_in_interval >= soft_limit
   return n_bytes_read_in_interval >= soft_limit

+ 6 - 6
src/or/or.h

@@ -1014,7 +1014,7 @@ typedef struct routerstatus_t {
                                * an exit node. */
                                * an exit node. */
 
 
   /** True iff we know version info for this router. (i.e., a "v" entry was
   /** True iff we know version info for this router. (i.e., a "v" entry was
-   * included.)  We'll replace all these with a big tor_vesion_t or a char[]
+   * included.)  We'll replace all these with a big tor_version_t or a char[]
    * if the number of traits we care about ever becomes incredibly big. */
    * if the number of traits we care about ever becomes incredibly big. */
   unsigned int version_known:1;
   unsigned int version_known:1;
   /** True iff this router is a version that supports BEGIN_DIR cells. */
   /** True iff this router is a version that supports BEGIN_DIR cells. */
@@ -2699,11 +2699,11 @@ void router_free_all(void);
 typedef struct trusted_dir_server_t {
 typedef struct trusted_dir_server_t {
   char *description;
   char *description;
   char *nickname;
   char *nickname;
-  char *address; /**< Hostname */
-  uint32_t addr; /**< IPv4 address */
-  uint16_t dir_port; /**< Directory port */
-  uint16_t or_port; /**< OR port: Used for tunneling connections */
-  char digest[DIGEST_LEN]; /**< Digest of identity key */
+  char *address; /**< Hostname. */
+  uint32_t addr; /**< IPv4 address. */
+  uint16_t dir_port; /**< Directory port. */
+  uint16_t or_port; /**< OR port: Used for tunneling connections. */
+  char digest[DIGEST_LEN]; /**< Digest of identity key. */
   unsigned int is_running:1; /**< True iff we think this server is running. */
   unsigned int is_running:1; /**< True iff we think this server is running. */
   /** True iff this server is an authority for the older ("v1") directory
   /** True iff this server is an authority for the older ("v1") directory
    * protocol. */
    * protocol. */