pub struct ExcludeNodes {
pub networks: Vec<IpNetwork>,
pub idhexes: HashSet<String>,
pub nicks: HashSet<String>,
pub countries: HashSet<String>,
pub exclude_unknowns: Option<String>,
}Expand description
Parsed ExcludeNodes configuration for relay filtering.
Parses Tor’s ExcludeNodes configuration option to filter out unwanted relays based on various criteria. This is used to ensure vanguard guards respect the user’s exclusion preferences.
§Supported Entry Types
┌─────────────────────────────────────────────────────────────────────────┐
│ ExcludeNodes Entry Types │
│ │
│ Type │ Format │ Example │
│ ──────────────┼────────────────────────────┼───────────────────────────│
│ Fingerprint │ $FINGERPRINT or FINGERPRINT│ $AABB...EEFF │
│ Country │ {cc} │ {us}, {ru} │
│ Network │ IP/CIDR │ 192.168.0.0/16 │
│ IP Address │ IP │ 192.168.1.1 │
│ Nickname │ name │ BadRelay │
└─────────────────────────────────────────────────────────────────────────┘§GeoIPExcludeUnknown
The exclude_unknowns field controls handling of relays with unknown
country codes:
| Setting | Behavior |
|---|---|
"1" | Always exclude ?? and a1 country codes |
"auto" | Exclude ?? and a1 only if other countries are excluded |
None | Don’t exclude unknown countries |
§Example
use vanguards_rs::vanguards::ExcludeNodes;
// Parse mixed exclusion configuration
let exclude = ExcludeNodes::parse(
"$AABBCCDD00112233445566778899AABBCCDDEEFF,{us},192.168.0.0/16,BadRelay",
Some("auto")
);
assert!(exclude.idhexes.contains("AABBCCDD00112233445566778899AABBCCDDEEFF"));
assert!(exclude.countries.contains("us"));
assert!(exclude.countries.contains("??")); // auto-added due to {us}
assert_eq!(exclude.networks.len(), 1);
assert!(exclude.nicks.contains("BadRelay"));§See Also
VanguardState::remove_excluded_from_layer- Uses this for filtering- Tor Manual - ExcludeNodes
Fields§
§networks: Vec<IpNetwork>IP networks to exclude (CIDR notation).
idhexes: HashSet<String>Relay fingerprints to exclude (uppercase hex).
nicks: HashSet<String>Relay nicknames to exclude.
countries: HashSet<String>Country codes to exclude (lowercase).
exclude_unknowns: Option<String>GeoIPExcludeUnknown setting (“1”, “auto”, or None).
Implementations§
Source§impl ExcludeNodes
impl ExcludeNodes
Sourcepub fn parse(conf_line: &str, exclude_unknowns: Option<&str>) -> Self
pub fn parse(conf_line: &str, exclude_unknowns: Option<&str>) -> Self
Parses an ExcludeNodes configuration line.
§Arguments
conf_line- The ExcludeNodes configuration value (comma-separated)exclude_unknowns- The GeoIPExcludeUnknown setting
§Returns
A parsed ExcludeNodes struct.
§Entry Format
Entries are comma-separated and can be:
$FINGERPRINTorFINGERPRINT- 40 hex character fingerprint$FINGERPRINT~nicknameor$FINGERPRINT=nickname- Fingerprint with suffix (suffix stripped){cc}- Country code (2 characters)192.168.0.0/24or2001:db8::/32- IP networknickname- Relay nickname
Sourcepub fn router_is_excluded(&self, router: &RouterStatusEntry) -> bool
pub fn router_is_excluded(&self, router: &RouterStatusEntry) -> bool
Sourcepub fn has_exclusions(&self) -> bool
pub fn has_exclusions(&self) -> bool
Returns true if this ExcludeNodes has any exclusions configured.
Trait Implementations§
Source§impl Clone for ExcludeNodes
impl Clone for ExcludeNodes
Source§fn clone(&self) -> ExcludeNodes
fn clone(&self) -> ExcludeNodes
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ExcludeNodes
impl Debug for ExcludeNodes
Source§impl Default for ExcludeNodes
impl Default for ExcludeNodes
Source§fn default() -> ExcludeNodes
fn default() -> ExcludeNodes
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ExcludeNodes
impl RefUnwindSafe for ExcludeNodes
impl Send for ExcludeNodes
impl Sync for ExcludeNodes
impl Unpin for ExcludeNodes
impl UnwindSafe for ExcludeNodes
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more