diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-06-02 12:56:45 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-06-02 12:56:45 -0400 |
commit | 0a4a3de3def27a7c7f8a514546b33662d0cfe6c5 (patch) | |
tree | 3872a4bd54487de1985fa8d35baa83b5ced627a8 /src | |
parent | 9ac2f63e0f3f1fd333b23ee6e6c02ae7cf0f71d2 (diff) | |
parent | df42eb0a18a9f6fe4b729a1c9a63bb6ab247f631 (diff) | |
download | tor-0a4a3de3def27a7c7f8a514546b33662d0cfe6c5.tar tor-0a4a3de3def27a7c7f8a514546b33662d0cfe6c5.tar.gz |
Merge remote-tracking branch 'origin/maint-0.2.2'
Conflicts:
src/or/dirserv.c
Diffstat (limited to 'src')
-rw-r--r-- | src/or/connection.c | 4 | ||||
-rw-r--r-- | src/or/dirserv.c | 4 | ||||
-rw-r--r-- | src/or/router.c | 18 | ||||
-rw-r--r-- | src/or/router.h | 3 |
4 files changed, 17 insertions, 12 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index f59b36ab9..81f0cdf81 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -2008,7 +2008,7 @@ retry_all_listeners(smartlist_t *replaced_conns, or_options_t *options = get_options(); int retval = 0; const uint16_t old_or_port = router_get_advertised_or_port(options); - const uint16_t old_dir_port = router_get_advertised_dir_port(options); + const uint16_t old_dir_port = router_get_advertised_dir_port(options, 0); if (retry_listeners(CONN_TYPE_OR_LISTENER, options->ORListenAddress, options->ORPort, "0.0.0.0", @@ -2054,7 +2054,7 @@ retry_all_listeners(smartlist_t *replaced_conns, return -1; if (old_or_port != router_get_advertised_or_port(options) || - old_dir_port != router_get_advertised_dir_port(options)) { + old_dir_port != router_get_advertised_dir_port(options, 0)) { /* Our chosen ORPort or DirPort is not what it used to be: the * descriptor we had (if any) should be regenerated. (We won't * automatically notice this because of changes in the option, diff --git a/src/or/dirserv.c b/src/or/dirserv.c index c591d906e..fef9450d7 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -2732,7 +2732,7 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_env_t *private_key, voter->sigs = smartlist_create(); voter->address = hostname; voter->addr = addr; - voter->dir_port = router_get_advertised_dir_port(options); + voter->dir_port = router_get_advertised_dir_port(options, 0); voter->or_port = router_get_advertised_or_port(options); voter->contact = tor_strdup(contact); if (options->V3AuthUseLegacyKey) { @@ -2836,7 +2836,7 @@ generate_v2_networkstatus_opinion(void) "%s" /* client version line, server version line. */ "dir-signing-key\n%s", hostname, fmt_addr32(addr), - (int)router_get_advertised_dir_port(options), + (int)router_get_advertised_dir_port(options, 0), fingerprint, contact, published, diff --git a/src/or/router.c b/src/or/router.c index a7879635c..34ea8babd 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -707,7 +707,7 @@ init_keys(void) ds = router_get_trusteddirserver_by_digest(digest); if (!ds) { ds = add_trusted_dir_server(options->Nickname, NULL, - router_get_advertised_dir_port(options), + router_get_advertised_dir_port(options, 0), router_get_advertised_or_port(options), digest, v3_digest, @@ -805,7 +805,7 @@ decide_to_advertise_dirport(or_options_t *options, uint16_t dir_port) return 0; if (!check_whether_dirport_reachable()) return 0; - if (!router_get_advertised_dir_port(options)) + if (!router_get_advertised_dir_port(options, dir_port)) return 0; /* Section two: reasons to publish or not publish that the user @@ -1190,12 +1190,16 @@ router_get_advertised_or_port(or_options_t *options) return options->ORPort; } -/** Return the port that we should advertise as our DirPort; this is either - * the one configured in the DirPort option, or the one we actually bound to - * if DirPort is "auto". */ +/** Return the port that we should advertise as our DirPort; + * this is one of three possibilities: + * The one that is passed as <b>dirport</b> if the DirPort option is 0, or + * the one configured in the DirPort option, + * or the one we actually bound to if DirPort is "auto". */ uint16_t -router_get_advertised_dir_port(or_options_t *options) +router_get_advertised_dir_port(or_options_t *options, uint16_t dirport) { + if (!options->DirPort) + return dirport; if (options->DirPort == CFG_AUTO_PORT) { connection_t *c = connection_get_by_type(CONN_TYPE_DIR_LISTENER); if (c) @@ -1442,7 +1446,7 @@ router_rebuild_descriptor(int force) ri->nickname = tor_strdup(options->Nickname); ri->addr = addr; ri->or_port = router_get_advertised_or_port(options); - ri->dir_port = router_get_advertised_dir_port(options); + ri->dir_port = router_get_advertised_dir_port(options, 0); ri->cache_info.published_on = time(NULL); ri->onion_pkey = crypto_pk_dup_key(get_onion_key()); /* must invoke from * main thread */ diff --git a/src/or/router.h b/src/or/router.h index e208eb122..dc9ab5e9e 100644 --- a/src/or/router.h +++ b/src/or/router.h @@ -51,7 +51,8 @@ int authdir_mode_tests_reachability(or_options_t *options); int authdir_mode_bridge(or_options_t *options); uint16_t router_get_advertised_or_port(or_options_t *options); -uint16_t router_get_advertised_dir_port(or_options_t *options); +uint16_t router_get_advertised_dir_port(or_options_t *options, + uint16_t dirport); int server_mode(or_options_t *options); int public_server_mode(or_options_t *options); |