37 #define DECLARE_EVENT(name, roles, flags) \
38 static periodic_event_item_t name ## _event = \
39 PERIODIC_EVENT(name, \
40 PERIODIC_EVENT_ROLE_##roles, \
44 #define FL(name) (PERIODIC_EVENT_FLAG_##name)
53 #define RETRY_DNS_INTERVAL (10*60)
56 return RETRY_DNS_INTERVAL;
59 DECLARE_EVENT(retry_dns, ROUTER, 0);
61 static int dns_honesty_first_time = 1;
76 return PERIODIC_EVENT_NO_UPDATE;
78 if (dns_honesty_first_time) {
80 dns_honesty_first_time = 0;
88 DECLARE_EVENT(check_dns_honesty, RELAY, FL(NEED_NET));
95 rotate_onion_key_callback(time_t now,
const or_options_t *options)
100 if (rotation_time > now) {
108 log_info(
LD_CONFIG,
"Couldn't rebuild router descriptor");
114 return PERIODIC_EVENT_NO_UPDATE;
127 #define CHECK_DESCRIPTOR_INTERVAL (60)
140 return CHECK_DESCRIPTOR_INTERVAL;
143 DECLARE_EVENT(check_descriptor, ROUTER, FL(NEED_NET));
145 static int dirport_reachability_count = 0;
159 #define EARLY_CHECK_REACHABILITY_INTERVAL (60)
168 return EARLY_CHECK_REACHABILITY_INTERVAL;
174 static int first_time = 1;
175 if (!first_time && me &&
181 #define BANDWIDTH_RECHECK_INTERVAL (12*60*60)
182 return BANDWIDTH_RECHECK_INTERVAL;
185 return CHECK_DESCRIPTOR_INTERVAL;
188 DECLARE_EVENT(check_for_reachability_bw, ROUTER, FL(NEED_NET));
211 if (me && !(v4_ok && v6_ok)) {
216 if (address4 || address6) {
217 char *where4=NULL, *where6=NULL;
219 tor_asprintf(&where4,
"%s:%d", address4, me->ipv4_orport);
221 tor_asprintf(&where6,
"[%s]:%d", address6, me->ipv6_orport);
222 const char *opt_and = (!v4_ok && !v6_ok) ?
"and" :
"";
228 static ratelim_t rlim = RATELIM_INIT(3600);
230 "Auto-discovered IPv6 address %s has not been found "
231 "reachable. However, IPv4 address is reachable. "
232 "Publishing server descriptor without IPv6 address.",
233 where6 ? where6 :
"");
236 "IPv6 is not but was "
237 "auto-discovered",
true);
240 "Your server has not managed to confirm reachability for "
241 "its ORPort(s) at %s%s%s. Relays do not publish "
242 "descriptors until their ORPort and DirPort are "
243 "reachable. Please check your firewalls, ports, address, "
244 "/etc/hosts file, etc.",
253 "REACHABILITY_FAILED ORADDRESS=%s:%d",
254 address4, me->ipv4_orport);
258 "REACHABILITY_FAILED ORADDRESS=[%s]:%d",
259 address6, me->ipv6_orport);
270 DECLARE_EVENT(reachability_warnings, ROUTER, FL(NEED_NET));
276 check_ed_keys_callback(time_t now,
const or_options_t *options)
281 if (new_signing_key < 0 ||
283 log_err(
LD_OR,
"Unable to update Ed25519 keys! Exiting.");
289 return PERIODIC_EVENT_NO_UPDATE;
292 DECLARE_EVENT(check_ed_keys, ROUTER, 0);
300 check_onion_keys_expiry_time_callback(time_t now,
const or_options_t *options)
305 if (expiry_time > now) {
309 log_info(
LD_GENERAL,
"Expiring old onion keys.");
315 return PERIODIC_EVENT_NO_UPDATE;
318 DECLARE_EVENT(check_onion_keys_expiry_time, ROUTER, 0);
321 relay_register_periodic_events(
void)
332 dns_honesty_first_time = 1;
333 dirport_reachability_count = 0;
char * tor_addr_to_str_dup(const tor_addr_t *addr)
void reset_bandwidth_test(void)
Header file for circuituse.c.
int control_event_server_status(int severity, const char *format,...)
Header file for control_events.c.
void cpuworkers_rotate_keyinfo(void)
Header file for cpuworker.c.
Common functions for using (pseudo-)random number generators.
int crypto_rand_int_range(unsigned int min, unsigned int max)
int crypto_rand_int(unsigned int max)
int has_dns_init_failed(void)
void dns_launch_correctness_checks(void)
#define log_fn_ratelim(ratelim, severity, domain, args,...)
int have_completed_a_circuit(void)
void tor_shutdown_event_loop_and_exit(int exitcode)
Header file for mainloop.c.
int net_is_disabled(void)
Master header file for Tor-specific functionality.
#define ONION_KEY_CONSENSUS_CHECK_INTERVAL
#define TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT
void periodic_events_register(periodic_event_item_t *item)
void periodic_event_reschedule(periodic_event_item_t *event)
int any_predicted_circuits(time_t now)
Header file for predict_ports.c.
int tor_asprintf(char **strp, const char *fmt,...)
void reschedule_descriptor_update_check(void)
static int reachability_warnings_callback(time_t now, const or_options_t *options)
static int check_dns_honesty_callback(time_t now, const or_options_t *options)
static int check_for_reachability_bw_callback(time_t now, const or_options_t *options)
static int check_descriptor_callback(time_t now, const or_options_t *options)
static int retry_dns_callback(time_t now, const or_options_t *options)
Header for feature/relay/relay_periodic.c.
bool resolved_addr_is_configured(int family)
Header file for resolve_addr.c.
void consider_publishable_server(int force)
void router_upload_dir_desc_to_dirservers(int force)
int get_onion_key_grace_period(void)
void check_descriptor_ipaddress_changed(time_t now)
void mark_my_descriptor_if_omit_ipv6_changes(const char *reason, bool omit_ipv6)
time_t get_onion_key_set_at(void)
const routerinfo_t * router_get_my_routerinfo(void)
void expire_old_onion_keys(void)
bool router_rebuild_descriptor(int force)
void check_descriptor_bandwidth_changed(time_t now)
int get_onion_key_lifetime(void)
void mark_my_descriptor_dirty_if_too_old(time_t now)
void rotate_onion_key(void)
int router_my_exit_policy_is_reject_star(void)
Header file for router.c.
Router descriptor structure.
int load_ed_keys(const or_options_t *options, time_t now)
int should_make_new_ed_keys(const or_options_t *options, const time_t now)
int generate_ed_link_cert(const or_options_t *options, time_t now, int force)
int public_server_mode(const or_options_t *options)
int advertised_server_mode(void)
int server_mode(const or_options_t *options)
Header file for routermode.c.
int router_orport_seems_reachable(const or_options_t *options, int family)
void router_do_reachability_checks(void)
Header file for selftest.c.
uint32_t bandwidthcapacity