netdoc: ignore bad entries in families.

Some of these are nicknames, which we can safely ignore.
This commit is contained in:
Nick Mathewson 2020-09-07 16:57:57 -04:00
parent 919a7c5970
commit b6a3642903
1 changed files with 4 additions and 0 deletions

View File

@ -12,6 +12,9 @@ use tor_llcrypto::pk::rsa::RSAIdentity;
/// belong to the same family if and only if each one lists the other
/// as belonging to its family.
///
/// NOTE: when parsing, this type always discards incorrectly-formatted
/// entries, including entries that are only nicknames.
///
/// TODO: This type probably belongs in a different crate.
pub struct RelayFamily(Vec<RSAIdentity>);
@ -34,6 +37,7 @@ impl std::str::FromStr for RelayFamily {
let v: Result<Vec<RSAIdentity>> = s
.split(crate::tokenize::is_sp)
.map(|e| e.parse::<LongIdent>().map(|v| v.into()))
.filter(Result::is_ok)
.collect();
Ok(RelayFamily(v?))
}