From ded70363a71ab52b965998c90587fb398e5048f0 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 10 Sep 2012 15:54:16 -0400 Subject: Rename DirServer to DirAuthority --- doc/tor.1.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'doc/tor.1.txt') diff --git a/doc/tor.1.txt b/doc/tor.1.txt index 1a7f8d597b..112af81fbf 100644 --- a/doc/tor.1.txt +++ b/doc/tor.1.txt @@ -292,7 +292,7 @@ GENERAL OPTIONS **DataDirectory** __DIR__:: Store working data in DIR (Default: @LOCALSTATEDIR@/lib/tor) -**DirServer** [__nickname__] [**flags**] __address__:__port__ __fingerprint__:: +**DirAuthority** [__nickname__] [**flags**] __address__:__port__ __fingerprint__:: Use a nonstandard authoritative directory server at the provided address and port, with the specified key fingerprint. This option can be repeated many times, for multiple authoritative directory servers. Flags are @@ -309,8 +309,8 @@ GENERAL OPTIONS flag "v3ident=**fp**" is given, the dirserver is a v3 directory authority whose v3 long-term signing key has the fingerprint **fp**. + + - If no **dirserver** line is given, Tor will use the default directory - servers. NOTE: this option is intended for setting up a private Tor + If no **DirAuthority** line is given, Tor will use the default directory + authorities. NOTE: this option is intended for setting up a private Tor network with its own directory authorities. If you use it, you will be distinguishable from other users, because you won't believe the same authorities they do. @@ -326,7 +326,7 @@ GENERAL OPTIONS **AlternateHSAuthority** [__nickname__] [**flags**] __address__:__port__ __fingerprint__ + **AlternateBridgeAuthority** [__nickname__] [**flags**] __address__:__port__ __ fingerprint__:: - These options behave as DirServer, but they replace fewer of the + These options behave as DirAuthority, but they replace fewer of the default directory authorities. Using AlternateDirAuthority replaces the default Tor directory authorities, but leaves the default hidden service authorities and bridge authorities in -- cgit v1.2.3-54-g00ecf From 90f6071d8dc0c23c0a2e7713ae1bba5ef44d09c2 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 10 Sep 2012 18:13:28 -0400 Subject: New FallbackDir option to add extra directories for bootstraping This replaces the old FallbackConsensus notion, and should provide a way -- assuming we pick reasonable nodes! -- to give clients suggestions of placs to go to get their first consensus. --- changes/fallback_dirsource | 9 +++ doc/tor.1.txt | 5 ++ src/or/config.c | 136 +++++++++++++++++++++++++++++++++++++++++---- src/or/or.h | 4 ++ src/or/router.c | 2 +- src/or/routerlist.c | 15 +++-- src/or/routerlist.h | 4 +- 7 files changed, 155 insertions(+), 20 deletions(-) create mode 100644 changes/fallback_dirsource (limited to 'doc/tor.1.txt') diff --git a/changes/fallback_dirsource b/changes/fallback_dirsource new file mode 100644 index 0000000000..61db81bf26 --- /dev/null +++ b/changes/fallback_dirsource @@ -0,0 +1,9 @@ + o Major features: + - Add a new FallbackDir option to use when we can't use a directory + from the consensus (either because we lack a consensus, or because + they're all down). Currently, all authorities are fallbacks by + default, and there are no other default fallbacks, but that will + change. This option will allow us to give clients a longer list + of servers to try to get a consensus from when first connecting + to the Tor network, and thereby reduce load on the directory + authorities. diff --git a/doc/tor.1.txt b/doc/tor.1.txt index 112af81fbf..2633899ca8 100644 --- a/doc/tor.1.txt +++ b/doc/tor.1.txt @@ -292,6 +292,11 @@ GENERAL OPTIONS **DataDirectory** __DIR__:: Store working data in DIR (Default: @LOCALSTATEDIR@/lib/tor) +**FallbackDir** __address__:__port__ orport=__port__ id=__fingerprint__:: + When we're unable to connect to any directory cache for directory info + (usually because we don't know about any yet) we try a FallbackDir. + By default, the directory authorities are also FallbackDirs. + **DirAuthority** [__nickname__] [**flags**] __address__:__port__ __fingerprint__:: Use a nonstandard authoritative directory server at the provided address and port, with the specified key fingerprint. This option can be repeated diff --git a/src/or/config.c b/src/or/config.c index a4ccf07413..63c8d48dc0 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -228,6 +228,7 @@ static config_var_t option_vars_[] = { V(ExitPortStatistics, BOOL, "0"), V(ExtendAllowPrivateAddresses, BOOL, "0"), V(ExtraInfoStatistics, BOOL, "1"), + V(FallbackDir, LINELIST, NULL), #if defined (WINCE) V(FallbackNetworkstatusFile, FILENAME, "fallback-consensus"), @@ -474,6 +475,8 @@ static char *get_bindaddr_from_transport_listen_line(const char *line, static int parse_dir_authority_line(const char *line, dirinfo_type_t required_type, int validate_only); +static int parse_dir_fallback_line(const char *line, + int validate_only); static void port_cfg_free(port_cfg_t *port); static int parse_ports(or_options_t *options, int validate_only, char **msg_out, int *n_ports_out); @@ -756,7 +759,7 @@ static void add_default_trusted_dir_authorities(dirinfo_type_t type) { int i; - const char *dirservers[] = { + const char *authorities[] = { "moria1 orport=9101 no-v2 " "v3ident=D586D18309DED4CD6D57C18FDB97EFA96D330566 " "128.31.0.39:9131 9695 DFC3 5FFE B861 329B 9F1A B04C 4639 7020 CE31", @@ -785,10 +788,27 @@ add_default_trusted_dir_authorities(dirinfo_type_t type) "154.35.32.5:80 CF6D 0AAF B385 BE71 B8E1 11FC 5CFF 4B47 9237 33BC", NULL }; - for (i=0; dirservers[i]; i++) { - if (parse_dir_authority_line(dirservers[i], type, 0)<0) { - log_err(LD_BUG, "Couldn't parse internal dirserver line %s", - dirservers[i]); + for (i=0; authorities[i]; i++) { + if (parse_dir_authority_line(authorities[i], type, 0)<0) { + log_err(LD_BUG, "Couldn't parse internal DirAuthority line %s", + authorities[i]); + } + } +} + +/** Add the default fallback directory servers into the fallback directory + * server list. */ +static void +add_default_fallback_dir_servers(void) +{ + int i; + const char *fallback[] = { + NULL + }; + for (i=0; fallback[i]; i++) { + if (parse_dir_fallback_line(fallback[i], 0)<0) { + log_err(LD_BUG, "Couldn't parse internal FallbackDir line %s", + fallback[i]); } } } @@ -798,7 +818,7 @@ add_default_trusted_dir_authorities(dirinfo_type_t type) * user if we changed any dangerous ones. */ static int -validate_dir_authorities(or_options_t *options, or_options_t *old_options) +validate_dir_servers(or_options_t *options, or_options_t *old_options) { config_line_t *cl; @@ -842,6 +862,9 @@ validate_dir_authorities(or_options_t *options, or_options_t *old_options) for (cl = options->AlternateHSAuthority; cl; cl = cl->next) if (parse_dir_authority_line(cl->value, NO_DIRINFO, 1)<0) return -1; + for (cl = options->FallbackDir; cl; cl = cl->next) + if (parse_dir_fallback_line(cl->value, 1)<0) + return -1; return 0; } @@ -849,14 +872,15 @@ validate_dir_authorities(or_options_t *options, or_options_t *old_options) * as appropriate. */ static int -consider_adding_dir_authorities(const or_options_t *options, - const or_options_t *old_options) +consider_adding_dir_servers(const or_options_t *options, + const or_options_t *old_options) { config_line_t *cl; int need_to_update = !smartlist_len(router_get_trusted_dir_servers()) || !smartlist_len(router_get_fallback_dir_servers()) || !old_options || !config_lines_eq(options->DirAuthorities, old_options->DirAuthorities) || + !config_lines_eq(options->FallbackDir, old_options->FallbackDir) || !config_lines_eq(options->AlternateBridgeAuthority, old_options->AlternateBridgeAuthority) || !config_lines_eq(options->AlternateDirAuthority, @@ -882,6 +906,8 @@ consider_adding_dir_authorities(const or_options_t *options, type |= HIDSERV_DIRINFO; add_default_trusted_dir_authorities(type); } + if (!options->FallbackDir) + add_default_fallback_dir_servers(); for (cl = options->DirAuthorities; cl; cl = cl->next) if (parse_dir_authority_line(cl->value, NO_DIRINFO, 0)<0) @@ -895,6 +921,9 @@ consider_adding_dir_authorities(const or_options_t *options, for (cl = options->AlternateHSAuthority; cl; cl = cl->next) if (parse_dir_authority_line(cl->value, NO_DIRINFO, 0)<0) return -1; + for (cl = options->FallbackDir; cl; cl = cl->next) + if (parse_dir_fallback_line(cl->value, 0)<0) + return -1; return 0; } @@ -1217,7 +1246,7 @@ options_act(const or_options_t *old_options) return -1; } - if (consider_adding_dir_authorities(options, old_options) < 0) + if (consider_adding_dir_servers(options, old_options) < 0) return -1; #ifdef NON_ANONYMOUS_MODE_ENABLED @@ -2844,8 +2873,9 @@ options_validate(or_options_t *old_options, or_options_t *options, if (validate_addr_policies(options, msg) < 0) return -1; - if (validate_dir_authorities(options, old_options) < 0) - REJECT("Directory authority line did not parse. See logs for details."); + if (validate_dir_servers(options, old_options) < 0) + REJECT("Directory authority/fallback line did not parse. See logs " + "for details."); if (options->UseBridges && !options->Bridges) REJECT("If you set UseBridges, you must specify at least one bridge."); @@ -4439,7 +4469,7 @@ parse_dir_authority_line(const char *line, dirinfo_type_t required_type, log_debug(LD_DIR, "Trusted %d dirserver at %s:%d (%s)", (int)type, address, (int)dir_port, (char*)smartlist_get(items,0)); if (!(ds = trusted_dir_server_new(nickname, address, dir_port, or_port, - digest, v3_digest, type))) + digest, v3_digest, type, 1.0))) goto err; dir_server_add(ds); } @@ -4460,6 +4490,88 @@ parse_dir_authority_line(const char *line, dirinfo_type_t required_type, return r; } +/** Read the contents of a FallbackDir line from line. If + * validate_only is 0, and the line is well-formed, then add the + * dirserver described in the line as a fallback directory. Return 0 on + * success, or -1 if the line isn't well-formed or if we can't add it. */ +static int +parse_dir_fallback_line(const char *line, + int validate_only) +{ + int r = -1; + smartlist_t *items = smartlist_new(), *positional = smartlist_new(); + int orport = -1; + uint16_t dirport; + tor_addr_t addr; + int ok; + char id[DIGEST_LEN]; + char *address=NULL; + + memset(id, 0, sizeof(id)); + smartlist_split_string(items, line, NULL, + SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, -1); + SMARTLIST_FOREACH_BEGIN(items, const char *, cp) { + const char *eq = strchr(cp, '='); + ok = 1; + if (! eq) { + smartlist_add(positional, (char*)cp); + continue; + } + if (!strcmpstart(cp, "orport=")) + orport = (int)tor_parse_long(cp+strlen("orport="), 10, + 1, 65535, &ok, NULL); + else if (!strcmpstart(cp, "id=")) + ok = !base16_decode(id, DIGEST_LEN, + cp+strlen("id="), strlen(cp)-strlen("id=")); + if (!ok) { + log_warn(LD_CONFIG, "Bad FallbackDir option %s", escaped(cp)); + goto end; + } + } SMARTLIST_FOREACH_END(cp); + + if (smartlist_len(positional) != 1) { + log_warn(LD_CONFIG, "Couldn't parse FallbackDir line %s", escaped(line)); + goto end; + } + + if (tor_digest_is_zero(id)) { + log_warn(LD_CONFIG, "Missing identity on FallbackDir line"); + goto end; + } + + if (orport <= 0) { + log_warn(LD_CONFIG, "Missing orport on FallbackDir line"); + goto end; + } + + if (tor_addr_port_split(LOG_INFO, smartlist_get(positional, 0), + &address, &dirport) < 0 || + tor_addr_parse(&addr, address)<0) { + log_warn(LD_CONFIG, "Couldn't parse address:port %s on FallbackDir line", + (const char*)smartlist_get(positional, 0)); + goto end; + } + + if (!validate_only) { + dir_server_t *ds; + ds = fallback_dir_server_new(&addr, dirport, orport, id, 1.0); + if (!ds) { + log_warn(LD_CONFIG, "Couldn't create FallbackDir %s", escaped(line)); + goto end; + } + dir_server_add(ds); + } + + r = 0; + + end: + SMARTLIST_FOREACH(items, char *, cp, tor_free(cp)); + smartlist_free(items); + smartlist_free(positional); + tor_free(address); + return r; +} + /** Free all storage held in port */ static void port_cfg_free(port_cfg_t *port) diff --git a/src/or/or.h b/src/or/or.h index 70490a6e05..70e00071f5 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -3428,6 +3428,9 @@ typedef struct { * use the "Alternate*Authority" options below instead. */ config_line_t *DirAuthorities; + /** List of fallback directory servers */ + config_line_t *FallbackDir; + /** If set, use these main (currently v3) directory authorities and * not the default ones. */ config_line_t *AlternateDirAuthority; @@ -4496,6 +4499,7 @@ typedef struct dir_server_t { uint32_t addr; /**< IPv4 address. */ uint16_t dir_port; /**< Directory port. */ uint16_t or_port; /**< OR port: Used for tunneling connections. */ + double weight; /** Weight used when selecting this node at random */ char digest[DIGEST_LEN]; /**< Digest of identity key. */ char v3_identity_digest[DIGEST_LEN]; /**< Digest of v3 (authority only, * high-security) identity key. */ diff --git a/src/or/router.c b/src/or/router.c index 34eb66af10..5786103b94 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -737,7 +737,7 @@ init_keys(void) router_get_advertised_or_port(options), digest, v3_digest, - type); + type, 0.0); if (!ds) { log_err(LD_GENERAL,"We want to be a directory authority, but we " "couldn't add ourselves to the authority list. Failing."); diff --git a/src/or/routerlist.c b/src/or/routerlist.c index ac4e46d7ae..e6e741334e 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -3785,12 +3785,16 @@ dir_server_new(int is_authority, const char *hostname, uint16_t dir_port, uint16_t or_port, const char *digest, const char *v3_auth_digest, - dirinfo_type_t type) + dirinfo_type_t type, + double weight) { dir_server_t *ent; uint32_t a; char *hostname_ = NULL; + if (weight < 0) + return NULL; + if (tor_addr_family(addr) == AF_INET) a = tor_addr_to_ipv4h(addr); else @@ -3810,6 +3814,7 @@ dir_server_new(int is_authority, ent->is_running = 1; ent->is_authority = is_authority; ent->type = type; + ent->weight = weight; memcpy(ent->digest, digest, DIGEST_LEN); if (v3_auth_digest && (type & V3_DIRINFO)) memcpy(ent->v3_identity_digest, v3_auth_digest, DIGEST_LEN); @@ -3842,7 +3847,7 @@ dir_server_t * trusted_dir_server_new(const char *nickname, const char *address, uint16_t dir_port, uint16_t or_port, const char *digest, const char *v3_auth_digest, - dirinfo_type_t type) + dirinfo_type_t type, double weight) { uint32_t a; tor_addr_t addr; @@ -3869,7 +3874,7 @@ trusted_dir_server_new(const char *nickname, const char *address, result = dir_server_new(1, nickname, &addr, hostname, dir_port, or_port, digest, - v3_auth_digest, type); + v3_auth_digest, type, weight); tor_free(hostname); return result; } @@ -3880,10 +3885,10 @@ trusted_dir_server_new(const char *nickname, const char *address, dir_server_t * fallback_dir_server_new(const tor_addr_t *addr, uint16_t dir_port, uint16_t or_port, - const char *id_digest) + const char *id_digest, double weight) { return dir_server_new(0, NULL, addr, NULL, dir_port, or_port, id_digest, - NULL, ALL_DIRINFO); + NULL, ALL_DIRINFO, weight); } /** Add a directory server to the global list(s). */ diff --git a/src/or/routerlist.h b/src/or/routerlist.h index 1d527d0220..81ba1ac54f 100644 --- a/src/or/routerlist.h +++ b/src/or/routerlist.h @@ -136,10 +136,10 @@ int router_exit_policy_rejects_all(const routerinfo_t *router); dir_server_t *trusted_dir_server_new(const char *nickname, const char *address, uint16_t dir_port, uint16_t or_port, const char *digest, const char *v3_auth_digest, - dirinfo_type_t type); + dirinfo_type_t type, double weight); dir_server_t *fallback_dir_server_new(const tor_addr_t *addr, uint16_t dir_port, uint16_t or_port, - const char *id_digest); + const char *id_digest, double weight); void dir_server_add(dir_server_t *ent); void authority_cert_free(authority_cert_t *cert); -- cgit v1.2.3-54-g00ecf From 06cd62266f4ce15cf71692344df82b3260fedb89 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 12 Sep 2012 13:30:09 -0400 Subject: Add a way to configure selection weights for dir_server_t --- doc/tor.1.txt | 6 ++++-- src/or/config.c | 28 ++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) (limited to 'doc/tor.1.txt') diff --git a/doc/tor.1.txt b/doc/tor.1.txt index 2633899ca8..e79d21e594 100644 --- a/doc/tor.1.txt +++ b/doc/tor.1.txt @@ -292,7 +292,7 @@ GENERAL OPTIONS **DataDirectory** __DIR__:: Store working data in DIR (Default: @LOCALSTATEDIR@/lib/tor) -**FallbackDir** __address__:__port__ orport=__port__ id=__fingerprint__:: +**FallbackDir** __address__:__port__ orport=__port__ id=__fingerprint__ [weight=__num__]:: When we're unable to connect to any directory cache for directory info (usually because we don't know about any yet) we try a FallbackDir. By default, the directory authorities are also FallbackDirs. @@ -310,7 +310,9 @@ GENERAL OPTIONS flag is set, or if the "v1" flag is set and the "no-hs" flag is **not** set. Tor will use this authority as a bridge authoritative directory if the "bridge" flag is set. If a flag "orport=**port**" is given, Tor will use the - given port when opening encrypted tunnels to the dirserver. Lastly, if a + given port when opening encrypted tunnels to the dirserver. If a flag + "weight=**num**" is given, then the directory server is chosen randomly + with probability proportional to that weight (default 1.0). Lastly, if a flag "v3ident=**fp**" is given, the dirserver is a v3 directory authority whose v3 long-term signing key has the fingerprint **fp**. + + diff --git a/src/or/config.c b/src/or/config.c index 63c8d48dc0..af699d9504 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -4371,6 +4371,7 @@ parse_dir_authority_line(const char *line, dirinfo_type_t required_type, char v3_digest[DIGEST_LEN]; dirinfo_type_t type = V2_DIRINFO; int is_not_hidserv_authority = 0, is_not_v2_authority = 0; + double weight = 1.0; items = smartlist_new(); smartlist_split_string(items, line, NULL, @@ -4406,6 +4407,14 @@ parse_dir_authority_line(const char *line, dirinfo_type_t required_type, if (!ok) log_warn(LD_CONFIG, "Invalid orport '%s' on DirServer line.", portstring); + } else if (!strcmpstart(flag, "weight=")) { + int ok; + const char *wstring = flag + strlen("weight="); + weight = tor_parse_double(wstring, 0, UINT64_MAX, &ok, NULL); + if (!ok) { + log_warn(LD_CONFIG, "Invalid weight '%s' on DirAuthority line.",flag); + weight=1.0; + } } else if (!strcasecmpstart(flag, "v3ident=")) { char *idstr = flag + strlen("v3ident="); if (strlen(idstr) != HEX_DIGEST_LEN || @@ -4469,7 +4478,7 @@ parse_dir_authority_line(const char *line, dirinfo_type_t required_type, log_debug(LD_DIR, "Trusted %d dirserver at %s:%d (%s)", (int)type, address, (int)dir_port, (char*)smartlist_get(items,0)); if (!(ds = trusted_dir_server_new(nickname, address, dir_port, or_port, - digest, v3_digest, type, 1.0))) + digest, v3_digest, type, weight))) goto err; dir_server_add(ds); } @@ -4506,6 +4515,7 @@ parse_dir_fallback_line(const char *line, int ok; char id[DIGEST_LEN]; char *address=NULL; + double weight=1.0; memset(id, 0, sizeof(id)); smartlist_split_string(items, line, NULL, @@ -4517,12 +4527,22 @@ parse_dir_fallback_line(const char *line, smartlist_add(positional, (char*)cp); continue; } - if (!strcmpstart(cp, "orport=")) + if (!strcmpstart(cp, "orport=")) { orport = (int)tor_parse_long(cp+strlen("orport="), 10, 1, 65535, &ok, NULL); - else if (!strcmpstart(cp, "id=")) + } else if (!strcmpstart(cp, "id=")) { ok = !base16_decode(id, DIGEST_LEN, cp+strlen("id="), strlen(cp)-strlen("id=")); + } else if (!strcmpstart(cp, "weight=")) { + int ok; + const char *wstring = cp + strlen("weight="); + weight = tor_parse_double(wstring, 0, UINT64_MAX, &ok, NULL); + if (!ok) { + log_warn(LD_CONFIG, "Invalid weight '%s' on FallbackDir line.", cp); + weight=1.0; + } + } + if (!ok) { log_warn(LD_CONFIG, "Bad FallbackDir option %s", escaped(cp)); goto end; @@ -4554,7 +4574,7 @@ parse_dir_fallback_line(const char *line, if (!validate_only) { dir_server_t *ds; - ds = fallback_dir_server_new(&addr, dirport, orport, id, 1.0); + ds = fallback_dir_server_new(&addr, dirport, orport, id, weight); if (!ds) { log_warn(LD_CONFIG, "Couldn't create FallbackDir %s", escaped(line)); goto end; -- cgit v1.2.3-54-g00ecf From a8d491a8fdfafe6e56924a19b5169c2eb9d3a66a Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 12 Sep 2012 13:56:36 -0400 Subject: Add an option to weight down authorities when choosing a fallback --- doc/tor.1.txt | 6 ++++++ src/or/config.c | 1 + src/or/or.h | 4 ++++ src/or/routerlist.c | 9 +++++++-- 4 files changed, 18 insertions(+), 2 deletions(-) (limited to 'doc/tor.1.txt') diff --git a/doc/tor.1.txt b/doc/tor.1.txt index e79d21e594..231ac528d2 100644 --- a/doc/tor.1.txt +++ b/doc/tor.1.txt @@ -322,6 +322,12 @@ GENERAL OPTIONS distinguishable from other users, because you won't believe the same authorities they do. +**DirAuthorityFallbackRate** __NUM__:: + When configured to use both directory authorities and fallback + directories, the directory authorities also work as fallbacks. They are + chosen with their regular weights, multiplied by this number, which + should be 1.0 or less. (Default: 1.0) + **DynamicDHGroups** **0**|**1**:: If this option is set to 1, when running as a server, generate our own Diffie-Hellman group instead of using the one from Apache's mod_ssl. diff --git a/src/or/config.c b/src/or/config.c index af699d9504..17b5b79ce4 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -208,6 +208,7 @@ static config_var_t option_vars_[] = { OBSOLETE("DirRecordUsageSaveInterval"), V(DirReqStatistics, BOOL, "1"), VAR("DirAuthority", LINELIST, DirAuthorities, NULL), + V(DirAuthorityFallbackRate, DOUBLE, "1.0"), V(DisableAllSwap, BOOL, "0"), V(DisableDebuggerAttachment, BOOL, "1"), V(DisableIOCP, BOOL, "1"), diff --git a/src/or/or.h b/src/or/or.h index cbb437e86c..9f9316b988 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -3431,6 +3431,10 @@ typedef struct { /** List of fallback directory servers */ config_line_t *FallbackDir; + /** Weight to apply to all directory authority rates if considering them + * along with fallbackdirs */ + double DirAuthorityFallbackRate; + /** If set, use these main (currently v3) directory authorities and * not the default ones. */ config_line_t *AlternateDirAuthority; diff --git a/src/or/routerlist.c b/src/or/routerlist.c index a5dd9c40f3..5536d1c61b 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -1252,7 +1252,7 @@ router_pick_directory_server_impl(dirinfo_type_t type, int flags) /** Pick a random element from a list of dir_server_t, weighting by their * weight field. */ static const dir_server_t * -dirserver_choose_by_weight(const smartlist_t *servers) +dirserver_choose_by_weight(const smartlist_t *servers, double authority_weight) { int n = smartlist_len(servers); int i; @@ -1263,6 +1263,8 @@ dirserver_choose_by_weight(const smartlist_t *servers) for (i = 0; i < n; ++i) { ds = smartlist_get(servers, i); weights[i].dbl = ds->weight; + if (ds->is_authority) + weights[i].dbl *= authority_weight; } scale_array_elements_to_u64(weights, n, NULL); @@ -1290,6 +1292,8 @@ router_pick_trusteddirserver_impl(const smartlist_t *sourcelist, const int prefer_tunnel = (flags & PDS_PREFER_TUNNELED_DIR_CONNS_); const int no_serverdesc_fetching =(flags & PDS_NO_EXISTING_SERVERDESC_FETCH); const int no_microdesc_fetching =(flags & PDS_NO_EXISTING_MICRODESC_FETCH); + const double auth_weight = (sourcelist == fallback_dir_servers) ? + options->DirAuthorityFallbackRate : 1.0; smartlist_t *pick_from; int n_busy = 0; int try_excluding = 1, n_excluded = 0; @@ -1368,7 +1372,8 @@ router_pick_trusteddirserver_impl(const smartlist_t *sourcelist, } { - const dir_server_t *selection = dirserver_choose_by_weight(pick_from); + const dir_server_t *selection = + dirserver_choose_by_weight(pick_from, auth_weight); if (selection) result = &selection->fake_status; -- cgit v1.2.3-54-g00ecf From f742b33d85c0884fa5902d0d24a1232c9bd47dd8 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 10 Oct 2012 00:08:35 -0400 Subject: Drop FallbackNetworkstatusFile; it never worked. --- changes/fallback_dirsource | 4 ++++ doc/tor.1.txt | 6 ------ src/or/config.c | 7 +------ src/or/networkstatus.c | 24 ------------------------ src/or/or.h | 4 ---- 5 files changed, 5 insertions(+), 40 deletions(-) (limited to 'doc/tor.1.txt') diff --git a/changes/fallback_dirsource b/changes/fallback_dirsource index 61db81bf26..d8d6c02aa4 100644 --- a/changes/fallback_dirsource +++ b/changes/fallback_dirsource @@ -7,3 +7,7 @@ of servers to try to get a consensus from when first connecting to the Tor network, and thereby reduce load on the directory authorities. + + o Removed features: + - Drop the old FallbackNetworkstatus option: we never got it working + well enough to use it. diff --git a/doc/tor.1.txt b/doc/tor.1.txt index 231ac528d2..c9be6cd5d8 100644 --- a/doc/tor.1.txt +++ b/doc/tor.1.txt @@ -1129,12 +1129,6 @@ The following options are useful only for clients (that is, if regular router descriptors. Tor does not use this information for anything itself; to save bandwidth, leave this option turned off. (Default: 0) -**FallbackNetworkstatusFile** __FILENAME__:: - If Tor doesn't have a cached networkstatus file, it starts out using this - one instead. Even if this file is out of date, Tor can still use it to - learn about directory mirrors, so it doesn't need to put load on the - authorities. (Default: None) - **WarnPlaintextPorts** __port__,__port__,__...__:: Tells Tor to issue a warnings whenever the user tries to make an anonymous connection to one of these ports. This option is designed to alert users diff --git a/src/or/config.c b/src/or/config.c index 17b5b79ce4..59b4abdfb0 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -231,12 +231,7 @@ static config_var_t option_vars_[] = { V(ExtraInfoStatistics, BOOL, "1"), V(FallbackDir, LINELIST, NULL), -#if defined (WINCE) - V(FallbackNetworkstatusFile, FILENAME, "fallback-consensus"), -#else - V(FallbackNetworkstatusFile, FILENAME, - SHARE_DATADIR PATH_SEPARATOR "tor" PATH_SEPARATOR "fallback-consensus"), -#endif + OBSOLETE("FallbackNetworkstatusFile"), V(FascistFirewall, BOOL, "0"), V(FirewallPorts, CSV, ""), V(FastFirstHopPK, BOOL, "1"), diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 937d61929d..9d402403c0 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -219,8 +219,6 @@ router_reload_consensus_networkstatus(void) { char *filename; char *s; - struct stat st; - const or_options_t *options = get_options(); const unsigned int flags = NSSET_FROM_CACHE | NSSET_DONT_DOWNLOAD_CERTS; int flav; @@ -263,25 +261,6 @@ router_reload_consensus_networkstatus(void) tor_free(filename); } - if (!current_consensus || - (stat(options->FallbackNetworkstatusFile, &st)==0 && - st.st_mtime > current_consensus->valid_after)) { - s = read_file_to_str(options->FallbackNetworkstatusFile, - RFTS_IGNORE_MISSING, NULL); - if (s) { - if (networkstatus_set_current_consensus(s, "ns", - flags|NSSET_ACCEPT_OBSOLETE)) { - log_info(LD_FS, "Couldn't load consensus networkstatus from \"%s\"", - options->FallbackNetworkstatusFile); - } else { - log_notice(LD_FS, - "Loaded fallback consensus networkstatus from \"%s\"", - options->FallbackNetworkstatusFile); - } - tor_free(s); - } - } - if (!current_consensus) { if (!named_server_map) named_server_map = strmap_new(); @@ -1674,9 +1653,6 @@ networkstatus_set_current_consensus(const char *consensus, if (from_cache && !accept_obsolete && c->valid_until < now-OLD_ROUTER_DESC_MAX_AGE) { - /* XXXX If we try to make fallbackconsensus work again, we should - * consider taking this out. Until then, believing obsolete consensuses - * is causing more harm than good. See also bug 887. */ log_info(LD_DIR, "Loaded an expired consensus. Discarding."); goto done; } diff --git a/src/or/or.h b/src/or/or.h index 9f9316b988..b2d31a67fa 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -3702,10 +3702,6 @@ typedef struct { * of certain configuration options. */ int TestingTorNetwork; - /** File to check for a consensus networkstatus, if we don't have one - * cached. */ - char *FallbackNetworkstatusFile; - /** If true, and we have GeoIP data, and we're a bridge, keep a per-country * count of how many client addresses have contacted us so that we can help * the bridge authority guess which countries have blocked access to us. */ -- cgit v1.2.3-54-g00ecf