From 0b6ede69e7ae15ff9a30b968d6e5a70c3b9a6256 Mon Sep 17 00:00:00 2001 From: Michalis Zampetakis Date: Mon, 23 Oct 2023 08:11:59 +0300 Subject: [PATCH] node: Add `listen` option to node config --- radicle-node/src/main.rs | 7 ++++++- radicle/src/node/config.rs | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/radicle-node/src/main.rs b/radicle-node/src/main.rs index a646053e..4d6d9c32 100644 --- a/radicle-node/src/main.rs +++ b/radicle-node/src/main.rs @@ -112,6 +112,11 @@ fn execute() -> anyhow::Result<()> { let daemon = options.daemon.unwrap_or_else(|| { net::SocketAddr::new(net::Ipv4Addr::LOCALHOST.into(), radicle::git::PROTOCOL_PORT) }); + let listen: Vec = if !options.listen.is_empty() { + options.listen.clone() + } else { + config.listen.clone() + }; let (notify, signals) = chan::bounded(1); signals::install(notify)?; @@ -120,7 +125,7 @@ fn execute() -> anyhow::Result<()> { log::debug!(target: "node", "Removing existing control socket.."); fs::remove_file(home.socket()).ok(); } - Runtime::init(home, config, options.listen, proxy, daemon, signals, signer)?.run()?; + Runtime::init(home, config, listen, proxy, daemon, signals, signer)?.run()?; Ok(()) } diff --git a/radicle/src/node/config.rs b/radicle/src/node/config.rs index 92c7234a..0b4da321 100644 --- a/radicle/src/node/config.rs +++ b/radicle/src/node/config.rs @@ -1,4 +1,5 @@ use std::collections::HashSet; +use std::net; use std::ops::Deref; use cyphernet::addr::PeerAddr; @@ -165,6 +166,9 @@ impl Default for PeerConfig { pub struct Config { /// Node alias. pub alias: Alias, + /// Address to listen on. + #[serde(default)] + pub listen: Vec, /// Peer configuration. #[serde(default)] pub peers: PeerConfig, @@ -204,6 +208,7 @@ impl Config { Self { alias, peers: PeerConfig::default(), + listen: vec![], connect: HashSet::default(), external_addresses: vec![], network: Network::default(),