diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-11-01 04:14:23 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-11-01 04:14:23 +0000 |
commit | 401b5c26de8d83f6af105abe560a0adc63890873 (patch) | |
tree | 961c73eac5abfbacf9e9a611699c5409bc559ccf /src/or | |
parent | 7712ddf8e7fe324ec675da9c6142009b8d29d4d1 (diff) | |
download | tor-401b5c26de8d83f6af105abe560a0adc63890873.tar tor-401b5c26de8d83f6af105abe560a0adc63890873.tar.gz |
r16320@catbus: nickm | 2007-11-01 00:11:20 -0400
Learn new addresses for authorities from their certificates.
svn:r12305
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/config.c | 1 | ||||
-rw-r--r-- | src/or/or.h | 6 | ||||
-rw-r--r-- | src/or/routerlist.c | 17 |
3 files changed, 24 insertions, 0 deletions
diff --git a/src/or/config.c b/src/or/config.c index b891cda42..71c6fef9f 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -202,6 +202,7 @@ static config_var_t _option_vars[] = { V(HttpsProxyAuthenticator, STRING, NULL), OBSOLETE("IgnoreVersion"), V(KeepalivePeriod, INTERVAL, "5 minutes"), + V(LearnAuthorityAddrFromCerts, BOOL, "1"), VAR("Log", LINELIST, Logs, NULL), OBSOLETE("LinkPadding"), OBSOLETE("LogLevel"), diff --git a/src/or/or.h b/src/or/or.h index ac832d8fb..afc190639 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2228,6 +2228,10 @@ typedef struct { /** DOCDOC here and in tor.1 */ char *FallbackNetworkstatusFile; + + /** DOCDOC here and in tor.1 */ + int LearnAuthorityAddrFromCerts; + } or_options_t; /** Persistent state for an onion router, as saved to disk. */ @@ -3649,6 +3653,8 @@ typedef struct trusted_dir_server_t { * latest certificate. */ download_status_t v2_ns_dl_status; /**< Status of downloading this server's * v2 network status. */ + time_t addr_current_at; /**< When was the document that we derived the + * address information from published? */ routerstatus_t fake_status; /**< Used when we need to pass this trusted * dir_server_t to directory_initiate_command_* diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 52125b8dc..0b4500248 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -108,6 +108,7 @@ trusted_dirs_load_certs_from_string(const char *contents, int from_store) { trusted_dir_server_t *ds; const char *s, *eos; + or_options_t *options = get_options(); for (s = contents; *s; s = eos) { authority_cert_t *cert = authority_cert_parse_from_string(s, &eos); @@ -141,6 +142,22 @@ trusted_dirs_load_certs_from_string(const char *contents, int from_store) continue; smartlist_add(ds->v3_certs, cert); + if (options->LearnAuthorityAddrFromCerts && + cert->cache_info.published_on > ds->addr_current_at) { + if (cert->addr && cert->dir_port && + (ds->addr != cert->addr || + ds->dir_port != cert->dir_port)) { + char *a = tor_dup_addr(cert->addr); + log_notice(LD_DIR, "Updating address for directory authority %s " + "from %s:%d to %s:%d based on in certificate.", + ds->nickname, ds->address, (int)ds->dir_port, + a, cert->dir_port); + tor_free(a); + ds->addr = cert->addr; + ds->dir_port = cert->dir_port; + } + ds->addr_current_at = cert->cache_info.published_on; + } if (!from_store) trusted_dir_servers_certs_changed = 1; |