aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-07-14 14:28:33 -0400
committerNick Mathewson <nickm@torproject.org>2020-07-16 09:02:10 -0400
commitab428ef60b701075158f1c06676bcc394f0969b2 (patch)
treef5a800772ff36fa7d8b58fef917505d23bd8faca /src/core
parent4f4785a8c113806d00c6a31154956edb86c1639f (diff)
downloadtor-ab428ef60b701075158f1c06676bcc394f0969b2.tar.gz
tor-ab428ef60b701075158f1c06676bcc394f0969b2.zip
Collapse channel_get_*_remote_addr() into a single function.
Since we can list the real address and the canonical one in a human-readable format we don't need to pick.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/or/channel.c26
-rw-r--r--src/core/or/channel.h3
-rw-r--r--src/core/or/channelpadding.c4
-rw-r--r--src/core/or/channeltls.c2
-rw-r--r--src/core/or/circuitbuild.c2
-rw-r--r--src/core/or/circuitlist.c2
-rw-r--r--src/core/or/circuituse.c4
-rw-r--r--src/core/or/command.c12
-rw-r--r--src/core/or/connection_edge.c2
9 files changed, 20 insertions, 37 deletions
diff --git a/src/core/or/channel.c b/src/core/or/channel.c
index 2de164b39c..8390fc1ecc 100644
--- a/src/core/or/channel.c
+++ b/src/core/or/channel.c
@@ -2553,7 +2553,7 @@ channel_dump_statistics, (channel_t *chan, int severity))
/* Handle remote address and descriptions */
have_remote_addr = channel_get_addr_if_possible(chan, &remote_addr);
if (have_remote_addr) {
- char *actual = tor_strdup(channel_get_actual_remote_descr(chan));
+ char *actual = tor_strdup(channel_describe_peer(chan));
remote_addr_str = tor_addr_to_str_dup(&remote_addr);
tor_log(severity, LD_GENERAL,
" * Channel %"PRIu64 " says its remote address"
@@ -2561,18 +2561,18 @@ channel_dump_statistics, (channel_t *chan, int severity))
"actual description of \"%s\"",
(chan->global_identifier),
safe_str(remote_addr_str),
- safe_str(channel_get_canonical_remote_descr(chan)),
+ safe_str(channel_describe_peer(chan)),
safe_str(actual));
tor_free(remote_addr_str);
tor_free(actual);
} else {
- char *actual = tor_strdup(channel_get_actual_remote_descr(chan));
+ char *actual = tor_strdup(channel_describe_peer(chan));
tor_log(severity, LD_GENERAL,
" * Channel %"PRIu64 " does not know its remote "
"address, but gives a canonical description of \"%s\" and an "
"actual description of \"%s\"",
(chan->global_identifier),
- channel_get_canonical_remote_descr(chan),
+ channel_describe_peer(chan),
actual);
tor_free(actual);
}
@@ -2782,22 +2782,6 @@ channel_listener_dump_transport_statistics(channel_listener_t *chan_l,
}
/**
- * Return text description of the remote endpoint.
- *
- * This function return a test provided by the lower layer of the remote
- * endpoint for this channel; it should specify the actual address connected
- * to/from.
- *
- * Subsequent calls to channel_get_{actual,canonical}_remote_{address,descr}
- * may invalidate the return value from this function.
- */
-const char *
-channel_get_actual_remote_descr(channel_t *chan)
-{
- return channel_get_canonical_remote_descr(chan);
-}
-
-/**
* Return text description of the remote endpoint canonical address.
*
* This function returns a human-readable string for logging; nothing
@@ -2806,7 +2790,7 @@ channel_get_actual_remote_descr(channel_t *chan)
* Subsequent calls to this function may invalidate its return value.
*/
MOCK_IMPL(const char *,
-channel_get_canonical_remote_descr,(channel_t *chan))
+channel_describe_peer,(channel_t *chan))
{
tor_assert(chan);
tor_assert(chan->describe_peer);
diff --git a/src/core/or/channel.h b/src/core/or/channel.h
index 917941a0b6..d52ebdf619 100644
--- a/src/core/or/channel.h
+++ b/src/core/or/channel.h
@@ -718,10 +718,9 @@ channel_is_in_state(channel_t *chan, channel_state_t state)
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);
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));
+MOCK_DECL(const char *, channel_describe_peer,(channel_t *chan));
int channel_has_queued_writes(channel_t *chan);
int channel_is_bad_for_new_circs(channel_t *chan);
void channel_mark_bad_for_new_circs(channel_t *chan);
diff --git a/src/core/or/channelpadding.c b/src/core/or/channelpadding.c
index 0e88b8b3bd..d0c43e8bdc 100644
--- a/src/core/or/channelpadding.c
+++ b/src/core/or/channelpadding.c
@@ -265,7 +265,7 @@ channelpadding_update_padding_for_channel(channel_t *chan,
log_fn_ratelim(&relay_limit,LOG_PROTOCOL_WARN,LD_PROTOCOL,
"Got a PADDING_NEGOTIATE from relay at %s (%s). "
"This should not happen.",
- channel_get_canonical_remote_descr(chan),
+ channel_describe_peer(chan),
hex_str(chan->identity_digest, DIGEST_LEN));
return -1;
}
@@ -399,7 +399,7 @@ channelpadding_send_padding_cell_for_callback(channel_t *chan)
"Sending netflow keepalive on %"PRIu64" to %s (%s) after "
"%"PRId64" ms. Delta %"PRId64"ms",
(chan->global_identifier),
- safe_str_client(channel_get_canonical_remote_descr(chan)),
+ safe_str_client(channel_describe_peer(chan)),
safe_str_client(hex_str(chan->identity_digest, DIGEST_LEN)),
(monotime_coarse_diff_msec(&chan->timestamp_xfer,&now)),
(
diff --git a/src/core/or/channeltls.c b/src/core/or/channeltls.c
index ade26684b8..082a035c3c 100644
--- a/src/core/or/channeltls.c
+++ b/src/core/or/channeltls.c
@@ -1874,7 +1874,7 @@ channel_tls_process_netinfo_cell(cell_t *cell, channel_tls_t *chan)
if (me && !TLS_CHAN_TO_BASE(chan)->is_canonical_to_peer &&
channel_is_canonical(TLS_CHAN_TO_BASE(chan))) {
- const char *descr = channel_get_actual_remote_descr(
+ const char *descr = channel_describe_peer(
TLS_CHAN_TO_BASE(chan));
log_info(LD_OR,
"We made a connection to a relay at %s (fp=%s) but we think "
diff --git a/src/core/or/circuitbuild.c b/src/core/or/circuitbuild.c
index fd56ca1c65..6ad19eebad 100644
--- a/src/core/or/circuitbuild.c
+++ b/src/core/or/circuitbuild.c
@@ -632,7 +632,7 @@ circuit_n_chan_done(channel_t *chan, int status, int close_origin_circuits)
tor_assert(chan);
log_debug(LD_CIRC,"chan to %s, status=%d",
- channel_get_canonical_remote_descr(chan), status);
+ channel_describe_peer(chan), status);
pending_circs = smartlist_new();
circuit_get_all_pending_on_channel(pending_circs, chan);
diff --git a/src/core/or/circuitlist.c b/src/core/or/circuitlist.c
index 2455aa8779..af98af362a 100644
--- a/src/core/or/circuitlist.c
+++ b/src/core/or/circuitlist.c
@@ -619,7 +619,7 @@ circuit_count_pending_on_channel(channel_t *chan)
cnt = smartlist_len(sl);
smartlist_free(sl);
log_debug(LD_CIRC,"or_conn to %s, %d pending circs",
- channel_get_canonical_remote_descr(chan),
+ channel_describe_peer(chan),
cnt);
return cnt;
}
diff --git a/src/core/or/circuituse.c b/src/core/or/circuituse.c
index d2bdf77d8d..3c8a7c4a89 100644
--- a/src/core/or/circuituse.c
+++ b/src/core/or/circuituse.c
@@ -819,7 +819,7 @@ circuit_expire_building(void)
log_info(LD_CIRC,
"Abandoning circ %u %s:%u (state %d,%d:%s, purpose %d, "
"len %d)", TO_ORIGIN_CIRCUIT(victim)->global_identifier,
- channel_get_canonical_remote_descr(victim->n_chan),
+ channel_describe_peer(victim->n_chan),
(unsigned)victim->n_circ_id,
TO_ORIGIN_CIRCUIT(victim)->has_opened,
victim->state, circuit_state_to_string(victim->state),
@@ -1857,7 +1857,7 @@ circuit_build_failed(origin_circuit_t *circ)
"from the first hop (%s). I'm going to try to rotate to a "
"better connection.",
TO_CIRCUIT(circ)->n_circ_id, circ->global_identifier,
- channel_get_canonical_remote_descr(n_chan));
+ channel_describe_peer(n_chan));
n_chan->is_bad_for_new_circs = 1;
} else {
log_info(LD_OR,
diff --git a/src/core/or/command.c b/src/core/or/command.c
index 8a1d2066cc..9226309ff7 100644
--- a/src/core/or/command.c
+++ b/src/core/or/command.c
@@ -252,7 +252,7 @@ command_process_create_cell(cell_t *cell, channel_t *chan)
log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
"Received a create cell (type %d) from %s with zero circID; "
" ignoring.", (int)cell->command,
- channel_get_actual_remote_descr(chan));
+ channel_describe_peer(chan));
return;
}
@@ -295,7 +295,7 @@ command_process_create_cell(cell_t *cell, channel_t *chan)
"Received create cell (type %d) from %s, but we're connected "
"to it as a client. "
"Sending back a destroy.",
- (int)cell->command, channel_get_canonical_remote_descr(chan));
+ (int)cell->command, channel_describe_peer(chan));
channel_send_destroy(cell->circ_id, chan,
END_CIRC_REASON_TORPROTOCOL);
return;
@@ -475,7 +475,7 @@ command_process_relay_cell(cell_t *cell, channel_t *chan)
log_debug(LD_OR,
"unknown circuit %u on connection from %s. Dropping.",
(unsigned)cell->circ_id,
- channel_get_canonical_remote_descr(chan));
+ channel_describe_peer(chan));
return;
}
@@ -536,7 +536,7 @@ command_process_relay_cell(cell_t *cell, channel_t *chan)
control_event_circ_bandwidth_used_for_circ(TO_ORIGIN_CIRCUIT(circ));
} else if (circ->n_chan) {
log_warn(LD_OR, " upstream=%s",
- channel_get_actual_remote_descr(circ->n_chan));
+ channel_describe_peer(circ->n_chan));
}
circuit_mark_for_close(circ, END_CIRC_REASON_TORPROTOCOL);
return;
@@ -547,7 +547,7 @@ command_process_relay_cell(cell_t *cell, channel_t *chan)
"Received too many RELAY_EARLY cells on circ %u from %s."
" Closing circuit.",
(unsigned)cell->circ_id,
- safe_str(channel_get_canonical_remote_descr(chan)));
+ safe_str(channel_describe_peer(chan)));
circuit_mark_for_close(circ, END_CIRC_REASON_TORPROTOCOL);
return;
}
@@ -618,7 +618,7 @@ command_process_destroy_cell(cell_t *cell, channel_t *chan)
if (!circ) {
log_info(LD_OR,"unknown circuit %u on connection from %s. Dropping.",
(unsigned)cell->circ_id,
- channel_get_canonical_remote_descr(chan));
+ channel_describe_peer(chan));
return;
}
log_debug(LD_OR,"Received for circID %u.",(unsigned)cell->circ_id);
diff --git a/src/core/or/connection_edge.c b/src/core/or/connection_edge.c
index 2798d1bf37..8eb9f8ba0f 100644
--- a/src/core/or/connection_edge.c
+++ b/src/core/or/connection_edge.c
@@ -3973,7 +3973,7 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
* proxies. */
log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
"Attempt by %s to open a stream %s. Closing.",
- safe_str(channel_get_canonical_remote_descr(or_circ->p_chan)),
+ safe_str(channel_describe_peer(or_circ->p_chan)),
client_chan ? "on first hop of circuit" :
"from unknown relay");
relay_send_end_cell_from_edge(rh.stream_id, circ,