mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-10 07:08:05 -05:00
bin/ircd2: fix bug & clean up
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
## JSON-RPC listen URL
|
||||
#rpc_listen="127.0.0.1:8857"
|
||||
#rpc_listen="127.0.0.1:11055"
|
||||
|
||||
## IRC listen URL
|
||||
#irc_listen="127.0.0.1:8855"
|
||||
#irc_listen="127.0.0.1:11066"
|
||||
|
||||
## Sets Datastore Path
|
||||
#datastore="~/.config/ircd"
|
||||
@@ -13,7 +13,7 @@
|
||||
#inbound="127.0.0.1:11002"
|
||||
|
||||
## Connection slots
|
||||
#outbound_connections=0
|
||||
#outbound_connections=5
|
||||
|
||||
## P2P external address
|
||||
#external_addr="127.0.0.1:11002"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use async_std::net::{TcpListener, TcpStream};
|
||||
use std::{net::SocketAddr, path::PathBuf, sync::Arc};
|
||||
use std::{net::SocketAddr, sync::Arc};
|
||||
|
||||
use async_channel::Receiver;
|
||||
use async_executor::Executor;
|
||||
@@ -16,7 +16,7 @@ use darkfi::{
|
||||
rpc::rpcserver::{listen_and_serve, RpcServerConfig},
|
||||
util::{
|
||||
cli::{log_config, spawn_config},
|
||||
path::get_config_path,
|
||||
path::{expand_path, get_config_path},
|
||||
},
|
||||
Error, Result,
|
||||
};
|
||||
@@ -103,7 +103,7 @@ async fn realmain(settings: Args, executor: Arc<Executor<'_>>) -> Result<()> {
|
||||
let local_addr = listener.local_addr()?;
|
||||
info!("Listening on {}", local_addr);
|
||||
|
||||
let datastore_path = PathBuf::from(&settings.datastore);
|
||||
let datastore_path = expand_path(&settings.datastore)?;
|
||||
|
||||
let net_settings = settings.net;
|
||||
//
|
||||
|
||||
@@ -18,10 +18,10 @@ pub struct Args {
|
||||
#[structopt(long)]
|
||||
pub config: Option<String>,
|
||||
/// JSON-RPC listen URL
|
||||
#[structopt(long = "rpc", default_value = "127.0.0.1:8857")]
|
||||
#[structopt(long = "rpc", default_value = "127.0.0.1:11055")]
|
||||
pub rpc_listen: SocketAddr,
|
||||
/// IRC listen URL
|
||||
#[structopt(long = "irc", default_value = "127.0.0.1:8855")]
|
||||
#[structopt(long = "irc", default_value = "127.0.0.1:11066")]
|
||||
pub irc_listen: SocketAddr,
|
||||
/// Sets Datastore Path
|
||||
#[structopt(long, default_value = "~/.config/ircd")]
|
||||
|
||||
@@ -18,7 +18,7 @@ pub struct Args {
|
||||
#[structopt(long)]
|
||||
pub config: Option<String>,
|
||||
/// JSON-RPC listen URL
|
||||
#[structopt(long = "rpc", default_value = "127.0.0.1:8857")]
|
||||
#[structopt(long = "rpc", default_value = "127.0.0.1:11055")]
|
||||
pub rpc_listen: SocketAddr,
|
||||
/// Sets Datastore Path
|
||||
#[structopt(long, default_value = "~/.config/tau")]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
## JSON-RPC listen URL
|
||||
#rpc_listen="127.0.0.1:8857"
|
||||
#rpc_listen="127.0.0.1:11055"
|
||||
|
||||
## Sets Datastore Path
|
||||
#datastore="~/.config/tau"
|
||||
|
||||
@@ -41,7 +41,6 @@ impl Default for Settings {
|
||||
|
||||
/// Defines the network settings.
|
||||
#[derive(Clone, Debug, Deserialize, StructOpt, StructOptToml)]
|
||||
#[serde(default)]
|
||||
#[structopt()]
|
||||
pub struct SettingsOpt {
|
||||
/// P2P accept address
|
||||
@@ -49,43 +48,45 @@ pub struct SettingsOpt {
|
||||
pub inbound: Option<SocketAddr>,
|
||||
|
||||
/// Connection slots
|
||||
#[structopt(long = "slots", default_value = "0")]
|
||||
pub outbound_connections: u32,
|
||||
#[structopt(long = "slots")]
|
||||
pub outbound_connections: Option<u32>,
|
||||
|
||||
/// P2P external address
|
||||
#[structopt(long)]
|
||||
pub external_addr: Option<SocketAddr>,
|
||||
|
||||
/// Peer nodes to connect to
|
||||
#[serde(default)]
|
||||
#[structopt(long)]
|
||||
pub peers: Vec<SocketAddr>,
|
||||
|
||||
/// Seed nodes to connect to
|
||||
#[serde(default)]
|
||||
#[structopt(long)]
|
||||
pub seeds: Vec<SocketAddr>,
|
||||
|
||||
#[structopt(skip = 0 as u32)]
|
||||
pub manual_attempt_limit: u32,
|
||||
#[structopt(skip = 8 as u32)]
|
||||
pub seed_query_timeout_seconds: u32,
|
||||
#[structopt(skip = 10 as u32)]
|
||||
pub connect_timeout_seconds: u32,
|
||||
#[structopt(skip = 4 as u32)]
|
||||
pub channel_handshake_seconds: u32,
|
||||
#[structopt(skip = 10 as u32)]
|
||||
pub channel_heartbeat_seconds: u32,
|
||||
#[structopt(skip)]
|
||||
pub manual_attempt_limit: Option<u32>,
|
||||
#[structopt(skip)]
|
||||
pub seed_query_timeout_seconds: Option<u32>,
|
||||
#[structopt(skip)]
|
||||
pub connect_timeout_seconds: Option<u32>,
|
||||
#[structopt(skip)]
|
||||
pub channel_handshake_seconds: Option<u32>,
|
||||
#[structopt(skip)]
|
||||
pub channel_heartbeat_seconds: Option<u32>,
|
||||
}
|
||||
|
||||
impl Into<Settings> for SettingsOpt {
|
||||
fn into(self) -> Settings {
|
||||
Settings {
|
||||
inbound: self.inbound,
|
||||
outbound_connections: self.outbound_connections,
|
||||
manual_attempt_limit: self.manual_attempt_limit,
|
||||
seed_query_timeout_seconds: self.seed_query_timeout_seconds,
|
||||
connect_timeout_seconds: self.connect_timeout_seconds,
|
||||
channel_handshake_seconds: self.channel_handshake_seconds,
|
||||
channel_heartbeat_seconds: self.channel_heartbeat_seconds,
|
||||
outbound_connections: self.outbound_connections.unwrap_or(0),
|
||||
manual_attempt_limit: self.manual_attempt_limit.unwrap_or(0),
|
||||
seed_query_timeout_seconds: self.seed_query_timeout_seconds.unwrap_or(8),
|
||||
connect_timeout_seconds: self.connect_timeout_seconds.unwrap_or(10),
|
||||
channel_handshake_seconds: self.channel_handshake_seconds.unwrap_or(4),
|
||||
channel_heartbeat_seconds: self.channel_heartbeat_seconds.unwrap_or(10),
|
||||
external_addr: self.external_addr,
|
||||
peers: self.peers,
|
||||
seeds: self.seeds,
|
||||
|
||||
Reference in New Issue
Block a user