pub struct ServerDescriptor {Show 40 fields
pub nickname: String,
pub fingerprint: Option<String>,
pub address: IpAddr,
pub or_port: u16,
pub socks_port: Option<u16>,
pub dir_port: Option<u16>,
pub or_addresses: Vec<(IpAddr, u16, bool)>,
pub platform: Option<Vec<u8>>,
pub tor_version: Option<Version>,
pub operating_system: Option<String>,
pub published: DateTime<Utc>,
pub uptime: Option<u64>,
pub contact: Option<Vec<u8>>,
pub link_protocols: Option<Vec<String>>,
pub circuit_protocols: Option<Vec<String>>,
pub bandwidth_avg: u64,
pub bandwidth_burst: u64,
pub bandwidth_observed: u64,
pub exit_policy: ExitPolicy,
pub exit_policy_v6: Option<String>,
pub bridge_distribution: BridgeDistribution,
pub family: HashSet<String>,
pub hibernating: bool,
pub allow_single_hop_exits: bool,
pub allow_tunneled_dir_requests: bool,
pub extra_info_cache: bool,
pub extra_info_digest: Option<String>,
pub extra_info_sha256_digest: Option<String>,
pub is_hidden_service_dir: bool,
pub protocols: HashMap<String, Vec<u32>>,
pub onion_key: Option<String>,
pub onion_key_crosscert: Option<String>,
pub ntor_onion_key: Option<String>,
pub ntor_onion_key_crosscert: Option<String>,
pub ntor_onion_key_crosscert_sign: Option<String>,
pub signing_key: Option<String>,
pub ed25519_certificate: Option<String>,
pub ed25519_master_key: Option<String>,
pub ed25519_signature: Option<String>,
pub signature: String,
/* private fields */
}Expand description
A server descriptor containing metadata about a Tor relay.
Server descriptors are the primary documents that relays publish to describe themselves. They contain identity information, network addresses, bandwidth capabilities, exit policies, and cryptographic keys needed for circuit construction.
§Fields Overview
| Category | Fields |
|---|---|
| Identity | nickname, fingerprint, contact |
| Network | address, or_port, dir_port, or_addresses |
| Bandwidth | bandwidth_avg, bandwidth_burst, bandwidth_observed |
| Policy | exit_policy, exit_policy_v6 |
| Keys | onion_key, signing_key, ntor_onion_key, Ed25519 keys |
| Protocols | protocols, link_protocols, circuit_protocols |
| Metadata | platform, tor_version, published, uptime |
§Invariants
nicknameis 1-19 alphanumeric charactersfingerprintis 40 uppercase hex characters (if present)or_portis non-zeropublishedis a valid UTC timestampsignatureis always present and non-empty
§Example
use stem_rs::descriptor::{ServerDescriptor, Descriptor};
let content = std::fs::read_to_string("server-descriptor").unwrap();
let desc = ServerDescriptor::parse(&content).unwrap();
println!("Nickname: {}", desc.nickname);
println!("Address: {}:{}", desc.address, desc.or_port);
println!("Published: {}", desc.published);
println!("Bandwidth: {} B/s avg, {} B/s observed",
desc.bandwidth_avg, desc.bandwidth_observed);
if let Some(ref fp) = desc.fingerprint {
println!("Fingerprint: {}", fp);
}
if let Some(ref version) = desc.tor_version {
println!("Tor version: {}", version);
}§Thread Safety
ServerDescriptor is Send and Sync as it contains only owned data.
Fields§
§nickname: StringThe relay’s nickname (1-19 alphanumeric characters).
fingerprint: Option<String>The relay’s fingerprint (40 hex characters), derived from identity key.
address: IpAddrThe relay’s primary IPv4 address.
or_port: u16The relay’s onion routing port (always non-zero).
socks_port: Option<u16>The relay’s SOCKS port (deprecated, usually None).
dir_port: Option<u16>The relay’s directory port for serving cached descriptors.
or_addresses: Vec<(IpAddr, u16, bool)>Additional addresses (IPv4 or IPv6) the relay listens on. Each tuple is (address, port, is_ipv6).
platform: Option<Vec<u8>>Raw platform string (e.g., “Tor 0.4.7.10 on Linux”).
tor_version: Option<Version>Parsed Tor version from the platform string.
operating_system: Option<String>Operating system from the platform string.
published: DateTime<Utc>When this descriptor was published (UTC).
uptime: Option<u64>Seconds the relay has been running.
contact: Option<Vec<u8>>Contact information for the relay operator.
link_protocols: Option<Vec<String>>Supported link protocol versions (legacy).
circuit_protocols: Option<Vec<String>>Supported circuit protocol versions (legacy).
bandwidth_avg: u64Average bandwidth in bytes per second the relay is willing to sustain.
bandwidth_burst: u64Maximum bandwidth in bytes per second for short bursts.
bandwidth_observed: u64Bandwidth in bytes per second the relay has actually observed.
exit_policy: ExitPolicyThe relay’s exit policy (rules for what traffic it will exit).
exit_policy_v6: Option<String>IPv6 exit policy summary (e.g., “accept 80,443” or “reject 1-65535”).
bridge_distribution: BridgeDistributionHow this bridge wants to be distributed (bridges only).
family: HashSet<String>Fingerprints of related relays (same operator).
hibernating: boolWhether the relay is currently hibernating (reduced service).
allow_single_hop_exits: boolWhether the relay allows single-hop exits (security risk).
allow_tunneled_dir_requests: boolWhether the relay accepts tunneled directory requests.
extra_info_cache: boolWhether the relay caches extra-info descriptors.
extra_info_digest: Option<String>SHA-1 digest of the relay’s extra-info descriptor.
extra_info_sha256_digest: Option<String>SHA-256 digest of the relay’s extra-info descriptor.
Whether the relay serves as a hidden service directory.
protocols: HashMap<String, Vec<u32>>Supported protocol versions (modern format). Maps protocol name to list of supported versions.
onion_key: Option<String>RSA onion key for circuit creation (PEM format).
onion_key_crosscert: Option<String>Cross-certification of onion key by identity key.
ntor_onion_key: Option<String>Curve25519 onion key for ntor handshake (base64).
ntor_onion_key_crosscert: Option<String>Cross-certification of ntor key.
ntor_onion_key_crosscert_sign: Option<String>Sign bit for ntor key cross-certification.
signing_key: Option<String>RSA signing key (PEM format).
ed25519_certificate: Option<String>Ed25519 identity certificate (PEM format).
ed25519_master_key: Option<String>Ed25519 master key (base64).
ed25519_signature: Option<String>Ed25519 signature over the descriptor.
signature: StringRSA signature over the descriptor (PEM format).
Implementations§
Source§impl ServerDescriptor
impl ServerDescriptor
Sourcepub fn new(
nickname: String,
address: IpAddr,
or_port: u16,
published: DateTime<Utc>,
signature: String,
) -> Self
pub fn new( nickname: String, address: IpAddr, or_port: u16, published: DateTime<Utc>, signature: String, ) -> Self
Creates a new server descriptor with minimal required fields.
This creates a descriptor with default values for optional fields. Use this for testing or when constructing descriptors programmatically.
§Arguments
nickname- The relay’s nickname (1-19 alphanumeric characters)address- The relay’s primary IP addressor_port- The relay’s onion routing portpublished- When this descriptor was publishedsignature- The RSA signature (PEM format)
§Example
use stem_rs::descriptor::ServerDescriptor;
use chrono::Utc;
use std::net::IpAddr;
let desc = ServerDescriptor::new(
"MyRelay".to_string(),
"192.168.1.1".parse().unwrap(),
9001,
Utc::now(),
"-----BEGIN SIGNATURE-----\ntest\n-----END SIGNATURE-----".to_string(),
);
assert_eq!(desc.nickname, "MyRelay");
assert_eq!(desc.or_port, 9001);Trait Implementations§
Source§impl Clone for ServerDescriptor
impl Clone for ServerDescriptor
Source§fn clone(&self) -> ServerDescriptor
fn clone(&self) -> ServerDescriptor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more