mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
Minor changes to bug5603
* Minor stylistic changes to comments and doxygen * Use strcmp_opt; it already exists. * Tighten bridge_has_digest implementation a little.
This commit is contained in:
parent
1e95a4a1f6
commit
64167e1772
@ -4912,46 +4912,28 @@ learned_router_identity(const tor_addr_t *addr, uint16_t port,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if <b>bridge</b> has the same identity digest as
|
/** Return true if <b>bridge</b> has the same identity digest as
|
||||||
* <b>digest</b>. <b>digest</b> is optional in which case it matches
|
* <b>digest</b>. If <b>digest</b> is NULL, it matches
|
||||||
* bridges without identity digests. */
|
* bridges with unspecified identity digests. */
|
||||||
static int
|
static int
|
||||||
bridge_has_digest(const bridge_info_t *bridge, const char *digest)
|
bridge_has_digest(const bridge_info_t *bridge, const char *digest)
|
||||||
{
|
{
|
||||||
if (!digest && tor_digest_is_zero(bridge->identity))
|
if (digest)
|
||||||
return 1;
|
return tor_memeq(digest, bridge->identity, DIGEST_LEN);
|
||||||
if (digest && tor_memeq(digest, bridge->identity, DIGEST_LEN))
|
else
|
||||||
return 1;
|
return tor_digest_is_zero(bridge->identity);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if <b>bridge</b> uses the same pluggable transport as
|
/** We are about to add a new bridge at <b>addr</b>:<b>port</b>, with optional
|
||||||
* <b>transport_name</b>. <b>transport_name</b> is optional in which
|
* <b>digest</b> and <b>transport_name</b>. Mark for removal any previously
|
||||||
* case it matches bridges without pluggable transports. */
|
* existing bridge with the same address and port, and warn the user as
|
||||||
static int
|
* appropriate.
|
||||||
bridge_has_transport_name(const bridge_info_t *bridge,
|
|
||||||
const char *transport_name)
|
|
||||||
{
|
|
||||||
if (!transport_name && !bridge->transport_name)
|
|
||||||
return 1;
|
|
||||||
if (transport_name && !strcmp(transport_name, bridge->transport_name))
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** We want to add a new bridge at <b>addr</b>:<b>port</b>, with
|
|
||||||
* optional <b>digest</b> and <b>transport_name</b>. See if this
|
|
||||||
* generates any conflicts with already registered bridges, try to
|
|
||||||
* resolve them and warn the user.
|
|
||||||
*
|
|
||||||
* This function might end up marking already registered bridges to
|
|
||||||
* be deleted.
|
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
bridge_resolve_conflicts(const tor_addr_t *addr, uint16_t port,
|
bridge_resolve_conflicts(const tor_addr_t *addr, uint16_t port,
|
||||||
const char *digest, const char *transport_name)
|
const char *digest, const char *transport_name)
|
||||||
{
|
{
|
||||||
/** Iterate the already-registered bridge list:
|
/* Iterate the already-registered bridge list:
|
||||||
|
|
||||||
If you find a bridge with the same adress and port, mark it for
|
If you find a bridge with the same adress and port, mark it for
|
||||||
removal. It doesn't make sense to have two active bridges with
|
removal. It doesn't make sense to have two active bridges with
|
||||||
@ -4968,7 +4950,7 @@ bridge_resolve_conflicts(const tor_addr_t *addr, uint16_t port,
|
|||||||
bridge->marked_for_removal = 1;
|
bridge->marked_for_removal = 1;
|
||||||
|
|
||||||
if (!bridge_has_digest(bridge, digest) ||
|
if (!bridge_has_digest(bridge, digest) ||
|
||||||
!bridge_has_transport_name(bridge, transport_name)) {
|
strcmp_opt(bridge->transport_name, transport_name)) {
|
||||||
/* warn the user */
|
/* warn the user */
|
||||||
char *bridge_description_new, *bridge_description_old;
|
char *bridge_description_new, *bridge_description_old;
|
||||||
tor_asprintf(&bridge_description_new, "%s:%u:%s:%s",
|
tor_asprintf(&bridge_description_new, "%s:%u:%s:%s",
|
||||||
|
Loading…
Reference in New Issue
Block a user