lay the groundwork for a default value for each config option.

tolerate null exitnodes, entrynodes, etc config options.


svn:r2655
This commit is contained in:
Roger Dingledine 2004-11-03 10:08:44 +00:00
parent 5253405dfc
commit e541319dcb
4 changed files with 77 additions and 79 deletions

View File

@ -1074,7 +1074,7 @@ static routerinfo_t *choose_good_middle_server(cpath_build_state_t *state,
routerlist_add_family(excluded, r); 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); 0, 1, options._AllowUnverified & ALLOW_UNVERIFIED_MIDDLE, 0);
smartlist_free(excluded); smartlist_free(excluded);
return choice; return choice;

View File

@ -52,11 +52,12 @@ static config_abbrev_t config_abbrevs[] = {
}; };
#undef PLURAL #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 { typedef struct config_var_t {
const char *name; /**< The full keyword (case insensitive) */ const char *name; /**< The full keyword (case insensitive). */
config_type_t type; /**< How to interpret the type and turn it into a value */ 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 */ 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; } config_var_t;
/** Return the offset of <b>member</b> within the type <b>tp</b>, in bytes */ /** Return the offset of <b>member</b> within the type <b>tp</b>, in bytes */
@ -65,77 +66,77 @@ typedef struct config_var_t {
* CONFIG_TYPE_<b>conftype</b>, and corresponds to * CONFIG_TYPE_<b>conftype</b>, and corresponds to
* or_options_t.<b>member</b>" * or_options_t.<b>member</b>"
*/ */
#define VAR(name,conftype,member) \ #define VAR(name,conftype,member,initvalue) \
{ name, CONFIG_TYPE_ ## conftype, STRUCT_OFFSET(or_options_t, member) } { name, CONFIG_TYPE_ ## conftype, STRUCT_OFFSET(or_options_t, member), initvalue }
/** An entry for config_vars: "The option <b>name</b> is obsolete." */ /** 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 /** Array of configuration options. Until we disallow nonstandard
* abbreviations, order is significant, since the first matching option will * abbreviations, order is significant, since the first matching option will
* be chosen first. * be chosen first.
*/ */
static config_var_t config_vars[] = { static config_var_t config_vars[] = {
VAR("Address", STRING, Address), VAR("Address", STRING, Address, NULL),
VAR("AllowUnverifiedNodes",CSV, AllowUnverifiedNodes), VAR("AllowUnverifiedNodes",CSV, AllowUnverifiedNodes, NULL),
VAR("AuthoritativeDirectory",BOOL, AuthoritativeDir), VAR("AuthoritativeDirectory",BOOL, AuthoritativeDir, "0"),
VAR("BandwidthRate", UINT, BandwidthRate), VAR("BandwidthRate", UINT, BandwidthRate, "800000"),
VAR("BandwidthBurst", UINT, BandwidthBurst), VAR("BandwidthBurst", UINT, BandwidthBurst, "50000000"),
VAR("ClientOnly", BOOL, ClientOnly), VAR("ClientOnly", BOOL, ClientOnly, "0"),
VAR("ContactInfo", STRING, ContactInfo), VAR("ContactInfo", STRING, ContactInfo, NULL),
VAR("DebugLogFile", STRING, DebugLogFile), VAR("DebugLogFile", STRING, DebugLogFile, NULL),
VAR("DataDirectory", STRING, DataDirectory), VAR("DataDirectory", STRING, DataDirectory, NULL),
VAR("DirPort", UINT, DirPort), VAR("DirPort", UINT, DirPort, "0"),
VAR("DirBindAddress", LINELIST, DirBindAddress), VAR("DirBindAddress", LINELIST, DirBindAddress, NULL),
VAR("DirFetchPostPeriod", UINT, DirFetchPostPeriod), VAR("DirFetchPostPeriod", UINT, DirFetchPostPeriod, "600"),
VAR("DirPolicy", LINELIST, DirPolicy), VAR("DirPolicy", LINELIST, DirPolicy, NULL),
VAR("DirServer", LINELIST, DirServers), VAR("DirServer", LINELIST, DirServers, NULL),
VAR("ExitNodes", STRING, ExitNodes), VAR("ExitNodes", STRING, ExitNodes, NULL),
VAR("EntryNodes", STRING, EntryNodes), VAR("EntryNodes", STRING, EntryNodes, NULL),
VAR("StrictExitNodes", BOOL, StrictExitNodes), VAR("StrictExitNodes", BOOL, StrictExitNodes, "0"),
VAR("StrictEntryNodes", BOOL, StrictEntryNodes), VAR("StrictEntryNodes", BOOL, StrictEntryNodes, "0"),
VAR("ExitPolicy", LINELIST, ExitPolicy), VAR("ExitPolicy", LINELIST, ExitPolicy, NULL),
VAR("ExcludeNodes", STRING, ExcludeNodes), VAR("ExcludeNodes", STRING, ExcludeNodes, NULL),
VAR("FascistFirewall", BOOL, FascistFirewall), VAR("FascistFirewall", BOOL, FascistFirewall, "0"),
VAR("FirewallPorts", CSV, FirewallPorts), VAR("FirewallPorts", CSV, FirewallPorts, NULL),
VAR("MyFamily", STRING, MyFamily), VAR("MyFamily", STRING, MyFamily, NULL),
VAR("NodeFamily", LINELIST, NodeFamilies), VAR("NodeFamily", LINELIST, NodeFamilies, NULL),
VAR("Group", STRING, Group), VAR("Group", STRING, Group, NULL),
VAR("HttpProxy", STRING, HttpProxy), VAR("HttpProxy", STRING, HttpProxy, NULL),
VAR("HiddenServiceDir", LINELIST, RendConfigLines), VAR("HiddenServiceDir", LINELIST, RendConfigLines, NULL),
VAR("HiddenServicePort", LINELIST, RendConfigLines), VAR("HiddenServicePort", LINELIST, RendConfigLines, NULL),
VAR("HiddenServiceNodes", LINELIST, RendConfigLines), VAR("HiddenServiceNodes", LINELIST, RendConfigLines, NULL),
VAR("HiddenServiceExcludeNodes", LINELIST, RendConfigLines), VAR("HiddenServiceExcludeNodes", LINELIST, RendConfigLines,NULL),
VAR("IgnoreVersion", BOOL, IgnoreVersion), VAR("IgnoreVersion", BOOL, IgnoreVersion, "0"),
VAR("KeepalivePeriod", UINT, KeepalivePeriod), VAR("KeepalivePeriod", UINT, KeepalivePeriod, "300"),
VAR("LogLevel", LINELIST, LogOptions), VAR("LogLevel", LINELIST, LogOptions, NULL),
VAR("LogFile", LINELIST, LogOptions), VAR("LogFile", LINELIST, LogOptions, NULL),
OBSOLETE("LinkPadding"), OBSOLETE("LinkPadding"),
VAR("MaxConn", UINT, MaxConn), VAR("MaxConn", UINT, MaxConn, "1024"),
VAR("MaxOnionsPending", UINT, MaxOnionsPending), VAR("MaxOnionsPending", UINT, MaxOnionsPending, "100"),
VAR("MonthlyAccountingStart",UINT, AccountingStart), VAR("MonthlyAccountingStart",UINT, AccountingStart, "0"),
VAR("AccountingMaxKB", UINT, AccountingMaxKB), VAR("AccountingMaxKB", UINT, AccountingMaxKB, "0"),
VAR("Nickname", STRING, Nickname), VAR("Nickname", STRING, Nickname, NULL),
VAR("NewCircuitPeriod", UINT, NewCircuitPeriod), VAR("NewCircuitPeriod", UINT, NewCircuitPeriod, "30"),
VAR("NumCpus", UINT, NumCpus), VAR("NumCpus", UINT, NumCpus, "1"),
VAR("ORPort", UINT, ORPort), VAR("ORPort", UINT, ORPort, "0"),
VAR("ORBindAddress", LINELIST, ORBindAddress), VAR("ORBindAddress", LINELIST, ORBindAddress, NULL),
VAR("OutboundBindAddress", STRING, OutboundBindAddress), VAR("OutboundBindAddress", STRING, OutboundBindAddress, NULL),
VAR("PidFile", STRING, PidFile), VAR("PidFile", STRING, PidFile, NULL),
VAR("PathlenCoinWeight", DOUBLE, PathlenCoinWeight), VAR("PathlenCoinWeight", DOUBLE, PathlenCoinWeight, "0.3"),
VAR("RedirectExit", LINELIST, RedirectExit), VAR("RedirectExit", LINELIST, RedirectExit, NULL),
OBSOLETE("RouterFile"), OBSOLETE("RouterFile"),
VAR("RunAsDaemon", BOOL, RunAsDaemon), VAR("RunAsDaemon", BOOL, RunAsDaemon, "0"),
VAR("RunTesting", BOOL, RunTesting), VAR("RunTesting", BOOL, RunTesting, "0"),
VAR("RecommendedVersions", LINELIST, RecommendedVersions), VAR("RecommendedVersions", LINELIST, RecommendedVersions, NULL),
VAR("RendNodes", STRING, RendNodes), VAR("RendNodes", STRING, RendNodes, NULL),
VAR("RendExcludeNodes", STRING, RendExcludeNodes), VAR("RendExcludeNodes", STRING, RendExcludeNodes, NULL),
VAR("SocksPort", UINT, SocksPort), VAR("SocksPort", UINT, SocksPort, "0"),
VAR("SocksBindAddress", LINELIST, SocksBindAddress), VAR("SocksBindAddress", LINELIST, SocksBindAddress, NULL),
VAR("SocksPolicy", LINELIST, SocksPolicy), VAR("SocksPolicy", LINELIST, SocksPolicy, NULL),
VAR("SysLog", LINELIST, LogOptions), VAR("SysLog", LINELIST, LogOptions, NULL),
OBSOLETE("TrafficShaping"), OBSOLETE("TrafficShaping"),
VAR("User", STRING, User), VAR("User", STRING, User, NULL),
{ NULL, CONFIG_TYPE_OBSOLETE, 0 } { NULL, CONFIG_TYPE_OBSOLETE, 0, NULL }
}; };
#undef VAR #undef VAR
#undef OBSOLETE #undef OBSOLETE
@ -589,13 +590,6 @@ static void
init_options(or_options_t *options) init_options(or_options_t *options)
{ {
memset(options,0,sizeof(or_options_t)); 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->PathlenCoinWeight = 0.3;
options->MaxConn = 1024; options->MaxConn = 1024;
options->DirFetchPostPeriod = 600; options->DirFetchPostPeriod = 600;
@ -745,7 +739,7 @@ getconfig(int argc, char **argv, or_options_t *options)
++i; ++i;
} else if (!strcmp(argv[i],"--list-fingerprint")) { } else if (!strcmp(argv[i],"--list-fingerprint")) {
options->command = CMD_LIST_FINGERPRINT; options->command = CMD_LIST_FINGERPRINT;
} }
} }
if (using_default_torrc) { if (using_default_torrc) {
@ -869,11 +863,13 @@ getconfig(int argc, char **argv, or_options_t *options)
result = -1; 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."); 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."); log(LOG_WARN, "StrictEntryNodes set, but no EntryNodes listed.");
} }

