mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 14:23:30 +01:00
Rate-limit warnings related to unrecognized MyFamily elements.
svn:r5204
This commit is contained in:
parent
ba67d14d40
commit
5cf758764e
@ -926,6 +926,7 @@ do_hup(void)
|
|||||||
if (accounting_is_enabled(options))
|
if (accounting_is_enabled(options))
|
||||||
accounting_record_bandwidth_usage(time(NULL));
|
accounting_record_bandwidth_usage(time(NULL));
|
||||||
|
|
||||||
|
router_reset_warnings();
|
||||||
routerlist_reset_warnings();
|
routerlist_reset_warnings();
|
||||||
addressmap_clear_transient();
|
addressmap_clear_transient();
|
||||||
/* first, reload config variables, in case they've changed */
|
/* first, reload config variables, in case they've changed */
|
||||||
@ -1382,7 +1383,7 @@ tor_free_all(int postfork)
|
|||||||
connection_free_all();
|
connection_free_all();
|
||||||
if (!postfork) {
|
if (!postfork) {
|
||||||
config_free_all();
|
config_free_all();
|
||||||
router_free_all_keys();
|
router_free_all();
|
||||||
}
|
}
|
||||||
tor_tls_free_all();
|
tor_tls_free_all();
|
||||||
/* stuff in main.c */
|
/* stuff in main.c */
|
||||||
|
@ -2055,7 +2055,8 @@ int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
|
|||||||
crypto_pk_env_t *ident_key);
|
crypto_pk_env_t *ident_key);
|
||||||
int is_legal_nickname(const char *s);
|
int is_legal_nickname(const char *s);
|
||||||
int is_legal_nickname_or_hexdigest(const char *s);
|
int is_legal_nickname_or_hexdigest(const char *s);
|
||||||
void router_free_all_keys(void);
|
void router_reset_warnings(void);
|
||||||
|
void router_free_all(void);
|
||||||
|
|
||||||
/********************************* routerlist.c ***************************/
|
/********************************* routerlist.c ***************************/
|
||||||
|
|
||||||
|
@ -756,6 +756,9 @@ router_get_my_descriptor(void)
|
|||||||
return desc_routerinfo->signed_descriptor;
|
return desc_routerinfo->signed_descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*DOCDOC*/
|
||||||
|
static smartlist_t *warned_nonexistent_family = NULL;
|
||||||
|
|
||||||
/** If <b>force</b> is true, or our descriptor is out-of-date, rebuild
|
/** If <b>force</b> is true, or our descriptor is out-of-date, rebuild
|
||||||
* a fresh routerinfo and signed server descriptor for this OR.
|
* a fresh routerinfo and signed server descriptor for this OR.
|
||||||
* Return 0 on success, -1 on error.
|
* Return 0 on success, -1 on error.
|
||||||
@ -810,6 +813,8 @@ router_rebuild_descriptor(int force)
|
|||||||
if (authdir_mode(options))
|
if (authdir_mode(options))
|
||||||
ri->is_verified = ri->is_named = 1; /* believe in yourself */
|
ri->is_verified = ri->is_named = 1; /* believe in yourself */
|
||||||
if (options->MyFamily) {
|
if (options->MyFamily) {
|
||||||
|
if (!warned_nonexistent_family)
|
||||||
|
warned_nonexistent_family = smartlist_create();
|
||||||
smartlist_t *family = smartlist_create();
|
smartlist_t *family = smartlist_create();
|
||||||
ri->declared_family = smartlist_create();
|
ri->declared_family = smartlist_create();
|
||||||
smartlist_split_string(family, options->MyFamily, ",",
|
smartlist_split_string(family, options->MyFamily, ",",
|
||||||
@ -822,9 +827,12 @@ router_rebuild_descriptor(int force)
|
|||||||
else
|
else
|
||||||
member = router_get_by_nickname(name, 1);
|
member = router_get_by_nickname(name, 1);
|
||||||
if (!member) {
|
if (!member) {
|
||||||
|
if (!smartlist_string_isin(warned_nonexistent_family, name)) {
|
||||||
log_fn(LOG_WARN, "I have no descriptor for the router named \"%s\" "
|
log_fn(LOG_WARN, "I have no descriptor for the router named \"%s\" "
|
||||||
"in my declared family; I'll use the nickname verbatim, but "
|
"in my declared family; I'll use the nickname as is, but "
|
||||||
"this may confuse clients.", name);
|
"this may confuse clients.", name);
|
||||||
|
smartlist_add(warned_nonexistent_family, tor_strdup(name));
|
||||||
|
}
|
||||||
smartlist_add(ri->declared_family, name);
|
smartlist_add(ri->declared_family, name);
|
||||||
name = NULL;
|
name = NULL;
|
||||||
} else {
|
} else {
|
||||||
@ -833,6 +841,8 @@ router_rebuild_descriptor(int force)
|
|||||||
base16_encode(fp+1,HEX_DIGEST_LEN+1,
|
base16_encode(fp+1,HEX_DIGEST_LEN+1,
|
||||||
member->identity_digest, DIGEST_LEN);
|
member->identity_digest, DIGEST_LEN);
|
||||||
smartlist_add(ri->declared_family, fp);
|
smartlist_add(ri->declared_family, fp);
|
||||||
|
if (smartlist_string_isin(warned_nonexistent_family, name))
|
||||||
|
smartlist_string_remove(warned_nonexistent_family, name);
|
||||||
}
|
}
|
||||||
tor_free(name);
|
tor_free(name);
|
||||||
});
|
});
|
||||||
@ -1135,9 +1145,20 @@ is_legal_nickname_or_hexdigest(const char *s)
|
|||||||
return len == HEX_DIGEST_LEN+1 && strspn(s+1,HEX_CHARACTERS)==len-1;
|
return len == HEX_DIGEST_LEN+1 && strspn(s+1,HEX_CHARACTERS)==len-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Release all resources held in router keys. */
|
/** Forget that we have issued any router-related warnings, so that we'll
|
||||||
|
* warn again if we see the same errors. */
|
||||||
void
|
void
|
||||||
router_free_all_keys(void)
|
router_reset_warnings(void)
|
||||||
|
{
|
||||||
|
if (warned_nonexistent_family) {
|
||||||
|
SMARTLIST_FOREACH(warned_nonexistent_family, char *, cp, tor_free(cp));
|
||||||
|
smartlist_clear(warned_nonexistent_family);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Release all static resources held in router.c */
|
||||||
|
void
|
||||||
|
router_free_all(void)
|
||||||
{
|
{
|
||||||
if (onionkey)
|
if (onionkey)
|
||||||
crypto_free_pk_env(onionkey);
|
crypto_free_pk_env(onionkey);
|
||||||
@ -1149,5 +1170,8 @@ router_free_all_keys(void)
|
|||||||
tor_mutex_free(key_lock);
|
tor_mutex_free(key_lock);
|
||||||
if (desc_routerinfo)
|
if (desc_routerinfo)
|
||||||
routerinfo_free(desc_routerinfo);
|
routerinfo_free(desc_routerinfo);
|
||||||
|
if (warned_nonexistent_family) {
|
||||||
|
SMARTLIST_FOREACH(warned_nonexistent_family, char *, cp, tor_free(cp));
|
||||||
|
smartlist_free(warned_nonexistent_family);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user