[or-cvs] lay the groundwork for a default value for each config opti...

Roger Dingledine arma at seul.org
Wed Nov 3 10:08:47 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	circuitbuild.c config.c control.c routerlist.c 
Log Message:
lay the groundwork for a default value for each config option.
tolerate null exitnodes, entrynodes, etc config options.


Index: circuitbuild.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuitbuild.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- circuitbuild.c	30 Oct 2004 05:04:52 -0000	1.46
+++ circuitbuild.c	3 Nov 2004 10:08:44 -0000	1.47
@@ -1074,7 +1074,7 @@
       routerlist_add_family(excluded, r);
     }
   }
-  choice = router_choose_random_node("", options.ExcludeNodes, excluded,
+  choice = router_choose_random_node(NULL, options.ExcludeNodes, excluded,
            0, 1, options._AllowUnverified & ALLOW_UNVERIFIED_MIDDLE, 0);
   smartlist_free(excluded);
   return choice;

Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.195
retrieving revision 1.196
diff -u -d -r1.195 -r1.196
--- config.c	2 Nov 2004 23:47:32 -0000	1.195
+++ config.c	3 Nov 2004 10:08:44 -0000	1.196
@@ -52,11 +52,12 @@
 };
 #undef PLURAL
 
-/* A variable allowed in the configuration file or on the command line */
+/** A variable allowed in the configuration file or on the command line. */
 typedef struct config_var_t {
-  const char *name; /**< The full keyword (case insensitive) */
-  config_type_t type; /**< How to interpret the type and turn it into a value */
-  off_t var_offset; /**< Offset of the corresponding member of or_options_t */
+  const char *name; /**< The full keyword (case insensitive). */
+  config_type_t type; /**< How to interpret the type and turn it into a value. */
+  off_t var_offset; /**< Offset of the corresponding member of or_options_t. */
+  const char *initvalue; /**< String (or null) describing initial value. */
 } config_var_t;
 
 /** Return the offset of <b>member</b> within the type <b>tp</b>, in bytes */
@@ -65,77 +66,77 @@
  * CONFIG_TYPE_<b>conftype</b>, and corresponds to
  * or_options_t.<b>member</b>"
  */
