netdoc: Add MiddleOnly flag to RelayFlags

Closes #833
This commit is contained in:
juga 2023-04-17 09:46:06 +00:00
parent f5542d847f
commit eee1dbee7a
2 changed files with 8 additions and 0 deletions

View File

@ -465,6 +465,9 @@ bitflags! {
/// Does this relay participate on the onion service directory /// Does this relay participate on the onion service directory
/// ring? /// ring?
const HSDIR = (1<<5); const HSDIR = (1<<5);
/// Set if this relay is considered "middle only", not suitable to run
/// as an exit or guard relay.
const MIDDLE_ONLY = (1<<12);
/// If set, there is no consensus for the ed25519 key for this relay. /// If set, there is no consensus for the ed25519 key for this relay.
const NO_ED_CONSENSUS = (1<<6); const NO_ED_CONSENSUS = (1<<6);
/// Is this relay considered "stable" enough for long-lived circuits? /// Is this relay considered "stable" enough for long-lived circuits?
@ -1150,6 +1153,7 @@ impl std::str::FromStr for RelayFlags {
"Fast" => RelayFlags::FAST, "Fast" => RelayFlags::FAST,
"Guard" => RelayFlags::GUARD, "Guard" => RelayFlags::GUARD,
"HSDir" => RelayFlags::HSDIR, "HSDir" => RelayFlags::HSDIR,
"MiddleOnly" => RelayFlags::MIDDLE_ONLY,
"NoEdConsensus" => RelayFlags::NO_ED_CONSENSUS, "NoEdConsensus" => RelayFlags::NO_ED_CONSENSUS,
"Stable" => RelayFlags::STABLE, "Stable" => RelayFlags::STABLE,
"StaleDesc" => RelayFlags::STALE_DESC, "StaleDesc" => RelayFlags::STALE_DESC,

View File

@ -159,6 +159,10 @@ macro_rules! implement_accessors {
pub fn is_flagged_hsdir(&self) -> bool { pub fn is_flagged_hsdir(&self) -> bool {
self.rs.flags.contains(RelayFlags::HSDIR) self.rs.flags.contains(RelayFlags::HSDIR)
} }
/// Return true if this routerstatus is listed with the MiddleOnly flag.
pub fn is_flagged_middle_only(&self) -> bool {
self.rs.flags.contains(RelayFlags::MIDDLE_ONLY)
}
} }
}; };
} }