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);
150 static bool warned_once =
false;
163 log_warn(
LD_CIRC,
"Only one bridge (transport: '%s') is configured. "
164 "You should have at least two for conflux, "
165 "for any transport that is not 'snowflake'.",
188 return (
const uint8_t *) bridge->
identity;
240 bridge->port == ap->port)
243 SMARTLIST_FOREACH_END(ap);
248 SMARTLIST_FOREACH_END(bridge);
267 bridge->port == port)
272 SMARTLIST_FOREACH_END(bridge);
291 bridge->port == port) {
299 } SMARTLIST_FOREACH_END(bridge);
353 smartlist_free(orports);
375 if (!tor_addr_port_is_valid(addr, port, 0))
381 return (bridge != NULL);
407 node->ri->ipv4_orport,
412 node->ri->ipv6_orport,
415 }
else if (node->rs) {
425 }
else if (node->md) {
455 if (bridge && ed_id &&
458 memcpy(&bridge->ed25519_identity, ed_id,
sizeof(*ed_id));
463 char *transport_info = NULL;
464 const char *transport_name =
467 tor_asprintf(&transport_info,
" (with transport '%s')", transport_name);
470 log_notice(
LD_DIR,
"Learned fingerprint %s for bridge %s%s.",
472 transport_info ? transport_info :
"");
475 (
const uint8_t *)digest);
498 const char *digest,
const char *transport_name)
509 if (bridge->marked_for_removal)
512 if (
tor_addr_eq(&bridge->addr, addr) && (bridge->port == port)) {
514 bridge->marked_for_removal = 1;
517 strcmp_opt(bridge->transport_name, transport_name)) {
519 char *bridge_description_new, *bridge_description_old;
523 transport_name ? transport_name :
"");
528 bridge->transport_name ? bridge->transport_name :
"");
530 log_warn(
LD_GENERAL,
"Tried to add bridge '%s', but we found a conflict"
531 " with the already registered bridge '%s'. We will discard"
532 " the old bridge and keep '%s'. If this is not what you"
533 " wanted, please change your configuration file accordingly.",
534 bridge_description_new, bridge_description_old,
535 bridge_description_new);
541 } SMARTLIST_FOREACH_END(bridge);
553 if (bridge->transport_name &&
554 !strcmp(bridge->transport_name, transport_name))
556 } SMARTLIST_FOREACH_END(bridge);
571 log_debug(
LD_GENERAL,
"Registering bridge at %s (transport: %s) (%s)",
573 bridge_line->transport_name ?
574 bridge_line->transport_name :
"no transport",
578 if (bridge_line->socks_args) {
581 tor_assert(smartlist_len(bridge_line->socks_args) > 0);
583 log_debug(
LD_GENERAL,
"Bridge uses %d SOCKS arguments:",
584 smartlist_len(bridge_line->socks_args));
586 log_debug(
LD_CONFIG,
"%d: %s", ++i, arg));
593 bridge_line->transport_name);
599 b->
port = bridge_line->port;
601 if (bridge_line->transport_name)
641 (bridge->port == port))
642 return bridge->transport_name;
643 } SMARTLIST_FOREACH_END(bridge);
666 (bridge->port == port)) {
667 if (bridge->transport_name) {
669 if (*transport == NULL) {
678 } SMARTLIST_FOREACH_END(bridge);
700 circuit_guard_state_t *guard_state = NULL;
709 log_warn(
LD_CONFIG,
"Can't use bridge at %s: there is no configured "
710 "transport called \"%s\".",
718 log_warn(
LD_APP,
"Not using bridge at %s: it is in ExcludeNodes.",
726 FIREWALL_OR_CONNECTION, 0, 0)) {
727 log_notice(
LD_CONFIG,
"Tried to fetch a descriptor directly from a "
728 "bridge, but that bridge is not reachable through our "
741 bridge_addrport.port = bridge->
port;
755 directory_request_free(req);
777 int ask_bridge_directly;
778 int can_use_bridge_authority;
795 log_warn(
LD_APP,
"Not using bridge at %s: it is in ExcludeNodes.",
804 &bridge->fetch_status,
810 ask_bridge_directly = !can_use_bridge_authority ||
812 log_debug(
LD_DIR,
"ask_bridge_directly=%d (%d, %d, %d)",
816 if (ask_bridge_directly &&
818 FIREWALL_OR_CONNECTION, 0,
820 log_notice(
LD_DIR,
"Bridge at '%s' isn't reachable by our "
821 "firewall policy. %s.",
823 can_use_bridge_authority ?
824 "Asking bridge authority instead" :
"Skipping");
825 if (can_use_bridge_authority)
826 ask_bridge_directly = 0;
831 if (ask_bridge_directly) {
839 memcpy(resource,
"fp/", 3);
843 log_info(
LD_DIR,
"Fetching bridge info '%s' from bridge authority.",
849 SMARTLIST_FOREACH_END(bridge);
871 bridge->
port == ri->ipv4_orport) ||
873 bridge->
port == ri->ipv6_orport)) {
878 ri->ipv4_orport = bridge->
port;
880 "Adjusted bridge routerinfo for '%s' to match configured "
885 ri->ipv6_orport = bridge->
port;
887 "Adjusted bridge routerinfo for '%s' to match configured "
891 log_err(
LD_BUG,
"Address family not supported: %d.",
913 "Bridge '%s' has both an IPv4 and an IPv6 address. "
914 "Will prefer using its %s address (%s) based on %s.",
919 "the configured Bridge address" :
920 "ClientPreferIPv6ORPort");
936 "Adjusted bridge routerstatus for '%s' to match "
937 "configured address %s.",
944 "Adjusted bridge routerstatus for '%s' to match configured"
948 log_err(
LD_BUG,
"Address family not supported: %d.",
970 "Bridge '%s' has both an IPv4 and an IPv6 address. "
971 "Will prefer using its %s address (%s) based on %s.",
976 "the configured Bridge address" :
977 "ClientPreferIPv6ORPort");
1004 time_t now = time(NULL);
1024 log_notice(
LD_DIR,
"Learned identity %s for bridge at %s:%d",
1027 (
int) bridge->
port);
1033 log_notice(
LD_DIR,
"new bridge descriptor '%s' (%s): %s",
1059 } SMARTLIST_FOREACH_END(b);
1074 dl = &(b->fetch_status);
1077 } SMARTLIST_FOREACH_END(b);
void tor_addr_copy(tor_addr_t *dest, const tor_addr_t *src)
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)
const char * fmt_addrport(const tor_addr_t *addr, uint16_t port)
#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)
download_status_t * get_bridge_dl_status_by_id(const char *digest)
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 bridge_info_t * get_configured_bridge_by_orports_digest(const char *digest, const smartlist_t *orports)
STATIC void clear_bridge_list(void)
const uint8_t * bridge_get_rsa_id_digest(const bridge_info_t *bridge)
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)
smartlist_t * list_bridge_identities(void)
int extend_info_is_a_configured_bridge(const extend_info_t *ei)
int node_is_a_configured_bridge(const node_t *node)
STATIC bridge_info_t * find_bridge_by_digest(const char *digest)
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)
const char * find_transport_name_by_bridge_addrport(const tor_addr_t *addr, uint16_t port)
const smartlist_t * bridge_list_get(void)
static bridge_info_t * get_configured_bridge_by_routerinfo(const routerinfo_t *ri)
void bridges_free_all(void)
int get_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port, const transport_t **transport)
bool conflux_can_exclude_used_bridges(void)
void learned_bridge_descriptor(routerinfo_t *ri, int from_cache, int desc_is_new)
static int bridge_exists_with_addr_and_port(const tor_addr_t *addr, const uint16_t port, 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)
static smartlist_t * bridge_list
const char * bridget_get_transport_name(const bridge_info_t *bridge)
const smartlist_t * get_socks_args_by_bridge_addrport(const tor_addr_t *addr, uint16_t port)
void retry_bridge_descriptor_fetch_directly(const char *digest)
static int bridge_has_digest(const bridge_info_t *bridge, const char *digest)
bridge_info_t * get_configured_bridge_by_addr_port_digest(const tor_addr_t *addr, uint16_t port, const char *digest)
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 curve25519_public_key_is_ok(const curve25519_public_key_t *key)
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)
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)
directory_request_t * directory_request_new(uint8_t dir_purpose)
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]
curve25519_public_key_t curve25519_onion_key
char identity[DIGEST_LEN]
unsigned int ipv6_preferred
int UpdateBridgesFromAuthority
int ClientPreferIPv6ORPort
struct routerset_t * ExcludeNodes
int TestingBridgeDownloadInitialDelay
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)