Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node: Explicit default for `AddressConfig`
✗ CI failure Lorenz Leutgeb committed 1 month ago
commit 96099a94ae440eee475bcc2039490d486477f280
parent d4153c04f72c2fa0a11132dac88a7b95ab93035f
1 failed (1 total) View logs
3 files changed +13 -8
modified crates/radicle-node/src/wire.rs
@@ -1097,10 +1097,10 @@ pub fn dial<G: Ecdh<Pk = NodeId>>(
        (HostName::Tor(onion), proxy) => match config.onion {
            // In onion proxy mode, simply use the configured proxy address.
            // This takes precedence over any global proxy.
-
            Some(AddressConfig::Proxy { address }) => address.into(),
+
            AddressConfig::Proxy { address } => address.into(),
            // In "forward" mode, if a global proxy is set, we use that, otherwise
            // we treat `.onion` addresses as regular DNS names.
-
            Some(AddressConfig::Forward) => {
+
            AddressConfig::Forward => {
                if let Some(proxy) = proxy {
                    proxy.into()
                } else {
@@ -1108,7 +1108,7 @@ pub fn dial<G: Ecdh<Pk = NodeId>>(
                }
            }
            // If onion address support isn't configured, refuse to connect.
-
            None => {
+
            AddressConfig::Drop => {
                return Err(io::Error::new(
                    io::ErrorKind::Unsupported,
                    "no configuration found for .onion addresses",
modified crates/radicle-protocol/src/service.rs
@@ -30,6 +30,8 @@ use radicle::node;
use radicle::node::address;
use radicle::node::address::Store as _;
use radicle::node::address::{AddressBook, AddressType, KnownAddress};
+
#[cfg(feature = "tor")]
+
use radicle::node::config::AddressConfig;
use radicle::node::config::{PeerConfig, RateLimit};
use radicle::node::device::Device;
use radicle::node::refs::Store as _;
@@ -2639,7 +2641,7 @@ where
        match AddressType::from(address) {
            // Only consider onion addresses if configured.
            #[cfg(feature = "tor")]
-
            AddressType::Onion => self.config.onion.is_some(),
+
            AddressType::Onion => self.config.onion != AddressConfig::Drop,
            AddressType::Dns | AddressType::Ipv4 | AddressType::Ipv6 => true,
        }
    }
modified crates/radicle/src/node/config.rs
@@ -354,7 +354,7 @@ pub enum Relay {
}

/// Proxy configuration.
-
#[derive(Debug, Clone, Serialize, Deserialize)]
+
#[derive(Debug, Copy, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", tag = "mode")]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg(feature = "tor")]
@@ -367,6 +367,9 @@ pub enum AddressConfig {
    /// Forward address to the next layer. Either this is the global proxy,
    /// or the operating system, via DNS.
    Forward,
+
    /// Drop connections to this address type.
+
    #[default]
+
    Drop,
}

/// Default seeding policy. Applies when no repository policies for the given repo are found.
@@ -495,8 +498,8 @@ pub struct Config {
    pub proxy: Option<net::SocketAddr>,
    /// Onion address config.
    #[cfg(feature = "tor")]
-
    #[serde(default, skip_serializing_if = "Option::is_none")]
-
    pub onion: Option<AddressConfig>,
+
    #[serde(default, skip_serializing_if = "crate::serde_ext::is_default")]
+
    pub onion: AddressConfig,
    /// Peer-to-peer network.
    #[serde(default)]
    pub network: Network,
@@ -549,7 +552,7 @@ impl Config {
            network: Network::default(),
            proxy: None,
            #[cfg(feature = "tor")]
-
            onion: None,
+
            onion: AddressConfig::Drop,
            relay: Relay::default(),
            limits: Limits::default(),
            workers: Workers::default(),