mirror of
https://github.com/romanz/electrs.git
synced 2024-11-19 01:43:29 +01:00
Merge branch 'dagurval-resolve-hostname'
This commit is contained in:
commit
ac577f9565
@ -4,6 +4,7 @@ use dirs::home_dir;
|
||||
use num_cpus;
|
||||
use std::fs;
|
||||
use std::net::SocketAddr;
|
||||
use std::net::ToSocketAddrs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
use stderrlog;
|
||||
@ -30,6 +31,14 @@ pub struct Config {
|
||||
pub server_banner: String,
|
||||
}
|
||||
|
||||
fn str_to_socketaddr(address: &str, what: &str) -> SocketAddr {
|
||||
address
|
||||
.to_socket_addrs()
|
||||
.expect(&format!("unable to resolve {} address", what))
|
||||
.next()
|
||||
.expect(&format!("no address found for {}", address))
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn from_args() -> Config {
|
||||
let m = App::new("Electrum Rust Server")
|
||||
@ -150,21 +159,21 @@ impl Config {
|
||||
Network::Regtest => 24224,
|
||||
};
|
||||
|
||||
let daemon_rpc_addr: SocketAddr = m
|
||||
.value_of("daemon_rpc_addr")
|
||||
.unwrap_or(&format!("127.0.0.1:{}", default_daemon_port))
|
||||
.parse()
|
||||
.expect("invalid Bitcoind RPC address");
|
||||
let electrum_rpc_addr: SocketAddr = m
|
||||
.value_of("electrum_rpc_addr")
|
||||
.unwrap_or(&format!("127.0.0.1:{}", default_electrum_port))
|
||||
.parse()
|
||||
.expect("invalid Electrum RPC address");
|
||||
let monitoring_addr: SocketAddr = m
|
||||
.value_of("monitoring_addr")
|
||||
.unwrap_or(&format!("127.0.0.1:{}", default_monitoring_port))
|
||||
.parse()
|
||||
.expect("invalid Prometheus monitoring address");
|
||||
let daemon_rpc_addr: SocketAddr = str_to_socketaddr(
|
||||
m.value_of("daemon_rpc_addr")
|
||||
.unwrap_or(&format!("localhost:{}", default_daemon_port)),
|
||||
"Bitcoin RPC",
|
||||
);
|
||||
let electrum_rpc_addr: SocketAddr = str_to_socketaddr(
|
||||
m.value_of("electrum_rpc_addr")
|
||||
.unwrap_or(&format!("localhost:{}", default_electrum_port)),
|
||||
"Electrum RPC",
|
||||
);
|
||||
let monitoring_addr: SocketAddr = str_to_socketaddr(
|
||||
m.value_of("monitoring_addr")
|
||||
.unwrap_or(&format!("localhost:{}", default_monitoring_port)),
|
||||
"Prometheus monitoring",
|
||||
);
|
||||
|
||||
let mut daemon_dir = m
|
||||
.value_of("daemon_dir")
|
||||
|
Loading…
Reference in New Issue
Block a user