mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Move entry_port_cfg_t fields in entry_connection_t
Also rename some options for uniformity, and apply this script: @@ entry_connection_t *conn; @@ conn-> +entry_cfg. \( isolation_flags \| session_group \| socks_prefer_no_auth \| ipv4_traffic \| ipv6_traffic \| prefer_ipv6 \| cache_ipv4_answers \| cache_ipv6_answers \| use_cached_ipv4_answers \| use_cached_ipv6_answers \| prefer_ipv6_virtaddr \)
This commit is contained in:
+4
-4
@@ -670,10 +670,10 @@ client_dns_set_addressmap(entry_connection_t *for_conn,
|
||||
return; /* If address was an IP address already, don't add a mapping. */
|
||||
|
||||
if (tor_addr_family(val) == AF_INET) {
|
||||
if (! for_conn->cache_ipv4_answers)
|
||||
if (! for_conn->entry_cfg.cache_ipv4_answers)
|
||||
return;
|
||||
} else if (tor_addr_family(val) == AF_INET6) {
|
||||
if (! for_conn->cache_ipv6_answers)
|
||||
if (! for_conn->entry_cfg.cache_ipv6_answers)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -702,8 +702,8 @@ client_dns_set_reverse_addressmap(entry_connection_t *for_conn,
|
||||
{
|
||||
tor_addr_t tmp_addr;
|
||||
sa_family_t f = tor_addr_parse(&tmp_addr, address);
|
||||
if ((f == AF_INET && ! for_conn->cache_ipv4_answers) ||
|
||||
(f == AF_INET6 && ! for_conn->cache_ipv6_answers))
|
||||
if ((f == AF_INET && ! for_conn->entry_cfg.cache_ipv4_answers) ||
|
||||
(f == AF_INET6 && ! for_conn->entry_cfg.cache_ipv6_answers))
|
||||
return;
|
||||
}
|
||||
tor_asprintf(&s, "REVERSE[%s]", address);
|
||||
|
||||
+12
-12
@@ -305,9 +305,9 @@ entry_connection_new(int type, int socket_family)
|
||||
* in a little while. Otherwise, we're doing this as a linked connection
|
||||
* of some kind, and we should set it up here based on the socket family */
|
||||
if (socket_family == AF_INET)
|
||||
entry_conn->ipv4_traffic_ok = 1;
|
||||
entry_conn->entry_cfg.ipv4_traffic = 1;
|
||||
else if (socket_family == AF_INET6)
|
||||
entry_conn->ipv6_traffic_ok = 1;
|
||||
entry_conn->entry_cfg.ipv6_traffic = 1;
|
||||
return entry_conn;
|
||||
}
|
||||
|
||||
@@ -1483,20 +1483,20 @@ connection_init_accepted_conn(connection_t *conn,
|
||||
return rv;
|
||||
break;
|
||||
case CONN_TYPE_AP:
|
||||
TO_ENTRY_CONN(conn)->isolation_flags = listener->entry_cfg.isolation_flags;
|
||||
TO_ENTRY_CONN(conn)->session_group = listener->entry_cfg.session_group;
|
||||
TO_ENTRY_CONN(conn)->entry_cfg.isolation_flags = listener->entry_cfg.isolation_flags;
|
||||
TO_ENTRY_CONN(conn)->entry_cfg.session_group = listener->entry_cfg.session_group;
|
||||
TO_ENTRY_CONN(conn)->nym_epoch = get_signewnym_epoch();
|
||||
TO_ENTRY_CONN(conn)->socks_request->listener_type = listener->base_.type;
|
||||
TO_ENTRY_CONN(conn)->ipv4_traffic_ok = listener->entry_cfg.ipv4_traffic;
|
||||
TO_ENTRY_CONN(conn)->ipv6_traffic_ok = listener->entry_cfg.ipv6_traffic;
|
||||
TO_ENTRY_CONN(conn)->prefer_ipv6_traffic = listener->entry_cfg.prefer_ipv6;
|
||||
TO_ENTRY_CONN(conn)->cache_ipv4_answers = listener->entry_cfg.cache_ipv4_answers;
|
||||
TO_ENTRY_CONN(conn)->cache_ipv6_answers = listener->entry_cfg.cache_ipv6_answers;
|
||||
TO_ENTRY_CONN(conn)->use_cached_ipv4_answers =
|
||||
TO_ENTRY_CONN(conn)->entry_cfg.ipv4_traffic = listener->entry_cfg.ipv4_traffic;
|
||||
TO_ENTRY_CONN(conn)->entry_cfg.ipv6_traffic = listener->entry_cfg.ipv6_traffic;
|
||||
TO_ENTRY_CONN(conn)->entry_cfg.prefer_ipv6 = listener->entry_cfg.prefer_ipv6;
|
||||
TO_ENTRY_CONN(conn)->entry_cfg.cache_ipv4_answers = listener->entry_cfg.cache_ipv4_answers;
|
||||
TO_ENTRY_CONN(conn)->entry_cfg.cache_ipv6_answers = listener->entry_cfg.cache_ipv6_answers;
|
||||
TO_ENTRY_CONN(conn)->entry_cfg.use_cached_ipv4_answers =
|
||||
listener->entry_cfg.use_cached_ipv4_answers;
|
||||
TO_ENTRY_CONN(conn)->use_cached_ipv6_answers =
|
||||
TO_ENTRY_CONN(conn)->entry_cfg.use_cached_ipv6_answers =
|
||||
listener->entry_cfg.use_cached_ipv6_answers;
|
||||
TO_ENTRY_CONN(conn)->prefer_ipv6_virtaddr =
|
||||
TO_ENTRY_CONN(conn)->entry_cfg.prefer_ipv6_virtaddr =
|
||||
listener->entry_cfg.prefer_ipv6_virtaddr;
|
||||
|
||||
switch (TO_CONN(listener)->type) {
|
||||
|
||||
+26
-26
@@ -968,9 +968,9 @@ connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn,
|
||||
const char *new_addr;
|
||||
int addr_type = RESOLVED_TYPE_IPV4;
|
||||
if (conn->socks_request->socks_version != 4) {
|
||||
if (!conn->ipv4_traffic_ok ||
|
||||
(conn->ipv6_traffic_ok && conn->prefer_ipv6_traffic) ||
|
||||
conn->prefer_ipv6_virtaddr)
|
||||
if (!conn->entry_cfg.ipv4_traffic ||
|
||||
(conn->entry_cfg.ipv6_traffic && conn->entry_cfg.prefer_ipv6) ||
|
||||
conn->entry_cfg.prefer_ipv6_virtaddr)
|
||||
addr_type = RESOLVED_TYPE_IPV6;
|
||||
}
|
||||
new_addr = addressmap_register_virtual_address(
|
||||
@@ -990,9 +990,9 @@ connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn,
|
||||
|
||||
if (socks->command == SOCKS_COMMAND_RESOLVE_PTR) {
|
||||
unsigned rewrite_flags = 0;
|
||||
if (conn->use_cached_ipv4_answers)
|
||||
if (conn->entry_cfg.use_cached_ipv4_answers)
|
||||
rewrite_flags |= AMR_FLAG_USE_IPV4_DNS;
|
||||
if (conn->use_cached_ipv6_answers)
|
||||
if (conn->entry_cfg.use_cached_ipv6_answers)
|
||||
rewrite_flags |= AMR_FLAG_USE_IPV6_DNS;
|
||||
|
||||
if (addressmap_rewrite_reverse(socks->address, sizeof(socks->address),
|
||||
@@ -1028,9 +1028,9 @@ connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn,
|
||||
} else if (!automap) {
|
||||
/* For address map controls, remap the address. */
|
||||
unsigned rewrite_flags = 0;
|
||||
if (conn->use_cached_ipv4_answers)
|
||||
if (conn->entry_cfg.use_cached_ipv4_answers)
|
||||
rewrite_flags |= AMR_FLAG_USE_IPV4_DNS;
|
||||
if (conn->use_cached_ipv6_answers)
|
||||
if (conn->entry_cfg.use_cached_ipv6_answers)
|
||||
rewrite_flags |= AMR_FLAG_USE_IPV6_DNS;
|
||||
if (addressmap_rewrite(socks->address, sizeof(socks->address),
|
||||
rewrite_flags, &map_expires, &exit_source)) {
|
||||
@@ -1235,8 +1235,8 @@ connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn,
|
||||
/* XXX Duplicate call to tor_addr_parse. */
|
||||
if (tor_addr_parse(&addr, socks->address) >= 0) {
|
||||
sa_family_t family = tor_addr_family(&addr);
|
||||
if ((family == AF_INET && ! conn->ipv4_traffic_ok) ||
|
||||
(family == AF_INET6 && ! conn->ipv4_traffic_ok)) {
|
||||
if ((family == AF_INET && ! conn->entry_cfg.ipv4_traffic) ||
|
||||
(family == AF_INET6 && ! conn->entry_cfg.ipv4_traffic)) {
|
||||
log_warn(LD_NET, "Rejecting SOCKS request for an IP address "
|
||||
"family that this listener does not support.");
|
||||
connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);
|
||||
@@ -1245,21 +1245,21 @@ connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn,
|
||||
log_warn(LD_NET, "Rejecting SOCKS4 request for an IPv6 address.");
|
||||
connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);
|
||||
return -1;
|
||||
} else if (socks->socks_version == 4 && !conn->ipv4_traffic_ok) {
|
||||
} else if (socks->socks_version == 4 && !conn->entry_cfg.ipv4_traffic) {
|
||||
log_warn(LD_NET, "Rejecting SOCKS4 request on a listener with "
|
||||
"no IPv4 traffic supported.");
|
||||
connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);
|
||||
return -1;
|
||||
} else if (family == AF_INET6) {
|
||||
conn->ipv4_traffic_ok = 0;
|
||||
conn->entry_cfg.ipv4_traffic = 0;
|
||||
} else if (family == AF_INET) {
|
||||
conn->ipv6_traffic_ok = 0;
|
||||
conn->entry_cfg.ipv6_traffic = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (socks->socks_version == 4)
|
||||
conn->ipv6_traffic_ok = 0;
|
||||
conn->entry_cfg.ipv6_traffic = 0;
|
||||
|
||||
if (!conn->use_begindir && !conn->chosen_exit_name && !circ) {
|
||||
/* see if we can find a suitable enclave exit */
|
||||
@@ -1826,19 +1826,19 @@ connection_ap_get_begincell_flags(entry_connection_t *ap_conn)
|
||||
return 0;
|
||||
|
||||
/* If only IPv4 is supported, no flags */
|
||||
if (ap_conn->ipv4_traffic_ok && !ap_conn->ipv6_traffic_ok)
|
||||
if (ap_conn->entry_cfg.ipv4_traffic && !ap_conn->entry_cfg.ipv6_traffic)
|
||||
return 0;
|
||||
|
||||
if (! cpath_layer ||
|
||||
! cpath_layer->extend_info)
|
||||
return 0;
|
||||
|
||||
if (!ap_conn->ipv4_traffic_ok)
|
||||
if (!ap_conn->entry_cfg.ipv4_traffic)
|
||||
flags |= BEGIN_FLAG_IPV4_NOT_OK;
|
||||
|
||||
exitnode = node_get_by_id(cpath_layer->extend_info->identity_digest);
|
||||
|
||||
if (ap_conn->ipv6_traffic_ok && exitnode) {
|
||||
if (ap_conn->entry_cfg.ipv6_traffic && exitnode) {
|
||||
tor_addr_t a;
|
||||
tor_addr_make_null(&a, AF_INET6);
|
||||
if (compare_tor_addr_to_node_policy(&a, ap_conn->socks_request->port,
|
||||
@@ -1853,7 +1853,7 @@ connection_ap_get_begincell_flags(entry_connection_t *ap_conn)
|
||||
if (flags == BEGIN_FLAG_IPV6_OK) {
|
||||
/* When IPv4 and IPv6 are both allowed, consider whether to say we
|
||||
* prefer IPv6. Otherwise there's no point in declaring a preference */
|
||||
if (ap_conn->prefer_ipv6_traffic)
|
||||
if (ap_conn->entry_cfg.prefer_ipv6)
|
||||
flags |= BEGIN_FLAG_IPV6_PREFERRED;
|
||||
}
|
||||
|
||||
@@ -2090,8 +2090,8 @@ connection_ap_make_link(connection_t *partner,
|
||||
/* Populate isolation fields. */
|
||||
conn->socks_request->listener_type = CONN_TYPE_DIR_LISTENER;
|
||||
conn->original_dest_address = tor_strdup(address);
|
||||
conn->session_group = session_group;
|
||||
conn->isolation_flags = isolation_flags;
|
||||
conn->entry_cfg.session_group = session_group;
|
||||
conn->entry_cfg.isolation_flags = isolation_flags;
|
||||
|
||||
base_conn->address = tor_strdup("(Tor_internal)");
|
||||
tor_addr_make_unspec(&base_conn->addr);
|
||||
@@ -2947,10 +2947,10 @@ connection_ap_can_use_exit(const entry_connection_t *conn, const node_t *exit)
|
||||
addr_policy_result_t r;
|
||||
if (0 == tor_addr_parse(&addr, conn->socks_request->address)) {
|
||||
addrp = &addr;
|
||||
} else if (!conn->ipv4_traffic_ok && conn->ipv6_traffic_ok) {
|
||||
} else if (!conn->entry_cfg.ipv4_traffic && conn->entry_cfg.ipv6_traffic) {
|
||||
tor_addr_make_null(&addr, AF_INET6);
|
||||
addrp = &addr;
|
||||
} else if (conn->ipv4_traffic_ok && !conn->ipv6_traffic_ok) {
|
||||
} else if (conn->entry_cfg.ipv4_traffic && !conn->entry_cfg.ipv6_traffic) {
|
||||
tor_addr_make_null(&addr, AF_INET);
|
||||
addrp = &addr;
|
||||
}
|
||||
@@ -3056,7 +3056,7 @@ int
|
||||
connection_edge_compatible_with_circuit(const entry_connection_t *conn,
|
||||
const origin_circuit_t *circ)
|
||||
{
|
||||
const uint8_t iso = conn->isolation_flags;
|
||||
const uint8_t iso = conn->entry_cfg.isolation_flags;
|
||||
const socks_request_t *sr = conn->socks_request;
|
||||
|
||||
/* If circ has never been used for an isolated connection, we can
|
||||
@@ -3105,7 +3105,7 @@ connection_edge_compatible_with_circuit(const entry_connection_t *conn,
|
||||
if ((iso & ISO_CLIENTADDR) &&
|
||||
!tor_addr_eq(&ENTRY_TO_CONN(conn)->addr, &circ->client_addr))
|
||||
return 0;
|
||||
if ((iso & ISO_SESSIONGRP) && conn->session_group != circ->session_group)
|
||||
if ((iso & ISO_SESSIONGRP) && conn->entry_cfg.session_group != circ->session_group)
|
||||
return 0;
|
||||
if ((iso & ISO_NYM_EPOCH) && conn->nym_epoch != circ->nym_epoch)
|
||||
return 0;
|
||||
@@ -3144,7 +3144,7 @@ connection_edge_update_circuit_isolation(const entry_connection_t *conn,
|
||||
circ->client_proto_type = conn->socks_request->listener_type;
|
||||
circ->client_proto_socksver = conn->socks_request->socks_version;
|
||||
tor_addr_copy(&circ->client_addr, &ENTRY_TO_CONN(conn)->addr);
|
||||
circ->session_group = conn->session_group;
|
||||
circ->session_group = conn->entry_cfg.session_group;
|
||||
circ->nym_epoch = conn->nym_epoch;
|
||||
circ->socks_username = sr->username ?
|
||||
tor_memdup(sr->username, sr->usernamelen) : NULL;
|
||||
@@ -3171,7 +3171,7 @@ connection_edge_update_circuit_isolation(const entry_connection_t *conn,
|
||||
mixed |= ISO_CLIENTPROTO;
|
||||
if (!tor_addr_eq(&ENTRY_TO_CONN(conn)->addr, &circ->client_addr))
|
||||
mixed |= ISO_CLIENTADDR;
|
||||
if (conn->session_group != circ->session_group)
|
||||
if (conn->entry_cfg.session_group != circ->session_group)
|
||||
mixed |= ISO_SESSIONGRP;
|
||||
if (conn->nym_epoch != circ->nym_epoch)
|
||||
mixed |= ISO_NYM_EPOCH;
|
||||
@@ -3179,7 +3179,7 @@ connection_edge_update_circuit_isolation(const entry_connection_t *conn,
|
||||
if (dry_run)
|
||||
return mixed;
|
||||
|
||||
if ((mixed & conn->isolation_flags) != 0) {
|
||||
if ((mixed & conn->entry_cfg.isolation_flags) != 0) {
|
||||
log_warn(LD_BUG, "Updating a circuit with seemingly incompatible "
|
||||
"isolation flags.");
|
||||
}
|
||||
|
||||
+10
-10
@@ -141,13 +141,13 @@ evdns_server_callback(struct evdns_server_request *req, void *data_)
|
||||
}
|
||||
|
||||
if (q->type == EVDNS_TYPE_A || q->type == EVDNS_QTYPE_ALL) {
|
||||
entry_conn->ipv4_traffic_ok = 1;
|
||||
entry_conn->ipv6_traffic_ok = 0;
|
||||
entry_conn->prefer_ipv6_traffic = 0;
|
||||
entry_conn->entry_cfg.ipv4_traffic = 1;
|
||||
entry_conn->entry_cfg.ipv6_traffic = 0;
|
||||
entry_conn->entry_cfg.prefer_ipv6 = 0;
|
||||
} else if (q->type == EVDNS_TYPE_AAAA) {
|
||||
entry_conn->ipv4_traffic_ok = 0;
|
||||
entry_conn->ipv6_traffic_ok = 1;
|
||||
entry_conn->prefer_ipv6_traffic = 1;
|
||||
entry_conn->entry_cfg.ipv4_traffic = 0;
|
||||
entry_conn->entry_cfg.ipv6_traffic = 1;
|
||||
entry_conn->entry_cfg.prefer_ipv6 = 1;
|
||||
}
|
||||
|
||||
strlcpy(entry_conn->socks_request->address, q->name,
|
||||
@@ -155,8 +155,8 @@ evdns_server_callback(struct evdns_server_request *req, void *data_)
|
||||
|
||||
entry_conn->socks_request->listener_type = listener->base_.type;
|
||||
entry_conn->dns_server_request = req;
|
||||
entry_conn->isolation_flags = listener->entry_cfg.isolation_flags;
|
||||
entry_conn->session_group = listener->entry_cfg.session_group;
|
||||
entry_conn->entry_cfg.isolation_flags = listener->entry_cfg.isolation_flags;
|
||||
entry_conn->entry_cfg.session_group = listener->entry_cfg.session_group;
|
||||
entry_conn->nym_epoch = get_signewnym_epoch();
|
||||
|
||||
if (connection_add(ENTRY_TO_CONN(entry_conn)) < 0) {
|
||||
@@ -232,9 +232,9 @@ dnsserv_launch_request(const char *name, int reverse,
|
||||
|
||||
entry_conn->socks_request->listener_type = CONN_TYPE_CONTROL_LISTENER;
|
||||
entry_conn->original_dest_address = tor_strdup(name);
|
||||
entry_conn->session_group = SESSION_GROUP_CONTROL_RESOLVE;
|
||||
entry_conn->entry_cfg.session_group = SESSION_GROUP_CONTROL_RESOLVE;
|
||||
entry_conn->nym_epoch = get_signewnym_epoch();
|
||||
entry_conn->isolation_flags = ISO_DEFAULT;
|
||||
entry_conn->entry_cfg.isolation_flags = ISO_DEFAULT;
|
||||
|
||||
if (connection_add(TO_CONN(conn))<0) {
|
||||
log_warn(LD_APP, "Couldn't register dummy connection for RESOLVE request");
|
||||
|
||||
+2
-31
@@ -1611,12 +1611,10 @@ typedef struct entry_connection_t {
|
||||
* only.) */
|
||||
|
||||
/* === Isolation related, AP only. === */
|
||||
/** AP only: based on which factors do we isolate this stream? */
|
||||
uint8_t isolation_flags;
|
||||
/** AP only: what session group is this stream in? */
|
||||
int session_group;
|
||||
entry_port_cfg_t entry_cfg;
|
||||
/** AP only: The newnym epoch in which we created this connection. */
|
||||
unsigned nym_epoch;
|
||||
|
||||
/** AP only: The original requested address before we rewrote it. */
|
||||
char *original_dest_address;
|
||||
/* Other fields to isolate on already exist. The ClientAddr is addr. The
|
||||
@@ -1675,33 +1673,6 @@ typedef struct entry_connection_t {
|
||||
*/
|
||||
unsigned int may_use_optimistic_data : 1;
|
||||
|
||||
/** Should we permit IPv4 and IPv6 traffic to use this connection?
|
||||
*
|
||||
* @{ */
|
||||
unsigned int ipv4_traffic_ok : 1;
|
||||
unsigned int ipv6_traffic_ok : 1;
|
||||
/** @} */
|
||||
/** Should we say we prefer IPv6 traffic? */
|
||||
unsigned int prefer_ipv6_traffic : 1;
|
||||
|
||||
/** For a socks listener: should we cache IPv4/IPv6 DNS information that
|
||||
* exit nodes tell us?
|
||||
*
|
||||
* @{ */
|
||||
unsigned int cache_ipv4_answers : 1;
|
||||
unsigned int cache_ipv6_answers : 1;
|
||||
/** @} */
|
||||
/** For a socks listeners: if we find an answer in our client-side DNS cache,
|
||||
* should we use it?
|
||||
*
|
||||
* @{ */
|
||||
unsigned int use_cached_ipv4_answers : 1;
|
||||
unsigned int use_cached_ipv6_answers : 1;
|
||||
/** @} */
|
||||
/** For socks listeners: When we can automap an address to IPv4 or IPv6,
|
||||
* do we prefer IPv6? */
|
||||
unsigned int prefer_ipv6_virtaddr : 1;
|
||||
|
||||
} entry_connection_t;
|
||||
|
||||
typedef enum {
|
||||
|
||||
+7
-7
@@ -804,8 +804,8 @@ connection_ap_process_end_not_open(
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((tor_addr_family(&addr) == AF_INET && !conn->ipv4_traffic_ok) ||
|
||||
(tor_addr_family(&addr) == AF_INET6 && !conn->ipv6_traffic_ok)) {
|
||||
if ((tor_addr_family(&addr) == AF_INET && !conn->entry_cfg.ipv4_traffic) ||
|
||||
(tor_addr_family(&addr) == AF_INET6 && !conn->entry_cfg.ipv6_traffic)) {
|
||||
log_fn(LOG_PROTOCOL_WARN, LD_APP,
|
||||
"Got an EXITPOLICY failure on a connection with a "
|
||||
"mismatched family. Closing.");
|
||||
@@ -1156,11 +1156,11 @@ connection_ap_handshake_socks_got_resolved_cell(entry_connection_t *conn,
|
||||
addr_hostname = addr;
|
||||
}
|
||||
} else if (tor_addr_family(&addr->addr) == AF_INET) {
|
||||
if (!addr_ipv4 && conn->ipv4_traffic_ok) {
|
||||
if (!addr_ipv4 && conn->entry_cfg.ipv4_traffic) {
|
||||
addr_ipv4 = addr;
|
||||
}
|
||||
} else if (tor_addr_family(&addr->addr) == AF_INET6) {
|
||||
if (!addr_ipv6 && conn->ipv6_traffic_ok) {
|
||||
if (!addr_ipv6 && conn->entry_cfg.ipv6_traffic) {
|
||||
addr_ipv6 = addr;
|
||||
}
|
||||
}
|
||||
@@ -1181,7 +1181,7 @@ connection_ap_handshake_socks_got_resolved_cell(entry_connection_t *conn,
|
||||
return;
|
||||
}
|
||||
|
||||
if (conn->prefer_ipv6_traffic) {
|
||||
if (conn->entry_cfg.prefer_ipv6) {
|
||||
addr_best = addr_ipv6 ? addr_ipv6 : addr_ipv4;
|
||||
} else {
|
||||
addr_best = addr_ipv4 ? addr_ipv4 : addr_ipv6;
|
||||
@@ -1327,8 +1327,8 @@ connection_edge_process_relay_cell_not_open(
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((family == AF_INET && ! entry_conn->ipv4_traffic_ok) ||
|
||||
(family == AF_INET6 && ! entry_conn->ipv6_traffic_ok)) {
|
||||
if ((family == AF_INET && ! entry_conn->entry_cfg.ipv4_traffic) ||
|
||||
(family == AF_INET6 && ! entry_conn->entry_cfg.ipv6_traffic)) {
|
||||
log_fn(LOG_PROTOCOL_WARN, LD_APP,
|
||||
"Got a connected cell to %s with unsupported address family."
|
||||
" Closing.", fmt_addr(&addr));
|
||||
|
||||
@@ -137,9 +137,9 @@ test_relaycell_resolved(void *arg)
|
||||
/* Now put it in the right state. */
|
||||
ENTRY_TO_CONN(entryconn)->state = AP_CONN_STATE_RESOLVE_WAIT;
|
||||
entryconn->socks_request->command = SOCKS_COMMAND_RESOLVE;
|
||||
entryconn->ipv4_traffic_ok = 1;
|
||||
entryconn->ipv6_traffic_ok = 1;
|
||||
entryconn->prefer_ipv6_traffic = 0;
|
||||
entryconn->entry_cfg.ipv4_traffic = 1;
|
||||
entryconn->entry_cfg.ipv6_traffic = 1;
|
||||
entryconn->entry_cfg.prefer_ipv6 = 0;
|
||||
|
||||
/* We prefer ipv4, so we should get the first ipv4 answer */
|
||||
MOCK_RESET();
|
||||
@@ -159,7 +159,7 @@ test_relaycell_resolved(void *arg)
|
||||
ASSERT_RESOLVED_CALLED(RESOLVED_TYPE_IPV4, "\x12\x00\x00\x01", 512, -1);
|
||||
|
||||
/* now prefer ipv6, and get the first ipv6 answer */
|
||||
entryconn->prefer_ipv6_traffic = 1;
|
||||
entryconn->entry_cfg.prefer_ipv6 = 1;
|
||||
MOCK_RESET();
|
||||
r = connection_edge_process_resolved_cell(edgeconn, &cell, &rh);
|
||||
tt_int_op(r, OP_EQ, 0);
|
||||
@@ -182,7 +182,7 @@ test_relaycell_resolved(void *arg)
|
||||
/* But if we don't allow IPv4, we report nothing if the cell contains only
|
||||
* ipv4 */
|
||||
MOCK_RESET();
|
||||
entryconn->ipv4_traffic_ok = 0;
|
||||
entryconn->entry_cfg.ipv4_traffic = 0;
|
||||
r = connection_edge_process_resolved_cell(edgeconn, &cell, &rh);
|
||||
tt_int_op(r, OP_EQ, 0);
|
||||
ASSERT_MARK_CALLED(END_STREAM_REASON_DONE|
|
||||
@@ -191,7 +191,7 @@ test_relaycell_resolved(void *arg)
|
||||
|
||||
/* If we wanted hostnames, we report nothing, since we only had IPs. */
|
||||
MOCK_RESET();
|
||||
entryconn->ipv4_traffic_ok = 1;
|
||||
entryconn->entry_cfg.ipv4_traffic = 1;
|
||||
entryconn->socks_request->command = SOCKS_COMMAND_RESOLVE_PTR;
|
||||
r = connection_edge_process_resolved_cell(edgeconn, &cell, &rh);
|
||||
tt_int_op(r, OP_EQ, 0);
|
||||
|
||||
Reference in New Issue
Block a user