mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 05:03:43 +01:00
Remove the return value of node_get_prim_orport() and node_get_prim_dirport()
This commit is contained in:
parent
200fc8c640
commit
c2fa743806
6
changes/ticket23873
Normal file
6
changes/ticket23873
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
o Code simplification and refactoring:
|
||||||
|
- We remove the return value of node_get_prim_orport() and
|
||||||
|
node_get_prim_dirport(), and introduce node_get_prim_orport()
|
||||||
|
in node_ipv6_or_preferred() and node_ipv6_dir_preferred() in
|
||||||
|
order to check for a null address. Closes ticket 23873. Patch
|
||||||
|
by Neel Chauhan.
|
@ -2866,8 +2866,10 @@ extend_info_from_node(const node_t *node, int for_direct_connect)
|
|||||||
valid_addr = fascist_firewall_choose_address_node(node,
|
valid_addr = fascist_firewall_choose_address_node(node,
|
||||||
FIREWALL_OR_CONNECTION,
|
FIREWALL_OR_CONNECTION,
|
||||||
0, &ap);
|
0, &ap);
|
||||||
else
|
else {
|
||||||
valid_addr = !node_get_prim_orport(node, &ap);
|
node_get_prim_orport(node, &ap);
|
||||||
|
valid_addr = tor_addr_port_is_valid_ap(&ap, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (valid_addr)
|
if (valid_addr)
|
||||||
log_debug(LD_CIRC, "using %s for %s",
|
log_debug(LD_CIRC, "using %s for %s",
|
||||||
|
@ -1456,9 +1456,11 @@ node_ipv6_or_preferred(const node_t *node)
|
|||||||
/* XX/teor - node->ipv6_preferred is set from
|
/* XX/teor - node->ipv6_preferred is set from
|
||||||
* fascist_firewall_prefer_ipv6_orport() each time the consensus is loaded.
|
* fascist_firewall_prefer_ipv6_orport() each time the consensus is loaded.
|
||||||
*/
|
*/
|
||||||
|
node_get_prim_orport(node, &ipv4_addr);
|
||||||
if (!fascist_firewall_use_ipv6(options)) {
|
if (!fascist_firewall_use_ipv6(options)) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (node->ipv6_preferred || node_get_prim_orport(node, &ipv4_addr)) {
|
} else if (node->ipv6_preferred ||
|
||||||
|
!tor_addr_port_is_valid_ap(&ipv4_addr, 0)) {
|
||||||
return node_has_ipv6_orport(node);
|
return node_has_ipv6_orport(node);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -1469,14 +1471,12 @@ node_ipv6_or_preferred(const node_t *node)
|
|||||||
if (r && tor_addr_port_is_valid_ipv4h((r)->addr, (r)->port_field, 0)) { \
|
if (r && tor_addr_port_is_valid_ipv4h((r)->addr, (r)->port_field, 0)) { \
|
||||||
tor_addr_from_ipv4h(&(ap_out)->addr, (r)->addr); \
|
tor_addr_from_ipv4h(&(ap_out)->addr, (r)->addr); \
|
||||||
(ap_out)->port = (r)->port_field; \
|
(ap_out)->port = (r)->port_field; \
|
||||||
return 0; \
|
|
||||||
} \
|
} \
|
||||||
STMT_END
|
STMT_END
|
||||||
|
|
||||||
/** Copy the primary (IPv4) OR port (IP address and TCP port) for
|
/** Copy the primary (IPv4) OR port (IP address and TCP port) for <b>node</b>
|
||||||
* <b>node</b> into *<b>ap_out</b>. Return 0 if a valid address and
|
* into *<b>ap_out</b>. */
|
||||||
* port was copied, else return non-zero.*/
|
void
|
||||||
int
|
|
||||||
node_get_prim_orport(const node_t *node, tor_addr_port_t *ap_out)
|
node_get_prim_orport(const node_t *node, tor_addr_port_t *ap_out)
|
||||||
{
|
{
|
||||||
node_assert_ok(node);
|
node_assert_ok(node);
|
||||||
@ -1493,8 +1493,6 @@ node_get_prim_orport(const node_t *node, tor_addr_port_t *ap_out)
|
|||||||
RETURN_IPV4_AP(node->ri, or_port, ap_out);
|
RETURN_IPV4_AP(node->ri, or_port, ap_out);
|
||||||
RETURN_IPV4_AP(node->rs, or_port, ap_out);
|
RETURN_IPV4_AP(node->rs, or_port, ap_out);
|
||||||
/* Microdescriptors only have an IPv6 address */
|
/* Microdescriptors only have an IPv6 address */
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Copy the preferred OR port (IP address and TCP port) for
|
/** Copy the preferred OR port (IP address and TCP port) for
|
||||||
@ -1566,19 +1564,19 @@ node_ipv6_dir_preferred(const node_t *node)
|
|||||||
* so we can't use it to determine DirPort IPv6 preference.
|
* so we can't use it to determine DirPort IPv6 preference.
|
||||||
* This means that bridge clients will use IPv4 DirPorts by default.
|
* This means that bridge clients will use IPv4 DirPorts by default.
|
||||||
*/
|
*/
|
||||||
|
node_get_prim_dirport(node, &ipv4_addr);
|
||||||
if (!fascist_firewall_use_ipv6(options)) {
|
if (!fascist_firewall_use_ipv6(options)) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (node_get_prim_dirport(node, &ipv4_addr)
|
} else if (!tor_addr_port_is_valid_ap(&ipv4_addr, 0)
|
||||||
|| fascist_firewall_prefer_ipv6_dirport(get_options())) {
|
|| fascist_firewall_prefer_ipv6_dirport(get_options())) {
|
||||||
return node_has_ipv6_dirport(node);
|
return node_has_ipv6_dirport(node);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Copy the primary (IPv4) Dir port (IP address and TCP port) for
|
/** Copy the primary (IPv4) Dir port (IP address and TCP port) for <b>node</b>
|
||||||
* <b>node</b> into *<b>ap_out</b>. Return 0 if a valid address and
|
* into *<b>ap_out</b>. */
|
||||||
* port was copied, else return non-zero.*/
|
void
|
||||||
int
|
|
||||||
node_get_prim_dirport(const node_t *node, tor_addr_port_t *ap_out)
|
node_get_prim_dirport(const node_t *node, tor_addr_port_t *ap_out)
|
||||||
{
|
{
|
||||||
node_assert_ok(node);
|
node_assert_ok(node);
|
||||||
@ -1590,8 +1588,6 @@ node_get_prim_dirport(const node_t *node, tor_addr_port_t *ap_out)
|
|||||||
RETURN_IPV4_AP(node->ri, dir_port, ap_out);
|
RETURN_IPV4_AP(node->ri, dir_port, ap_out);
|
||||||
RETURN_IPV4_AP(node->rs, dir_port, ap_out);
|
RETURN_IPV4_AP(node->rs, dir_port, ap_out);
|
||||||
/* Microdescriptors only have an IPv6 address */
|
/* Microdescriptors only have an IPv6 address */
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef RETURN_IPV4_AP
|
#undef RETURN_IPV4_AP
|
||||||
|
@ -77,11 +77,11 @@ int node_has_ipv6_dirport(const node_t *node);
|
|||||||
/* Deprecated - use node_ipv6_or_preferred or node_ipv6_dir_preferred */
|
/* Deprecated - use node_ipv6_or_preferred or node_ipv6_dir_preferred */
|
||||||
#define node_ipv6_preferred(node) node_ipv6_or_preferred(node)
|
#define node_ipv6_preferred(node) node_ipv6_or_preferred(node)
|
||||||
int node_ipv6_or_preferred(const node_t *node);
|
int node_ipv6_or_preferred(const node_t *node);
|
||||||
int node_get_prim_orport(const node_t *node, tor_addr_port_t *ap_out);
|
void node_get_prim_orport(const node_t *node, tor_addr_port_t *ap_out);
|
||||||
void node_get_pref_orport(const node_t *node, tor_addr_port_t *ap_out);
|
void node_get_pref_orport(const node_t *node, tor_addr_port_t *ap_out);
|
||||||
void node_get_pref_ipv6_orport(const node_t *node, tor_addr_port_t *ap_out);
|
void node_get_pref_ipv6_orport(const node_t *node, tor_addr_port_t *ap_out);
|
||||||
int node_ipv6_dir_preferred(const node_t *node);
|
int node_ipv6_dir_preferred(const node_t *node);
|
||||||
int node_get_prim_dirport(const node_t *node, tor_addr_port_t *ap_out);
|
void node_get_prim_dirport(const node_t *node, tor_addr_port_t *ap_out);
|
||||||
void node_get_pref_dirport(const node_t *node, tor_addr_port_t *ap_out);
|
void node_get_pref_dirport(const node_t *node, tor_addr_port_t *ap_out);
|
||||||
void node_get_pref_ipv6_dirport(const node_t *node, tor_addr_port_t *ap_out);
|
void node_get_pref_ipv6_dirport(const node_t *node, tor_addr_port_t *ap_out);
|
||||||
int node_has_curve25519_onion_key(const node_t *node);
|
int node_has_curve25519_onion_key(const node_t *node);
|
||||||
|
Loading…
Reference in New Issue
Block a user