1
//! Define configuration structures used for relay selection.
2

            
3
use std::collections::HashSet;
4

            
5
/// Configuration object for building relay restrictions.
6
///
7
/// This object can affect the interpretation of various usages and restrictions.
8
#[allow(clippy::exhaustive_structs)]
9
pub struct RelaySelectionConfig<'a> {
10
    /// A set of ports that require Stable relays.
11
    pub long_lived_ports: &'a HashSet<u16>,
12

            
13
    /// Configuration for which addresses are considered "too close"
14
    /// to share a circuit.
15
    pub subnet_config: tor_netdir::SubnetConfig,
16
}
17

            
18
impl<'a> RelaySelectionConfig<'a> {
19
    /// Return true if `port` requires us to use relays with the Stable flag.
20
291178
    pub(crate) fn port_requires_stable_flag(&self, port: u16) -> bool {
21
291178
        self.long_lived_ports.contains(&port)
22
291178
    }
23
}