-#define VAR(name,conftype,member) \
-  { name, CONFIG_TYPE_ ## conftype, STRUCT_OFFSET(or_options_t, member) }
+#define VAR(name,conftype,member,initvalue) \
+  { name, CONFIG_TYPE_ ## conftype, STRUCT_OFFSET(or_options_t, member), initvalue }
 /** An entry for config_vars: "The option <b>name</b> is obsolete." */
-#define OBSOLETE(name) { name, CONFIG_TYPE_OBSOLETE, 0 }
+#define OBSOLETE(name) { name, CONFIG_TYPE_OBSOLETE, 0, NULL }
 
 /** Array of configuration options.  Until we disallow nonstandard
  * abbreviations, order is significant, since the first matching option will
  * be chosen first.
  */
 static config_var_t config_vars[] = {
-  VAR("Address",             STRING,   Address),
-  VAR("AllowUnverifiedNodes",CSV,      AllowUnverifiedNodes),
-  VAR("AuthoritativeDirectory",BOOL,   AuthoritativeDir),
-  VAR("BandwidthRate",       UINT,     BandwidthRate),
-  VAR("BandwidthBurst",      UINT,     BandwidthBurst),
-  VAR("ClientOnly",          BOOL,     ClientOnly),
-  VAR("ContactInfo",         STRING,   ContactInfo),
-  VAR("DebugLogFile",        STRING,   DebugLogFile),
-  VAR("DataDirectory",       STRING,   DataDirectory),
-  VAR("DirPort",             UINT,     DirPort),
-  VAR("DirBindAddress",      LINELIST, DirBindAddress),
-  VAR("DirFetchPostPeriod",  UINT,     DirFetchPostPeriod),
-  VAR("DirPolicy",           LINELIST, DirPolicy),
-  VAR("DirServer",           LINELIST, DirServers),
-  VAR("ExitNodes",           STRING,   ExitNodes),
-  VAR("EntryNodes",          STRING,   EntryNodes),
-  VAR("StrictExitNodes",     BOOL,     StrictExitNodes),
-  VAR("StrictEntryNodes",    BOOL,     StrictEntryNodes),
-  VAR("ExitPolicy",          LINELIST, ExitPolicy),
-  VAR("ExcludeNodes",        STRING,   ExcludeNodes),
-  VAR("FascistFirewall",     BOOL,     FascistFirewall),
-  VAR("FirewallPorts",       CSV,      FirewallPorts),
-  VAR("MyFamily",            STRING,   MyFamily),
-  VAR("NodeFamily",          LINELIST, NodeFamilies),
-  VAR("Group",               STRING,   Group),
-  VAR("HttpProxy",           STRING,   HttpProxy),
-  VAR("HiddenServiceDir",    LINELIST, RendConfigLines),
-  VAR("HiddenServicePort",   LINELIST, RendConfigLines),
-  VAR("HiddenServiceNodes",  LINELIST, RendConfigLines),
-  VAR("HiddenServiceExcludeNodes", LINELIST, RendConfigLines),
-  VAR("IgnoreVersion",       BOOL,     IgnoreVersion),
-  VAR("KeepalivePeriod",     UINT,     KeepalivePeriod),
-  VAR("LogLevel",            LINELIST, LogOptions),
-  VAR("LogFile",             LINELIST, LogOptions),
+  VAR("Address",             STRING,   Address,              NULL),
+  VAR("AllowUnverifiedNodes",CSV,      AllowUnverifiedNodes, NULL),
+  VAR("AuthoritativeDirectory",BOOL,   AuthoritativeDir,     "0"),
+  VAR("BandwidthRate",       UINT,     BandwidthRate,        "800000"),
+  VAR("BandwidthBurst",      UINT,     BandwidthBurst,       "50000000"),
+  VAR("ClientOnly",          BOOL,     ClientOnly,           "0"),
+  VAR("ContactInfo",         STRING,   ContactInfo,          NULL),
+  VAR("DebugLogFile",        STRING,   DebugLogFile,         NULL),
+  VAR("DataDirectory",       STRING,   DataDirectory,        NULL),
+  VAR("DirPort",             UINT,     DirPort,              "0"),
+  VAR("DirBindAddress",      LINELIST, DirBindAddress,       NULL),
+  VAR("DirFetchPostPeriod",  UINT,     DirFetchPostPeriod,   "600"),
+  VAR("DirPolicy",           LINELIST, DirPolicy,            NULL),
+  VAR("DirServer",           LINELIST, DirServers,           NULL),
+  VAR("ExitNodes",           STRING,   ExitNodes,            NULL),
+  VAR("EntryNodes",          STRING,   EntryNodes,           NULL),
+  VAR("StrictExitNodes",     BOOL,     StrictExitNodes,      "0"),
+  VAR("StrictEntryNodes",    BOOL,     StrictEntryNodes,     "0"),
+  VAR("ExitPolicy",          LINELIST, ExitPolicy,           NULL),
+  VAR("ExcludeNodes",        STRING,   ExcludeNodes,         NULL),
+  VAR("FascistFirewall",     BOOL,     FascistFirewall,      "0"),
+  VAR("FirewallPorts",       CSV,      FirewallPorts,        NULL),
+  VAR("MyFamily",            STRING,   MyFamily,             NULL),
+  VAR("NodeFamily",          LINELIST, NodeFamilies,         NULL),
+  VAR("Group",               STRING,   Group,                NULL),
+  VAR("HttpProxy",           STRING,   HttpProxy,            NULL),
+  VAR("HiddenServiceDir",    LINELIST, RendConfigLines,      NULL),
+  VAR("HiddenServicePort",   LINELIST, RendConfigLines,      NULL),
+  VAR("HiddenServiceNodes",  LINELIST, RendConfigLines,      NULL),
+  VAR("HiddenServiceExcludeNodes", LINELIST, RendConfigLines,NULL),
+  VAR("IgnoreVersion",       BOOL,     IgnoreVersion,        "0"),
+  VAR("KeepalivePeriod",     UINT,     KeepalivePeriod,      "300"),
+  VAR("LogLevel",            LINELIST, LogOptions,           NULL),
+  VAR("LogFile",             LINELIST, LogOptions,           NULL),
   OBSOLETE("LinkPadding"),
-  VAR("MaxConn",             UINT,     MaxConn),
-  VAR("MaxOnionsPending",    UINT,     MaxOnionsPending),
-  VAR("MonthlyAccountingStart",UINT,   AccountingStart),
-  VAR("AccountingMaxKB",     UINT,     AccountingMaxKB),
-  VAR("Nickname",            STRING,   Nickname),
-  VAR("NewCircuitPeriod",    UINT,     NewCircuitPeriod),
-  VAR("NumCpus",             UINT,     NumCpus),
-  VAR("ORPort",              UINT,     ORPort),
-  VAR("ORBindAddress",       LINELIST, ORBindAddress),
-  VAR("OutboundBindAddress", STRING,   OutboundBindAddress),
-  VAR("PidFile",             STRING,   PidFile),
-  VAR("PathlenCoinWeight",   DOUBLE,   PathlenCoinWeight),
-  VAR("RedirectExit",        LINELIST, RedirectExit),
+  VAR("MaxConn",             UINT,     MaxConn,              "1024"),
+  VAR("MaxOnionsPending",    UINT,     MaxOnionsPending,     "100"),
+  VAR("MonthlyAccountingStart",UINT,   AccountingStart,      "0"),
+  VAR("AccountingMaxKB",     UINT,     AccountingMaxKB,      "0"),
+  VAR("Nickname",            STRING,   Nickname,             NULL),
+  VAR("NewCircuitPeriod",    UINT,     NewCircuitPeriod,     "30"),
+  VAR("NumCpus",             UINT,     NumCpus,              "1"),
+  VAR("ORPort",              UINT,     ORPort,               "0"),
+  VAR("ORBindAddress",       LINELIST, ORBindAddress,        NULL),
+  VAR("OutboundBindAddress", STRING,   OutboundBindAddress,  NULL),
+  VAR("PidFile",             STRING,   PidFile,              NULL),
+  VAR("PathlenCoinWeight",   DOUBLE,   PathlenCoinWeight,    "0.3"),
+  VAR("RedirectExit",        LINELIST, RedirectExit,         NULL),
   OBSOLETE("RouterFile"),
-  VAR("RunAsDaemon",         BOOL,     RunAsDaemon),
-  VAR("RunTesting",          BOOL,     RunTesting),
-  VAR("RecommendedVersions", LINELIST, RecommendedVersions),
-  VAR("RendNodes",           STRING,   RendNodes),
-  VAR("RendExcludeNodes",    STRING,   RendExcludeNodes),
-  VAR("SocksPort",           UINT,     SocksPort),
-  VAR("SocksBindAddress",    LINELIST, SocksBindAddress),
-  VAR("SocksPolicy",         LINELIST, SocksPolicy),
-  VAR("SysLog",              LINELIST, LogOptions),
+  VAR("RunAsDaemon",         BOOL,     RunAsDaemon,          "0"),
+  VAR("RunTesting",          BOOL,     RunTesting,           "0"),
+  VAR("RecommendedVersions", LINELIST, RecommendedVersions,  NULL),
+  VAR("RendNodes",           STRING,   RendNodes,            NULL),
+  VAR("RendExcludeNodes",    STRING,   RendExcludeNodes,     NULL),
+  VAR("SocksPort",           UINT,     SocksPort,            "0"),
+  VAR("SocksBindAddress",    LINELIST, SocksBindAddress,     NULL),
+  VAR("SocksPolicy",         LINELIST, SocksPolicy,          NULL),
+  VAR("SysLog",              LINELIST, LogOptions,           NULL),
   OBSOLETE("TrafficShaping"),
-  VAR("User",                STRING,   User),
-  { NULL, CONFIG_TYPE_OBSOLETE, 0 }
+  VAR("User",                STRING,   User,                 NULL),
+  { NULL, CONFIG_TYPE_OBSOLETE, 0, NULL }
 };
 #undef VAR
 #undef OBSOLETE
@@ -589,13 +590,6 @@
 init_options(or_options_t *options)
 {
   memset(options,0,sizeof(or_options_t));
-  options->ExitNodes = tor_strdup("");
-  options->EntryNodes = tor_strdup("");
-  options->StrictEntryNodes = options->StrictExitNodes = 0;
-  options->ExcludeNodes = tor_strdup("");
-  options->RendNodes = tor_strdup("");
-  options->RendExcludeNodes = tor_strdup("");
-  /* options->PidFile = tor_strdup("tor.pid"); */
   options->PathlenCoinWeight = 0.3;
   options->MaxConn = 1024;
   options->DirFetchPostPeriod = 600;
@@ -745,7 +739,7 @@
       ++i;
     } else if (!strcmp(argv[i],"--list-fingerprint")) {
       options->command = CMD_LIST_FINGERPRINT;
-    }      
+    }
   }
 
   if (using_default_torrc) {
@@ -869,11 +863,13 @@
     result = -1;
   }
 
