mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-13 06:33:44 +01:00
Refactor channel_connect_for_circuit() to take an extend_info_t.
This commit is contained in:
parent
6a0b9e4746
commit
1e97f96888
@ -94,12 +94,15 @@ static const node_t *choose_good_middle_server(uint8_t purpose,
|
|||||||
* callbacks.
|
* callbacks.
|
||||||
*/
|
*/
|
||||||
MOCK_IMPL(channel_t *,
|
MOCK_IMPL(channel_t *,
|
||||||
channel_connect_for_circuit,(const tor_addr_t *addr, uint16_t port,
|
channel_connect_for_circuit,(const extend_info_t *ei))
|
||||||
const char *id_digest,
|
|
||||||
const struct ed25519_public_key_t *ed_id))
|
|
||||||
{
|
{
|
||||||
channel_t *chan;
|
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);
|
chan = channel_connect(addr, port, id_digest, ed_id);
|
||||||
if (chan) command_setup_channel(chan);
|
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);
|
circ->base_.n_hop = extend_info_dup(firsthop->extend_info);
|
||||||
|
|
||||||
if (should_launch) {
|
if (should_launch) {
|
||||||
n_chan = channel_connect_for_circuit(
|
n_chan = channel_connect_for_circuit(firsthop->extend_info);
|
||||||
&firsthop->extend_info->addr,
|
|
||||||
firsthop->extend_info->port,
|
|
||||||
firsthop->extend_info->identity_digest,
|
|
||||||
&firsthop->extend_info->ed_identity);
|
|
||||||
if (!n_chan) { /* connect failed, forget the whole thing */
|
if (!n_chan) { /* connect failed, forget the whole thing */
|
||||||
log_info(LD_CIRC,"connect to firsthop failed. Closing.");
|
log_info(LD_CIRC,"connect to firsthop failed. Closing.");
|
||||||
return -END_CIRC_REASON_CONNECTFAILED;
|
return -END_CIRC_REASON_CONNECTFAILED;
|
||||||
|
@ -56,13 +56,7 @@ const node_t *choose_good_entry_server(uint8_t purpose,
|
|||||||
struct circuit_guard_state_t **guard_state_out);
|
struct circuit_guard_state_t **guard_state_out);
|
||||||
void circuit_upgrade_circuits_from_guard_wait(void);
|
void circuit_upgrade_circuits_from_guard_wait(void);
|
||||||
|
|
||||||
struct ed25519_public_key_t;
|
MOCK_DECL(channel_t *, channel_connect_for_circuit,(const extend_info_t *ei));
|
||||||
|
|
||||||
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));
|
|
||||||
|
|
||||||
struct create_cell_t;
|
struct create_cell_t;
|
||||||
MOCK_DECL(int,
|
MOCK_DECL(int,
|
||||||
|
@ -401,11 +401,7 @@ circuit_open_connection_for_extend(const struct extend_cell_t *ec,
|
|||||||
|
|
||||||
if (should_launch) {
|
if (should_launch) {
|
||||||
/* we should try to open a connection */
|
/* we should try to open a connection */
|
||||||
channel_t *n_chan = channel_connect_for_circuit(
|
channel_t *n_chan = channel_connect_for_circuit(circ->n_hop);
|
||||||
&circ->n_hop->addr,
|
|
||||||
circ->n_hop->port,
|
|
||||||
circ->n_hop->identity_digest,
|
|
||||||
&circ->n_hop->ed_identity);
|
|
||||||
if (!n_chan) {
|
if (!n_chan) {
|
||||||
log_info(LD_CIRC,"Launching n_chan failed. Closing circuit.");
|
log_info(LD_CIRC,"Launching n_chan failed. Closing circuit.");
|
||||||
circuit_mark_for_close(circ, END_CIRC_REASON_CONNECTFAILED);
|
circuit_mark_for_close(circ, END_CIRC_REASON_CONNECTFAILED);
|
||||||
|
@ -1001,15 +1001,9 @@ mock_circuit_mark_for_close_(circuit_t *circ, int reason,
|
|||||||
static int mock_channel_connect_calls = 0;
|
static int mock_channel_connect_calls = 0;
|
||||||
static channel_t *mock_channel_connect_nchan = NULL;
|
static channel_t *mock_channel_connect_nchan = NULL;
|
||||||
static channel_t *
|
static channel_t *
|
||||||
mock_channel_connect_for_circuit(const tor_addr_t *addr,
|
mock_channel_connect_for_circuit(const extend_info_t *ei)
|
||||||
uint16_t port,
|
|
||||||
const char *id_digest,
|
|
||||||
const struct ed25519_public_key_t *ed_id)
|
|
||||||
{
|
{
|
||||||
(void)addr;
|
(void)ei;
|
||||||
(void)port;
|
|
||||||
(void)id_digest;
|
|
||||||
(void)ed_id;
|
|
||||||
mock_channel_connect_calls++;
|
mock_channel_connect_calls++;
|
||||||
return mock_channel_connect_nchan;
|
return mock_channel_connect_nchan;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user