pub struct TorConfig {
pub mode: Option<String>,
pub socks5_addr: Option<String>,
pub connect_timeout_ms: Option<u64>,
pub mtu: Option<u16>,
pub control_addr: Option<String>,
pub control_auth: Option<String>,
pub cookie_path: Option<String>,
pub max_inbound_connections: Option<usize>,
pub directory_service: Option<DirectoryServiceConfig>,
pub advertise_on_nostr: Option<bool>,
pub advertised_port: Option<u16>,
}Expand description
Tor transport instance configuration.
Supports three modes:
socks5: Outbound-only connections through a Tor SOCKS5 proxy.control_port: Full bidirectional support — outbound via SOCKS5 plus inbound via Tor onion service managed through the control port.directory: Full bidirectional support — outbound via SOCKS5, inbound via a Tor-managedHiddenServiceDironion service. No control port needed. Enables TorSandbox 1mode.
Fields§
§mode: Option<String>Tor access mode: “socks5”, “control_port”, or “directory”. Default: “socks5”.
socks5_addr: Option<String>SOCKS5 proxy address (host:port). Defaults to “127.0.0.1:9050”.
connect_timeout_ms: Option<u64>Outbound connect timeout in milliseconds. Defaults to 120000 (120s). Tor circuit establishment can take 30-60s, so this must be generous.
mtu: Option<u16>Default MTU for Tor connections. Defaults to 1400.
control_addr: Option<String>Control port address: a Unix socket path (/run/tor/control) or
TCP address (host:port). Unix sockets are preferred for security.
Defaults to “/run/tor/control”.
control_auth: Option<String>Control port authentication method:
"cookie" (read from default path),
"cookie:/path/to/cookie" (read from specified path), or
"password:secret" (password auth). Default: "cookie".
Path to the Tor control cookie file. Used when control_auth is “cookie”. Defaults to “/var/run/tor/control.authcookie”.
max_inbound_connections: Option<usize>Maximum number of inbound connections via onion service. Default: 64.
directory_service: Option<DirectoryServiceConfig>Directory-mode onion service configuration. Only valid in “directory” mode. Tor manages the onion service via HiddenServiceDir in torrc; fips reads the .onion hostname from a file.
advertise_on_nostr: Option<bool>Whether this transport should be advertised on Nostr overlay discovery. Default: false.
advertised_port: Option<u16>Public-facing onion port published in Nostr overlay adverts. Must
match the virtual port in torrc’s HiddenServicePort <port> 127.0.0.1:<bind_port> directive — that is the port other peers
will use to reach this onion. Default: 443.
Implementations§
Source§impl TorConfig
impl TorConfig
Sourcepub fn socks5_addr(&self) -> &str
pub fn socks5_addr(&self) -> &str
Get the SOCKS5 proxy address. Default: “127.0.0.1:9050”.
Sourcepub fn control_addr(&self) -> &str
pub fn control_addr(&self) -> &str
Get the control port address. Default: “/run/tor/control”.
Sourcepub fn control_auth(&self) -> &str
pub fn control_auth(&self) -> &str
Get the control auth string. Default: “cookie”.
Get the cookie file path. Default: “/var/run/tor/control.authcookie”.
Sourcepub fn connect_timeout_ms(&self) -> u64
pub fn connect_timeout_ms(&self) -> u64
Get the connect timeout in milliseconds. Default: 120000.
Sourcepub fn max_inbound_connections(&self) -> usize
pub fn max_inbound_connections(&self) -> usize
Get the max inbound connections. Default: 64.
Sourcepub fn advertise_on_nostr(&self) -> bool
pub fn advertise_on_nostr(&self) -> bool
Whether this Tor transport should be advertised on Nostr discovery.
Sourcepub fn advertised_port(&self) -> u16
pub fn advertised_port(&self) -> u16
Public-facing onion port published in Nostr overlay adverts. Default: 443.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TorConfig
impl<'de> Deserialize<'de> for TorConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for TorConfig
impl RefUnwindSafe for TorConfig
impl Send for TorConfig
impl Sync for TorConfig
impl Unpin for TorConfig
impl UnsafeUnpin for TorConfig
impl UnwindSafe for TorConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more