80 } SMARTLIST_FOREACH_END(p);
94 if (ent->is_authority) {
97 } SMARTLIST_FOREACH_END(ent);
128 router_get_fallback_dir_servers_mutable(
void)
137 router_get_trusted_dir_servers(
void)
143 router_get_fallback_dir_servers(
void)
145 return router_get_fallback_dir_servers_mutable();
247 } SMARTLIST_FOREACH_END(dir);
264 return (!type) || ((type & ent->type) != 0);
287 if (type != NO_DIRINFO && (type & ent->type) == 0) {
291 if ((family == AF_INET &&
tor_addr_eq(addr, &ent->ipv4_addr)) ||
292 (family == AF_INET6 &&
tor_addr_eq(addr, &ent->ipv6_addr))) {
295 } SMARTLIST_FOREACH_END(ent);
339 const char *nickname,
341 const char *hostname,
342 uint16_t ipv4_dirport, uint16_t ipv4_orport,
344 const char *digest,
const char *v3_auth_digest,
349 char *hostname_ = NULL;
363 hostname_ = tor_strdup(hostname);
366 ent->nickname = nickname ? tor_strdup(nickname) : NULL;
374 ent->weight = weight;
375 if (addrport_ipv6 && tor_addr_port_is_valid_ap(addrport_ipv6, 0)) {
377 log_warn(
LD_BUG,
"Hey, I got a non-ipv6 addr as addrport_ipv6.");
392 tor_asprintf(&ent->description,
"directory server \"%s\" at %s:%" PRIu16,
393 nickname, hostname_, ipv4_dirport);
395 tor_asprintf(&ent->description,
"directory server at %s:%" PRIu16,
396 hostname_, ipv4_dirport);
420 uint16_t ipv4_dirport, uint16_t ipv4_orport,
422 const char *digest,
const char *v3_auth_digest,
433 "Couldn't find a suitable address when adding ourself as a "
434 "trusted directory server.");
445 "Unable to lookup address for directory server at '%s'",
449 hostname = tor_strdup(address);
453 ipv4_dirport, ipv4_orport,
456 v3_auth_digest, type, weight);
460 memset(&p, 0,
sizeof(p));
462 p.port = ipv4_dirport;
508 tor_assert_nonfatal(addr_family == AF_INET || addr_family == AF_INET6);
513 if (port->usage == usage &&
515 return &port->dirport;
517 } SMARTLIST_FOREACH_END(port);
554 uint16_t ipv4_dirport, uint16_t ipv4_orport,
556 const char *id_digest,
double weight)
558 return dir_server_new(0, NULL, ipv4_addr, NULL, ipv4_dirport, ipv4_orport,
559 addrport_ipv6, id_digest, NULL, ALL_DIRINFO, weight);
578 #define dir_server_free(val) \
579 FREE_AND_NULL(dir_server_t, dir_server_free_, (val))
604 dir_server_free(ent));
618 dirlist_free_all(
void)
void tor_addr_copy(tor_addr_t *dest, const tor_addr_t *src)
void tor_addr_make_unspec(tor_addr_t *a)
char * tor_addr_to_str_dup(const tor_addr_t *addr)
int tor_addr_is_null(const tor_addr_t *addr)
void tor_addr_port_copy(tor_addr_port_t *dest, const tor_addr_port_t *source)
static sa_family_t tor_addr_family(const tor_addr_t *a)
#define tor_addr_eq(a, b)
int authdir_mode(const or_options_t *options)
Header file for directory authority mode.
const or_options_t * get_options(void)
Header file for config.c.
int control_event_networkstatus_changed_single(const routerstatus_t *rs)
Header file for control_events.c.
int tor_memeq(const void *a, const void *b, size_t sz)
Trusted/fallback directory server structure.
Header file for directory.c.
#define DIR_PURPOSE_FETCH_EXTRAINFO
#define DIR_PURPOSE_FETCH_CERTIFICATE
#define DIR_PURPOSE_UPLOAD_HSDESC
#define DIR_PURPOSE_FETCH_MICRODESC
#define DIR_PURPOSE_UPLOAD_VOTE
#define DIR_PURPOSE_FETCH_DETACHED_SIGNATURES
#define DIR_PURPOSE_FETCH_CONSENSUS
#define DIR_PURPOSE_SERVER
#define DIR_PURPOSE_FETCH_SERVERDESC
#define DIR_PURPOSE_UPLOAD_SIGNATURES
#define DIR_PURPOSE_FETCH_STATUS_VOTE
#define DIR_PURPOSE_HAS_FETCHED_HSDESC
#define DIR_PURPOSE_UPLOAD_DIR
#define DIR_PURPOSE_FETCH_HSDESC
bool router_addr_is_trusted_dir_type(const tor_addr_t *addr, dirinfo_type_t type)
void trusted_dir_server_add_dirport(dir_server_t *ds, auth_dirport_usage_t usage, const tor_addr_port_t *dirport)
void mark_all_dirservers_up(smartlist_t *server_list)
int get_n_authorities(dirinfo_type_t type)
dir_server_t * trusteddirserver_get_by_v3_auth_digest(const char *digest)
void router_reset_status_download_failures(void)
dir_server_t * router_get_trusteddirserver_by_digest(const char *digest)
static smartlist_t * trusted_dir_servers
const tor_addr_port_t * trusted_dir_server_get_dirport_exact(const dir_server_t *ds, auth_dirport_usage_t usage, int addr_family)
dir_server_t * fallback_dir_server_new(const tor_addr_t *ipv4_addr, uint16_t ipv4_dirport, uint16_t ipv4_orport, const tor_addr_port_t *addrport_ipv6, const char *id_digest, double weight)
int router_digest_is_trusted_dir_type(const char *digest, dirinfo_type_t type)
void clear_dir_servers(void)
auth_dirport_usage_t auth_dirport_usage_for_purpose(int purpose)
const tor_addr_port_t * trusted_dir_server_get_dirport(const dir_server_t *ds, auth_dirport_usage_t usage, int addr_family)
void dir_server_add(dir_server_t *ent)
dir_server_t * trusted_dir_server_new(const char *nickname, const char *address, uint16_t ipv4_dirport, uint16_t ipv4_orport, const tor_addr_port_t *ipv6_addrport, const char *digest, const char *v3_auth_digest, dirinfo_type_t type, double weight)
int router_digest_is_fallback_dir(const char *digest)
void dirlist_add_trusted_dir_addresses(void)
dir_server_t * router_get_fallback_dirserver_by_digest(const char *digest)
static smartlist_t * fallback_dir_servers
smartlist_t * router_get_trusted_dir_servers_mutable(void)
static void dir_server_free_(dir_server_t *ds)
static void add_trusted_dir_to_nodelist_addr_set(const dir_server_t *dir)
static dir_server_t * dir_server_new(int is_authority, const char *nickname, const tor_addr_t *ipv4_addr, const char *hostname, uint16_t ipv4_dirport, uint16_t ipv4_orport, const tor_addr_port_t *addrport_ipv6, const char *digest, const char *v3_auth_digest, dirinfo_type_t type, double weight)
Header file for dirlist.c.
routerstatus_t * router_get_mutable_consensus_status_by_id(const char *digest)
Header file for networkstatus.c.
Node information structure.
node_t * node_get_mutable_by_id(const char *identity_digest)
void router_dir_info_changed(void)
void nodelist_add_addr_to_address_set(const tor_addr_t *addr, uint16_t or_port, uint16_t dir_port)
Header file for nodelist.c.
Master header file for Tor-specific functionality.
Header file for policies.c.
int tor_asprintf(char **strp, const char *fmt,...)
int tor_addr_lookup(const char *name, uint16_t family, tor_addr_t *addr)
bool find_my_address(const or_options_t *options, int family, int warn_severity, tor_addr_t *addr_out, resolved_addr_method_t *method_out, char **hostname_out)
Attempt to find our IP address that can be used as our external reachable address.
Header file for resolve_addr.c.
int router_digest_is_me(const char *digest)
Header file for router.c.
Header file for routerlist.c.
Header file for routerset.c.
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)
auth_dirport_usage_t usage
routerstatus_t fake_status
struct smartlist_t * auth_dirports
unsigned int is_authority
char v3_identity_digest[DIGEST_LEN]
char identity_digest[DIGEST_LEN]
char nickname[MAX_NICKNAME_LEN+1]
unsigned int is_authority
#define MOCK_IMPL(rv, funcname, arglist)
#define tor_assert_nonfatal_unreached()