diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-07-14 14:08:55 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-07-16 09:02:10 -0400 |
commit | db21e91f4bda5860dea2d817c1f707f57119abee (patch) | |
tree | 87c80d62b2579d3eea5c41143cac8de61ad39e7d /src/core | |
parent | 0ccdf05dc54bf956348b0647414732b6a497d17a (diff) | |
download | tor-db21e91f4bda5860dea2d817c1f707f57119abee.tar.gz tor-db21e91f4bda5860dea2d817c1f707f57119abee.zip |
Remove "ADDR_ONLY" mode from channel_get_*_remote_descr.
This mode was only used in one place, and it caused a dangerous
mingling of functionality. The method is supposed to _describe_ the
peer's address, not give its actual address. We already had a
function to get the actual address.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/or/channel.c | 13 | ||||
-rw-r--r-- | src/core/or/channel.h | 5 | ||||
-rw-r--r-- | src/core/or/channeltls.c | 12 | ||||
-rw-r--r-- | src/core/or/connection_edge.c | 9 |
4 files changed, 7 insertions, 32 deletions
diff --git a/src/core/or/channel.c b/src/core/or/channel.c index deb27a4d78..5ea38256ac 100644 --- a/src/core/or/channel.c +++ b/src/core/or/channel.c @@ -2802,19 +2802,6 @@ channel_get_actual_remote_descr(channel_t *chan) } /** - * Return the text address of the remote endpoint. - * - * Subsequent calls to channel_get_{actual,canonical}_remote_{address,descr} - * may invalidate the return value from this function. - */ -const char * -channel_get_actual_remote_address(channel_t *chan) -{ - /* Param 1 indicates the actual description */ - return chan->get_remote_descr(chan, GRD_FLAG_ORIGINAL|GRD_FLAG_ADDR_ONLY); -} - -/** * Return text description of the remote endpoint canonical address. * * This function return a test provided by the lower layer of the remote diff --git a/src/core/or/channel.h b/src/core/or/channel.h index 9aa59da2cb..f047d24f66 100644 --- a/src/core/or/channel.h +++ b/src/core/or/channel.h @@ -337,12 +337,10 @@ struct channel_t { int (*get_transport_name)(channel_t *chan, char **transport_out); #define GRD_FLAG_ORIGINAL 1 -#define GRD_FLAG_ADDR_ONLY 2 /** * Get a text description of the remote endpoint; canonicalized if the flag * GRD_FLAG_ORIGINAL is not set, or the one we originally connected - * to/received from if it is. If GRD_FLAG_ADDR_ONLY is set, we return only - * the original address. + * to/received from if it is. */ const char * (*get_remote_descr)(channel_t *, int); /** Check if the lower layer has queued writes */ @@ -723,7 +721,6 @@ const char * channel_describe_transport(channel_t *chan); MOCK_DECL(void, channel_dump_statistics, (channel_t *chan, int severity)); void channel_dump_transport_statistics(channel_t *chan, int severity); const char * channel_get_actual_remote_descr(channel_t *chan); -const char * channel_get_actual_remote_address(channel_t *chan); MOCK_DECL(int, channel_get_addr_if_possible, (const channel_t *chan, tor_addr_t *addr_out)); MOCK_DECL(const char *, channel_get_canonical_remote_descr,(channel_t *chan)); diff --git a/src/core/or/channeltls.c b/src/core/or/channeltls.c index 8273235efb..3a10b2c27d 100644 --- a/src/core/or/channeltls.c +++ b/src/core/or/channeltls.c @@ -601,18 +601,6 @@ channel_tls_get_remote_descr_method(channel_t *chan, int flags) 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_addr_to_str_dup(&(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_nonfatal_unreached_once(); diff --git a/src/core/or/connection_edge.c b/src/core/or/connection_edge.c index cd4ec8be7b..2798d1bf37 100644 --- a/src/core/or/connection_edge.c +++ b/src/core/or/connection_edge.c @@ -3996,10 +3996,13 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ) * caller might want to know whether the remote IP address has changed, * and we might already have corrected base_.addr[ess] for the relay's * canonical IP address. */ - if (or_circ && or_circ->p_chan) - address = tor_strdup(channel_get_actual_remote_address(or_circ->p_chan)); - else + tor_addr_t chan_addr; + if (or_circ && or_circ->p_chan && + channel_get_addr_if_possible(or_circ->p_chan, &chan_addr)) { + address = tor_addr_to_str_dup(&chan_addr); + } else { address = tor_strdup("127.0.0.1"); + } port = 1; /* XXXX This value is never actually used anywhere, and there * isn't "really" a connection here. But we * need to set it to something nonzero. */ |