| |
use std::io;
|
| - |
use std::{env, fs, net, process};
|
| + |
use std::{env, fs, net, path::PathBuf, process};
|
| |
|
| - |
use anyhow::{anyhow, Context};
|
| + |
use anyhow::Context;
|
| |
use crossbeam_channel as chan;
|
| - |
use cyphernet::addr::PeerAddr;
|
| - |
use localtime::LocalDuration;
|
| |
|
| - |
use radicle::node;
|
| |
use radicle::prelude::Signer;
|
| |
use radicle::profile;
|
| |
use radicle::version;
|
| |
use radicle_node::crypto::ssh::keystore::{Keystore, MemorySigner};
|
| - |
use radicle_node::prelude::{Address, NodeId};
|
| |
use radicle_node::Runtime;
|
| - |
use radicle_node::{logger, service, signals};
|
| + |
use radicle_node::{logger, signals};
|
| |
|
| |
pub const NAME: &str = "radicle-node";
|
| |
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
| |
radicle-node [<option>...]
|
| |
|
| |
If you're running a public seed node, make sure to use `--listen` to bind a listening socket to
|
| - |
eg. `0.0.0.0:8776`, and `--external-address` to advertize your public/external address to the
|
| - |
network.
|
| + |
eg. `0.0.0.0:8776`, and add your external addresses in your configuration.
|
| |
|
| |
Options
|
| |
|
| - |
--connect <peer> Connect to the given peer address on start
|
| - |
--external-address <address> Publicly accessible address (may be specified multiple times)
|
| + |
--config <path> Config file to use (default ~/.radicle/config.json)
|
| |
--git-daemon <address> Address to bind git-daemon to (default 0.0.0.0:9418)
|
| - |
--tracking-policy (track|block) Default tracking policy
|
| - |
--tracking-scope (trusted|all) Default scope for tracking policies
|
| |
--force Force start even if an existing control socket is found
|
| - |
--help Print help
|
| |
--listen <address> Address to listen on
|
| |
--version Print program version
|
| + |
--help Print help
|
| |
"#;
|
| |
|
| |
#[derive(Debug)]
|
| |
struct Options {
|
| |
daemon: Option<net::SocketAddr>,
|
| + |
config: Option<PathBuf>,
|
| |
listen: Vec<net::SocketAddr>,
|
| |
force: bool,
|
| |
}
|
| |
|
| |
impl Options {
|
| - |
fn from_env(config: &mut node::Config) -> Result<Self, anyhow::Error> {
|
| + |
fn from_env() -> Result<Self, anyhow::Error> {
|
| |
use lexopt::prelude::*;
|
| |
|
| |
let mut parser = lexopt::Parser::from_env();
|
| |
let mut listen = Vec::new();
|
| |
let mut daemon = None;
|
| + |
let mut config = None;
|
| |
let mut force = false;
|
| |
|
| |
while let Some(arg) = parser.next()? {
|
| |
match arg {
|
| - |
Long("connect") => {
|
| - |
let peer: PeerAddr<NodeId, Address> = parser.value()?.parse()?;
|
| - |
config.connect.insert(peer.into());
|
| - |
}
|
| - |
Long("external-address") => {
|
| - |
let addr = parser.value()?.parse()?;
|
| - |
config.external_addresses.push(addr);
|
| - |
}
|
| |
Long("force") => {
|
| |
force = true;
|
| |
}
|
| |
let addr = parser.value()?.parse()?;
|
| |
daemon = Some(addr);
|
| |
}
|
| - |
Long("tracking-policy") => {
|
| - |
let policy = parser
|
| - |
.value()?
|
| - |
.parse()
|
| - |
.map_err(|s| anyhow!("unknown tracking policy {:?}", s))?;
|
| - |
config.policy = policy;
|
| - |
}
|
| - |
Long("tracking-scope") => {
|
| - |
let scope = parser
|
| - |
.value()?
|
| - |
.parse()
|
| - |
.map_err(|s| anyhow!("unknown tracking scope {:?}", s))?;
|
| - |
config.scope = scope;
|
| - |
}
|
| - |
Long("limit-routing-max-age") => {
|
| - |
let secs: u64 = parser.value()?.parse()?;
|
| - |
config.limits.routing_max_age = LocalDuration::from_secs(secs);
|
| - |
}
|
| - |
Long("limit-routing-max-size") => {
|
| - |
config.limits.routing_max_size = parser.value()?.parse()?;
|
| - |
}
|
| - |
Long("limit-fetch-concurrency") => {
|
| - |
config.limits.fetch_concurrency = parser.value()?.parse()?;
|
| + |
Long("config") => {
|
| + |
let value = parser.value()?;
|
| + |
let path = PathBuf::from(value);
|
| + |
config = Some(path);
|
| |
}
|
| |
Long("listen") => {
|
| |
let addr = parser.value()?.parse()?;
|
| |
logger::init(log::Level::Debug)?;
|
| |
|
| |
let home = profile::home()?;
|
| - |
let mut config = profile::Config::load(&home.config())?.node;
|
| - |
let options = Options::from_env(&mut config)?;
|
| + |
let options = Options::from_env()?;
|
| |
|
| |
log::info!(target: "node", "Starting node..");
|
| |
log::info!(target: "node", "Version {} ({})", env!("CARGO_PKG_VERSION"), env!("GIT_HEAD"));
|