diff options
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/mod.rs | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 2de44ac..d4a7c9c 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -240,7 +240,7 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[ Kind::List, "NAME,[NAME...]", Some("mycelium"), - "The transports this node uses, in order of preference: mycelium, libp2p (in builds with the libp2p feature). A peer is reached on the first one both have; nodes on several carry the traffic between nodes that share none.", + "The transports this node uses, in order of preference: mycelium, libp2p and tor (in builds with the libp2p and tor features). A peer is reached on the first one both have, until the paths are measured (then on the fastest); nodes on several carry the traffic between nodes that share none.", ), option( "libp2p-listen", @@ -285,6 +285,20 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[ "With the libp2p transport: use public libp2p infrastructure: join the IPFS DHT (through the IPFS bootstrap nodes) to find peers' addresses and public relays, picked after members that relay. Public relays only keep circuits for minutes and some KiB: enough to punch holes through NATs. Makes this node's peer ID and addresses known to the DHT.", ), option( + "tor-state-dir", + Kind::Text, + "PATH", + None, + "With the tor transport: arti's state and cache (in `state` and `cache` below), among them the onion service's key, which makes its address: keep it with the node. Required with tor.", + ), + option( + "tor-port", + Kind::Integer, + "PORT", + Some("9662"), + "With the tor transport: the port of this node's onion service (published with its onion address).", + ), + option( "libp2p-key-file", Kind::Text, "PATH", @@ -420,6 +434,11 @@ pub(crate) struct Settings { pub(crate) libp2p_public: bool, #[cfg_attr(not(feature = "libp2p"), allow(dead_code))] pub(crate) libp2p_key_file: Option<PathBuf>, + #[cfg_attr(not(feature = "tor"), allow(dead_code))] + pub(crate) tor_state_dir: Option<PathBuf>, + #[serde(default = "default_tor_port")] + #[cfg_attr(not(feature = "tor"), allow(dead_code))] + pub(crate) tor_port: u16, pub(crate) mycelium_rest_url: Option<String>, pub(crate) mycelium_key_file: Option<PathBuf>, pub(crate) mycelium_network_key_file: Option<PathBuf>, @@ -455,8 +474,14 @@ fn default_transports() -> Vec<String> { vec!["mycelium".to_owned()] } /// The transports `transports` may name, and whether this build has each. -pub(crate) const TRANSPORTS: &[(&str, bool)] = - &[("mycelium", true), ("libp2p", cfg!(feature = "libp2p"))]; +pub(crate) const TRANSPORTS: &[(&str, bool)] = &[ + ("mycelium", true), + ("libp2p", cfg!(feature = "libp2p")), + ("tor", cfg!(feature = "tor")), +]; +fn default_tor_port() -> u16 { + 9662 +} fn default_mycelium_peers() -> Vec<String> { vec!["tls://127.0.0.1:9651".to_owned()] } @@ -521,6 +546,11 @@ impl Settings { if self.transports.is_empty() { bail!("transports: a node needs at least one"); } + if self.transports.iter().any(|name| name == "tor") && self.tor_state_dir.is_none() { + bail!( + "tor needs tor-state-dir: where arti keeps its state, the onion service's key among it" + ); + } for (index, name) in self.transports.iter().enumerate() { match TRANSPORTS.iter().find(|(known, _)| known == name) { None => bail!( |