View File

@ -250,7 +250,7 @@ int connection_control_process_inbuf(connection_t *conn) {
log_fn(LOG_WARN, "Received client-only '%s' command; ignoring.", log_fn(LOG_WARN, "Received client-only '%s' command; ignoring.",
control_cmd_to_string(command_type)); control_cmd_to_string(command_type));
send_control_error(conn, ERR_UNRECOGNIZED_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; break;
default: default:
log_fn(LOG_WARN, "Received unrecognized command type %d; ignoring.", log_fn(LOG_WARN, "Received unrecognized command type %d; ignoring.",

View File

@ -293,8 +293,9 @@ add_nickname_list_to_smartlist(smartlist_t *sl, const char *list, int warn_if_do
routerinfo_t *router; routerinfo_t *router;
smartlist_t *nickname_list; smartlist_t *nickname_list;
if(!list)
return; /* nothing to do */
tor_assert(sl); tor_assert(sl);
tor_assert(list);
nickname_list = smartlist_create(); nickname_list = smartlist_create();
@ -330,8 +331,9 @@ router_nickname_is_in_list(routerinfo_t *router, const char *list)
smartlist_t *nickname_list; smartlist_t *nickname_list;
int v = 0; int v = 0;
if(!list)
return 0; /* definitely not */
tor_assert(router); tor_assert(router);
tor_assert(list);
nickname_list = smartlist_create(); nickname_list = smartlist_create();
smartlist_split_string(nickname_list, list, ",", smartlist_split_string(nickname_list, list, ",",