mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
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.
This commit is contained in:
+5
-21
@@ -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);
|
||||
}
|
||||
@@ -2781,22 +2781,6 @@ channel_listener_dump_transport_statistics(channel_listener_t *chan_l,
|
||||
if (chan_l->dumpstats) chan_l->dumpstats(chan_l, severity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)),
|
||||
(
|
||||
|
||||
@@ -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 "
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -501,7 +501,7 @@ circuit_extend(struct cell_t *cell, struct circuit_t *circ)
|
||||
circ->n_chan = n_chan;
|
||||
log_debug(LD_CIRC,
|
||||
"n_chan is %s.",
|
||||
channel_get_canonical_remote_descr(n_chan));
|
||||
channel_describe_peer(n_chan));
|
||||
|
||||
if (circuit_deliver_create_cell(circ, &ec.create_cell, 1) < 0)
|
||||
return -1;
|
||||
|
||||
@@ -1286,7 +1286,7 @@ test_circuit_extend(void *arg)
|
||||
MOCK(server_mode, mock_server_mode);
|
||||
|
||||
/* Mock a debug function, but otherwise ignore it */
|
||||
MOCK(channel_get_canonical_remote_descr,
|
||||
MOCK(channel_describe_peer,
|
||||
mock_channel_get_canonical_remote_descr);
|
||||
|
||||
setup_full_capture_of_logs(LOG_INFO);
|
||||
@@ -1479,7 +1479,7 @@ test_circuit_extend(void *arg)
|
||||
UNMOCK(server_mode);
|
||||
server = 0;
|
||||
|
||||
UNMOCK(channel_get_canonical_remote_descr);
|
||||
UNMOCK(channel_describe_peer);
|
||||
|
||||
UNMOCK(extend_cell_parse);
|
||||
memset(&mock_extend_cell_parse_cell_out, 0,
|
||||
|
||||
Reference in New Issue
Block a user