-  if (options->StrictExitNodes && !strlen(options->ExitNodes)) {
+  if (options->StrictExitNodes &&
+      (!options->ExitNodes || !strlen(options->ExitNodes))) {
     log(LOG_WARN, "StrictExitNodes set, but no ExitNodes listed.");
   }
 
-  if (options->StrictEntryNodes && !strlen(options->EntryNodes)) {
+  if (options->StrictEntryNodes &&
+      (!options->EntryNodes || !strlen(options->EntryNodes))) {
     log(LOG_WARN, "StrictEntryNodes set, but no EntryNodes listed.");
   }
 

Index: control.c
===================================================================
RCS file: /home/or/cvsroot/src/or/control.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- control.c	3 Nov 2004 01:32:26 -0000	1.1
+++ control.c	3 Nov 2004 10:08:44 -0000	1.2
@@ -250,7 +250,7 @@
       log_fn(LOG_WARN, "Received client-only '%s' command; ignoring.",
              control_cmd_to_string(command_type));
       send_control_error(conn, ERR_UNRECOGNIZED_TYPE,
-                         "Command type only valid from server tor client");
+                         "Command type only valid from server to tor client");
       break;
     default:
       log_fn(LOG_WARN, "Received unrecognized command type %d; ignoring.",

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.172
retrieving revision 1.173
diff -u -d -r1.172 -r1.173
--- routerlist.c	2 Nov 2004 03:02:17 -0000	1.172
+++ routerlist.c	3 Nov 2004 10:08:44 -0000	1.173
@@ -293,8 +293,9 @@
   routerinfo_t *router;
   smartlist_t *nickname_list;
 
+  if(!list)
+    return; /* nothing to do */
   tor_assert(sl);
-  tor_assert(list);
 
   nickname_list = smartlist_create();
 
@@ -330,8 +331,9 @@
   smartlist_t *nickname_list;
   int v = 0;
 
+  if(!list)
+    return 0; /* definitely not */
   tor_assert(router);
-  tor_assert(list);
 
   nickname_list = smartlist_create();
   smartlist_split_string(nickname_list, list, ",",



More information about the tor-commits mailing list