@@ -287,65 +287,98 @@ routerinfo_is_a_configured_bridge(const routerinfo_t *ri)
/* *
* Return 1 iff <b>bridge_list</b> contains entry matching
* given; IPv4 address in host byte order (<b>ipv4_addr</b>
* and <b>port</b>. Otherwise, return 0.
* and <b>port</b> (and no identity digest) OR it contains an
* entry whose identity matches <b>digest</b>. Otherwise,
* return 0.
*/
static int
bridge_exists_with_ipv4h_addr_and_port (const uint32_t ipv4_addr,
const uint16_t port)
const uint16_t port,
const char *digest)
{
tor_addr_t node_ipv4;
if (tor_addr_port_is_valid_ipv4h (ipv4_addr, port, 0 )) {
tor_addr_from_ipv4h (&node_ipv4, ipv4_addr);
return addr_is_a_configured_bridge (&node_ipv4, port, NULL );
bridge_info_t *bridge =
get_configured_bridge_by_addr_port_digest (&node_ipv4,
port,
digest);
return (bridge != NULL );
}
return 0 ;
}
/* *
* Return 1 iff <b>bridge_list</b> contains entry matching given
* <b>ipv6_addr</b> and <b>port</b>. Otherwise, return 0.
* <b>ipv6_addr</b> and <b>port</b> (and no identity digest) OR
* it contains an entry whose identity matches <b>digest</b>.
* Otherwise, return 0.
*/
static int
bridge_exists_with_ipv6_addr_and_port (const tor_addr_t *ipv6_addr,
const uint16_t port)
const uint16_t port,
const char *digest)
{
if (!tor_addr_port_is_valid (ipv6_addr, port, 0 ))
return 0 ;
return addr_is_a_configured_bridge (ipv6_addr, port, NULL );
bridge_info_t *bridge =
get_configured_bridge_by_addr_port_digest (ipv6_addr,
port,
digest);
return (bridge != NULL );
}
/* * Return 1 if <b>node</b> is one of our configured bridges, else 0. */
/* * Return 1 if <b>node</b> is one of our configured bridges, else 0.
* More specifically, return 1 iff: a bridge_info_t object exists in
* <b>bridge_list</b> such that: 1) It's identity is equal to node
* identity OR 2) It's identity digest is zero, but it matches
* address and port of any ORPort in the node.
*/
int
node_is_a_configured_bridge (const node_t *node)
{
/* First, let's try searching for a bridge with matching identity. */
if (!tor_digest_is_zero (node->identity )) {
return find_bridge_by_digest (node->identity ) != NULL ;
}
if (BUG (tor_digest_is_zero (node->identity )))
return 0 ;
if (find_bridge_by_digest (node->identity ) != NULL )
return 1 ;
/* At this point, we have established that no bridge exists with
* matching identity digest. However, we still pass it into
* bridge_exists_* functions because we want further code to
* check for absence of identity digest in a bridge.
*/
if (node->ri ) {
if (bridge_exists_with_ipv4h_addr_and_port (node->ri ->addr ,
node->ri ->or_port ))
node->ri ->or_port ,
node->identity ))
return 1 ;
if (bridge_exists_with_ipv6_addr_and_port (&node->ri ->ipv6_addr ,
node->ri ->ipv6_orport ))
node->ri ->ipv6_orport ,
node->identity ))
return 1 ;
} else if (node->rs ) {
if (bridge_exists_with_ipv4h_addr_and_port (node->rs ->addr ,
node->rs ->or_port ))
node->rs ->or_port ,
node->identity ))
return 1 ;
if (bridge_exists_with_ipv6_addr_and_port (&node->rs ->ipv6_addr ,
node->rs ->ipv6_orport ))
node->rs ->ipv6_orport ,
node->identity ))
return 1 ;
} else if (node->md ) {
if (bridge_exists_with_ipv6_addr_and_port (&node->md ->ipv6_addr ,
node->md ->ipv6_orport ))
node->md ->ipv6_orport ,
node->identity ))
return 1 ;
}