14 #define TOR_BRIDGES_PRIVATE
68 #define bridge_free(bridge) \
69 FREE_AND_NULL(bridge_info_t, bridge_free_, (bridge))
100 if (b->marked_for_removal) {
104 } SMARTLIST_FOREACH_END(b);
153 return (
const uint8_t *) bridge->
identity;
205 bridge->port == ap->port)
208 SMARTLIST_FOREACH_END(ap);
213 SMARTLIST_FOREACH_END(bridge);
232 bridge->port == port)
237 SMARTLIST_FOREACH_END(bridge);
256 bridge->port == port) {
264 } SMARTLIST_FOREACH_END(bridge);
316 smartlist_free(orports);
338 if (!tor_addr_port_is_valid(addr, port, 0))
344 return (bridge != NULL);
370 node->ri->ipv4_orport,
375 node->ri->ipv6_orport,
378 }
else if (node->rs) {
388 }
else if (node->md) {
418 if (bridge && ed_id &&
421 memcpy(&bridge->ed25519_identity, ed_id,
sizeof(*ed_id));
426 char *transport_info = NULL;
427 const char *transport_name =
430 tor_asprintf(&transport_info,
" (with transport '%s')", transport_name);
433 log_notice(
LD_DIR,
"Learned fingerprint %s for bridge %s%s.",
435 transport_info ? transport_info :
"");
438 (
const uint8_t *)digest);
461 const char *digest,
const char *transport_name)
472 if (bridge->marked_for_removal)
475 if (
tor_addr_eq(&bridge->addr, addr) && (bridge->port == port)) {
477 bridge->marked_for_removal = 1;
480 strcmp_opt(bridge->transport_name, transport_name)) {
482 char *bridge_description_new, *bridge_description_old;
486 transport_name ? transport_name :
"");
491 bridge->transport_name ? bridge->transport_name :
"");
493 log_warn(
LD_GENERAL,
"Tried to add bridge '%s', but we found a conflict"
494 " with the already registered bridge '%s'. We will discard"
495 " the old bridge and keep '%s'. If this is not what you"
496 " wanted, please change your configuration file accordingly.",
497 bridge_description_new, bridge_description_old,
498 bridge_description_new);
504 } SMARTLIST_FOREACH_END(bridge);
516 if (bridge->transport_name &&
517 !strcmp(bridge->transport_name, transport_name))
519 } SMARTLIST_FOREACH_END(bridge);
534 log_debug(
LD_GENERAL,
"Registering bridge at %s (transport: %s) (%s)",
536 bridge_line->transport_name ?
537 bridge_line->transport_name :
"no transport",
541 if (bridge_line->socks_args) {
544 tor_assert(smartlist_len(bridge_line->socks_args) > 0);
546 log_debug(
LD_GENERAL,
"Bridge uses %d SOCKS arguments:",
547 smartlist_len(bridge_line->socks_args));
549 log_debug(
LD_CONFIG,
"%d: %s", ++i, arg));
556 bridge_line->transport_name);
562 b->
port = bridge_line->port;
564 if (bridge_line->transport_name)
604 (bridge->port == port))
605 return bridge->transport_name;
606 } SMARTLIST_FOREACH_END(bridge);
629 (bridge->port == port)) {
630 if (bridge->transport_name) {
632 if (*transport == NULL) {
641 } SMARTLIST_FOREACH_END(bridge);
663 circuit_guard_state_t *guard_state = NULL;
672 log_warn(
LD_CONFIG,
"Can't use bridge at %s: there is no configured "
673 "transport called \"%s\".",
681 log_warn(
LD_APP,
"Not using bridge at %s: it is in ExcludeNodes.",
689 FIREWALL_OR_CONNECTION, 0, 0)) {
690 log_notice(
LD_CONFIG,
"Tried to fetch a descriptor directly from a "
691 "bridge, but that bridge is not reachable through our "
704 bridge_addrport.port = bridge->
port;
718 directory_request_free(req);
740 int ask_bridge_directly;
741 int can_use_bridge_authority;
758 log_warn(
LD_APP,
"Not using bridge at %s: it is in ExcludeNodes.",
767 &bridge->fetch_status,
773 ask_bridge_directly = !can_use_bridge_authority ||
775 log_debug(
LD_DIR,
"ask_bridge_directly=%d (%d, %d, %d)",
779 if (ask_bridge_directly &&
781 FIREWALL_OR_CONNECTION, 0,
783 log_notice(
LD_DIR,
"Bridge at '%s' isn't reachable by our "
784 "firewall policy. %s.",
786 can_use_bridge_authority ?
787 "Asking bridge authority instead" :
"Skipping");
788 if (can_use_bridge_authority)
789 ask_bridge_directly = 0;
794 if (ask_bridge_directly) {
802 memcpy(resource,
"fp/", 3);
806 log_info(
LD_DIR,
"Fetching bridge info '%s' from bridge authority.",
812 SMARTLIST_FOREACH_END(bridge);
834 bridge->
port == ri->ipv4_orport) ||
836 bridge->
port == ri->ipv6_orport)) {
841 ri->ipv4_orport = bridge->
port;
843 "Adjusted bridge routerinfo for '%s' to match configured "
848 ri->ipv6_orport = bridge->
port;
850 "Adjusted bridge routerinfo for '%s' to match configured "
854 log_err(
LD_BUG,
"Address family not supported: %d.",
876 "Bridge '%s' has both an IPv4 and an IPv6 address. "
877 "Will prefer using its %s address (%s) based on %s.",
882 "the configured Bridge address" :
883 "ClientPreferIPv6ORPort");
899 "Adjusted bridge routerstatus for '%s' to match "
900 "configured address %s.",
907 "Adjusted bridge routerstatus for '%s' to match configured"
911 log_err(
LD_BUG,
"Address family not supported: %d.",
933 "Bridge '%s' has both an IPv4 and an IPv6 address. "
934 "Will prefer using its %s address (%s) based on %s.",
939 "the configured Bridge address" :
940 "ClientPreferIPv6ORPort");
959 time_t now = time(NULL);
977 log_notice(
LD_DIR,
"Learned identity %s for bridge at %s:%d",
985 log_notice(
LD_DIR,
"new bridge descriptor '%s' (%s): %s", ri->
nickname,
1010 } SMARTLIST_FOREACH_END(b);
1025 dl = &(b->fetch_status);
1028 } SMARTLIST_FOREACH_END(b);
void tor_addr_copy(tor_addr_t *dest, const tor_addr_t *src)
const char * fmt_addrport(const tor_addr_t *addr, uint16_t port)
int tor_addr_compare(const tor_addr_t *addr1, const tor_addr_t *addr2, tor_addr_comparison_t how)
int tor_addr_is_null(const tor_addr_t *addr)
#define fmt_and_decorate_addr(a)
static sa_family_t tor_addr_family(const tor_addr_t *a)
#define tor_addr_eq(a, b)
const char * hex_str(const char *from, size_t fromlen)
void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen)
const char * find_transport_name_by_bridge_addrport(const tor_addr_t *addr, uint16_t port)
static void rewrite_node_address_for_bridge(const bridge_info_t *bridge, node_t *node)
void mark_bridge_list(void)
int routerinfo_is_a_configured_bridge(const routerinfo_t *ri)
STATIC void bridge_resolve_conflicts(const tor_addr_t *addr, uint16_t port, const char *digest, const char *transport_name)
int addr_is_a_configured_bridge(const tor_addr_t *addr, uint16_t port, const char *digest)
static void bridge_free_(bridge_info_t *bridge)
void learned_router_identity(const tor_addr_t *addr, uint16_t port, const char *digest, const ed25519_public_key_t *ed_id)
void sweep_bridge_list(void)
STATIC void clear_bridge_list(void)
int transport_is_needed(const char *transport_name)
void bridge_add_from_config(bridge_line_t *bridge_line)
static void launch_direct_bridge_descriptor_fetch(bridge_info_t *bridge)
const smartlist_t * get_socks_args_by_bridge_addrport(const tor_addr_t *addr, uint16_t port)
const char * bridget_get_transport_name(const bridge_info_t *bridge)
STATIC bridge_info_t * get_configured_bridge_by_orports_digest(const char *digest, const smartlist_t *orports)
int extend_info_is_a_configured_bridge(const extend_info_t *ei)
STATIC bridge_info_t * find_bridge_by_digest(const char *digest)
bridge_info_t * get_configured_bridge_by_exact_addr_port_digest(const tor_addr_t *addr, uint16_t port, const char *digest)
int node_is_a_configured_bridge(const node_t *node)
const tor_addr_port_t * bridge_get_addr_port(const bridge_info_t *bridge)
void fetch_bridge_descriptors(const or_options_t *options, time_t now)
smartlist_t * list_bridge_identities(void)
static bridge_info_t * get_configured_bridge_by_routerinfo(const routerinfo_t *ri)
const uint8_t * bridge_get_rsa_id_digest(const bridge_info_t *bridge)
download_status_t * get_bridge_dl_status_by_id(const char *digest)
void bridges_free_all(void)
int get_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port, const transport_t **transport)
bridge_info_t * get_configured_bridge_by_addr_port_digest(const tor_addr_t *addr, uint16_t port, const char *digest)
static int bridge_exists_with_addr_and_port(const tor_addr_t *addr, const uint16_t port, const char *digest)
static smartlist_t * bridge_list
const smartlist_t * bridge_list_get(void)
void retry_bridge_descriptor_fetch_directly(const char *digest)
static int bridge_has_digest(const bridge_info_t *bridge, const char *digest)
void learned_bridge_descriptor(routerinfo_t *ri, int from_cache)
bool bridge_has_invalid_transport(const bridge_info_t *bridge)
Header file for circuitbuild.c.
Header file for circuitbuild.c.
const or_options_t * get_options(void)
Header file for config.c.
connection_t * connection_get_by_type_addr_port_purpose(int type, const tor_addr_t *addr, uint16_t port, int purpose)
Header file for connection.c.
int ed25519_public_key_is_zero(const ed25519_public_key_t *pubkey)
const char * router_describe(const routerinfo_t *ri)
Header file for describe.c.
int tor_memeq(const void *a, const void *b, size_t sz)
void directory_request_set_resource(directory_request_t *req, const char *resource)
void directory_request_set_or_addr_port(directory_request_t *req, const tor_addr_port_t *p)
void directory_request_set_guard_state(directory_request_t *req, circuit_guard_state_t *state)
directory_request_t * directory_request_new(uint8_t dir_purpose)
void directory_request_set_router_purpose(directory_request_t *req, uint8_t router_purpose)
void directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose, const char *resource, int pds_flags, download_want_authority_t want_authority)
void directory_request_set_directory_id_digest(directory_request_t *req, const char *digest)
void directory_initiate_request(directory_request_t *request)
Header file for dirclient.c.
struct directory_request_t directory_request_t
Header file for directory.c.
#define DIR_PURPOSE_FETCH_SERVERDESC
int get_n_authorities(dirinfo_type_t type)
Header file for dirlist.c.
int download_status_is_ready(download_status_t *dls, time_t now)
time_t download_status_increment_attempt(download_status_t *dls, const char *item, time_t now)
void download_status_mark_impossible(download_status_t *dl)
void download_status_reset(download_status_t *dls)
Header file for dlstatus.c.
void entry_guard_learned_bridge_identity(const tor_addr_port_t *addrport, const uint8_t *rsa_id_digest)
int num_bridges_usable(int use_maybe_reachable)
circuit_guard_state_t * get_guard_state_for_bridge_desc_fetch(const char *digest)
Header file for circuitbuild.c.
Microdescriptor structure.
Node information structure.
void node_get_pref_orport(const node_t *node, tor_addr_port_t *ap_out)
node_t * node_get_mutable_by_id(const char *identity_digest)
void router_set_status(const char *digest, int up)
Header file for nodelist.c.
Master header file for Tor-specific functionality.
int reachable_addr_prefer_ipv6_orport(const or_options_t *options)
int reachable_addr_allows_addr(const tor_addr_t *addr, uint16_t port, firewall_connection_t fw_connection, int pref_only, int pref_ipv6)
Header file for policies.c.
int tor_asprintf(char **strp, const char *fmt,...)
smartlist_t * router_get_all_orports(const routerinfo_t *ri)
Header file for routerinfo.c.
Router descriptor structure.
#define ROUTER_PURPOSE_BRIDGE
void routerlist_retry_directory_downloads(time_t now)
Header file for routerlist.c.
int routerset_contains_bridge(const routerset_t *set, const bridge_info_t *bridge)
Header file for routerset.c.
Routerstatus (consensus entry) structure.
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
void smartlist_clear(smartlist_t *sl)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
#define SMARTLIST_DEL_CURRENT(sl, var)
tor_addr_port_t addrport_configured
char identity[DIGEST_LEN]
unsigned marked_for_removal
download_status_t fetch_status
download_schedule_increment_bitfield_t increment_on
download_schedule_bitfield_t schedule
tor_addr_port_t orports[EXTEND_INFO_MAX_ADDRS]
char identity_digest[DIGEST_LEN]
char identity[DIGEST_LEN]
unsigned int ipv6_preferred
int UpdateBridgesFromAuthority
int ClientPreferIPv6ORPort
struct routerset_t * ExcludeNodes
char nickname[MAX_NICKNAME_LEN+1]
char identity_digest[DIGEST_LEN]
#define MOCK_IMPL(rv, funcname, arglist)
int pt_proxies_configuration_pending(void)
transport_t * transport_get_by_name(const char *name)
Headers for transports.c.
#define IF_BUG_ONCE(cond)
int strcmp_opt(const char *s1, const char *s2)
int fast_mem_is_zero(const char *mem, size_t len)
int tor_digest_is_zero(const char *digest)