diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-07-01 14:42:55 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-07-02 09:51:04 -0400 |
commit | 1e97f968882f12edad20874ada99c2bd8542119d (patch) | |
tree | 31ee477578e6e7ac83cf6f8df5507bb639589fb9 /src | |
parent | 6a0b9e47462d7c0bcb4598343cc7d6e7689216d7 (diff) | |
download | tor-1e97f968882f12edad20874ada99c2bd8542119d.tar.gz tor-1e97f968882f12edad20874ada99c2bd8542119d.zip |
Refactor channel_connect_for_circuit() to take an extend_info_t.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/or/circuitbuild.c | 15 | ||||
-rw-r--r-- | src/core/or/circuitbuild.h | 8 | ||||
-rw-r--r-- | src/feature/relay/circuitbuild_relay.c | 6 | ||||
-rw-r--r-- | src/test/test_circuitbuild.c | 10 |
4 files changed, 11 insertions, 28 deletions
diff --git a/src/core/or/circuitbuild.c b/src/core/or/circuitbuild.c index 1f9b5050ef..d1f097c25a 100644 --- a/src/core/or/circuitbuild.c +++ b/src/core/or/circuitbuild.c @@ -94,12 +94,15 @@ static const node_t *choose_good_middle_server(uint8_t purpose, * callbacks. */ MOCK_IMPL(channel_t *, -channel_connect_for_circuit,(const tor_addr_t *addr, uint16_t port, - const char *id_digest, - const struct ed25519_public_key_t *ed_id)) +channel_connect_for_circuit,(const extend_info_t *ei)) { channel_t *chan; + const tor_addr_t *addr = &ei->addr; + uint16_t port = ei->port; + const char *id_digest = ei->identity_digest; + const ed25519_public_key_t *ed_id = &ei->ed_identity; + chan = channel_connect(addr, port, id_digest, ed_id); if (chan) command_setup_channel(chan); @@ -581,11 +584,7 @@ circuit_handle_first_hop(origin_circuit_t *circ) circ->base_.n_hop = extend_info_dup(firsthop->extend_info); if (should_launch) { - n_chan = channel_connect_for_circuit( - &firsthop->extend_info->addr, - firsthop->extend_info->port, - firsthop->extend_info->identity_digest, - &firsthop->extend_info->ed_identity); + n_chan = channel_connect_for_circuit(firsthop->extend_info); if (!n_chan) { /* connect failed, forget the whole thing */ log_info(LD_CIRC,"connect to firsthop failed. Closing."); return -END_CIRC_REASON_CONNECTFAILED; diff --git a/src/core/or/circuitbuild.h b/src/core/or/circuitbuild.h index bbb78eada7..0cd1eb4f45 100644 --- a/src/core/or/circuitbuild.h +++ b/src/core/or/circuitbuild.h @@ -56,13 +56,7 @@ const node_t *choose_good_entry_server(uint8_t purpose, struct circuit_guard_state_t **guard_state_out); void circuit_upgrade_circuits_from_guard_wait(void); -struct ed25519_public_key_t; - -MOCK_DECL(channel_t *, -channel_connect_for_circuit,(const tor_addr_t *addr, - uint16_t port, - const char *id_digest, - const struct ed25519_public_key_t *ed_id)); +MOCK_DECL(channel_t *, channel_connect_for_circuit,(const extend_info_t *ei)); struct create_cell_t; MOCK_DECL(int, diff --git a/src/feature/relay/circuitbuild_relay.c b/src/feature/relay/circuitbuild_relay.c index 36e64d9b33..881cbd51be 100644 --- a/src/feature/relay/circuitbuild_relay.c +++ b/src/feature/relay/circuitbuild_relay.c @@ -401,11 +401,7 @@ circuit_open_connection_for_extend(const struct extend_cell_t *ec, if (should_launch) { /* we should try to open a connection */ - channel_t *n_chan = channel_connect_for_circuit( - &circ->n_hop->addr, - circ->n_hop->port, - circ->n_hop->identity_digest, - &circ->n_hop->ed_identity); + channel_t *n_chan = channel_connect_for_circuit(circ->n_hop); if (!n_chan) { log_info(LD_CIRC,"Launching n_chan failed. Closing circuit."); circuit_mark_for_close(circ, END_CIRC_REASON_CONNECTFAILED); diff --git a/src/test/test_circuitbuild.c b/src/test/test_circuitbuild.c index e1fbd333d7..f7a27146b0 100644 --- a/src/test/test_circuitbuild.c +++ b/src/test/test_circuitbuild.c @@ -1001,15 +1001,9 @@ mock_circuit_mark_for_close_(circuit_t *circ, int reason, static int mock_channel_connect_calls = 0; static channel_t *mock_channel_connect_nchan = NULL; static channel_t * -mock_channel_connect_for_circuit(const tor_addr_t *addr, - uint16_t port, - const char *id_digest, - const struct ed25519_public_key_t *ed_id) +mock_channel_connect_for_circuit(const extend_info_t *ei) { - (void)addr; - (void)port; - (void)id_digest; - (void)ed_id; + (void)ei; mock_channel_connect_calls++; return mock_channel_connect_nchan; } |