diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-10-17 11:23:26 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-10-17 11:23:26 -0400 |
commit | 26946c659b5abdc38fd4dc8cd4b4659aadcf05f0 (patch) | |
tree | 9c5e5979f97991046ea5d4ba318c2dc8d3f84fd0 /src/or/channeltls.c | |
parent | 898bd1ae8f1eeb880eaaeba2caa1cda435a1ac5b (diff) | |
download | tor-26946c659b5abdc38fd4dc8cd4b4659aadcf05f0.tar.gz tor-26946c659b5abdc38fd4dc8cd4b4659aadcf05f0.zip |
Restore the 'address' value of tunneled connections
When we merged the channel code, we made the 'address' field of linked
directory connections created with begindir (and their associated edge
connections) contain an address:port string, when they should only
have contained the address part.
This patch also tweaks the interface to the get_descr method of
channels so that it takes a set of flags rather than a single flag.
Diffstat (limited to 'src/or/channeltls.c')
-rw-r--r-- | src/or/channeltls.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/or/channeltls.c b/src/or/channeltls.c index 234aa3111d..a7ac83f3ae 100644 --- a/src/or/channeltls.c +++ b/src/or/channeltls.c @@ -53,7 +53,7 @@ static const char * channel_tls_describe_transport_method(channel_t *chan); static int channel_tls_get_remote_addr_method(channel_t *chan, tor_addr_t *addr_out); static const char * -channel_tls_get_remote_descr_method(channel_t *chan, int req); +channel_tls_get_remote_descr_method(channel_t *chan, int flags); static int channel_tls_has_queued_writes_method(channel_t *chan); static int channel_tls_is_canonical_method(channel_t *chan, int req); static int @@ -412,7 +412,7 @@ channel_tls_get_remote_addr_method(channel_t *chan, tor_addr_t *addr_out) */ static const char * -channel_tls_get_remote_descr_method(channel_t *chan, int req) +channel_tls_get_remote_descr_method(channel_t *chan, int flags) { #define MAX_DESCR_LEN 32 @@ -427,21 +427,34 @@ channel_tls_get_remote_descr_method(channel_t *chan, int req) conn = TO_CONN(tlschan->conn); - switch (req) { + switch (flags) { case 0: - /* Canonical address */ + /* Canonical address with port*/ tor_snprintf(buf, MAX_DESCR_LEN + 1, "%s:%u", conn->address, conn->port); answer = buf; break; - case 1: - /* Actual address */ + case GRD_FLAG_ORIGINAL: + /* Actual address with port */ addr_str = tor_dup_addr(&(tlschan->conn->real_addr)); tor_snprintf(buf, MAX_DESCR_LEN + 1, "%s:%u", addr_str, conn->port); tor_free(addr_str); answer = buf; break; + case GRD_FLAG_ADDR_ONLY: + /* Canonical address, no port */ + strlcpy(buf, conn->address, sizeof(buf)); + answer = buf; + break; + case GRD_FLAG_ORIGINAL|GRD_FLAG_ADDR_ONLY: + /* Actual address, no port */ + addr_str = tor_dup_addr(&(tlschan->conn->real_addr)); + strlcpy(buf, addr_str, sizeof(buf)); + tor_free(addr_str); + answer = buf; + break; + default: /* Something's broken in channel.c */ tor_assert(1); |