ExcludeNodes

Struct ExcludeNodes 

Source
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:

SettingBehavior
"1"Always exclude ?? and a1 country codes
"auto"Exclude ?? and a1 only if other countries are excluded
NoneDon’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

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

Source

pub fn new() -> Self

Creates a new empty ExcludeNodes.

Source

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:

  • $FINGERPRINT or FINGERPRINT - 40 hex character fingerprint
  • $FINGERPRINT~nickname or $FINGERPRINT=nickname - Fingerprint with suffix (suffix stripped)
  • {cc} - Country code (2 characters)
  • 192.168.0.0/24 or 2001:db8::/32 - IP network
  • nickname - Relay nickname
Source

pub fn router_is_excluded(&self, router: &RouterStatusEntry) -> bool

Checks if a router should be excluded.

§Arguments
  • router - The router status entry to check
§Returns

true if the router matches any exclusion criteria.

Source

pub fn has_exclusions(&self) -> bool

Returns true if this ExcludeNodes has any exclusions configured.

Trait Implementations§

Source§

impl Clone for ExcludeNodes

Source§

fn clone(&self) -> ExcludeNodes

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExcludeNodes

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ExcludeNodes

Source§

fn default() -> ExcludeNodes

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more