node: Add `listen` option to node config
This commit is contained in:
parent
d67f9ea9bb
commit
0b6ede69e7
|
|
@ -112,6 +112,11 @@ fn execute() -> anyhow::Result<()> {
|
||||||
let daemon = options.daemon.unwrap_or_else(|| {
|
let daemon = options.daemon.unwrap_or_else(|| {
|
||||||
net::SocketAddr::new(net::Ipv4Addr::LOCALHOST.into(), radicle::git::PROTOCOL_PORT)
|
net::SocketAddr::new(net::Ipv4Addr::LOCALHOST.into(), radicle::git::PROTOCOL_PORT)
|
||||||
});
|
});
|
||||||
|
let listen: Vec<std::net::SocketAddr> = if !options.listen.is_empty() {
|
||||||
|
options.listen.clone()
|
||||||
|
} else {
|
||||||
|
config.listen.clone()
|
||||||
|
};
|
||||||
|
|
||||||
let (notify, signals) = chan::bounded(1);
|
let (notify, signals) = chan::bounded(1);
|
||||||
signals::install(notify)?;
|
signals::install(notify)?;
|
||||||
|
|
@ -120,7 +125,7 @@ fn execute() -> anyhow::Result<()> {
|
||||||
log::debug!(target: "node", "Removing existing control socket..");
|
log::debug!(target: "node", "Removing existing control socket..");
|
||||||
fs::remove_file(home.socket()).ok();
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
use std::net;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
use cyphernet::addr::PeerAddr;
|
use cyphernet::addr::PeerAddr;
|
||||||
|
|
@ -165,6 +166,9 @@ impl Default for PeerConfig {
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
/// Node alias.
|
/// Node alias.
|
||||||
pub alias: Alias,
|
pub alias: Alias,
|
||||||
|
/// Address to listen on.
|
||||||
|
#[serde(default)]
|
||||||
|
pub listen: Vec<net::SocketAddr>,
|
||||||
/// Peer configuration.
|
/// Peer configuration.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub peers: PeerConfig,
|
pub peers: PeerConfig,
|
||||||
|
|
@ -204,6 +208,7 @@ impl Config {
|
||||||
Self {
|
Self {
|
||||||
alias,
|
alias,
|
||||||
peers: PeerConfig::default(),
|
peers: PeerConfig::default(),
|
||||||
|
listen: vec![],
|
||||||
connect: HashSet::default(),
|
connect: HashSet::default(),
|
||||||
external_addresses: vec![],
|
external_addresses: vec![],
|
||||||
network: Network::default(),
|
network: Network::default(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue