Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ libc = "0.2.81"
log = "0.4.11"
socket2 = { version = "0.4", features = ["all"] }
num_cpus = "1.12.0"
memchr = "2.4.1"
page_size = "0.4.2"
prometheus = "0.13"
proxy-protocol = { version = "0.5", features = ["always_exhaustive"] }
rayon = "1.5.0"
rocksdb = "0.21.0"
serde = "1.0.118"
Expand All @@ -71,9 +73,13 @@ tempfile = "3.0"

[profile.release]
lto = true
panic = 'abort'
panic = 'unwind' # This is default, but required, so explicitly writing it
codegen-units = 1

[patch.crates-io.electrum-client]
git = "https://github.com/Blockstream/rust-electrum-client"
rev = "d3792352992a539afffbe11501d1aff9fd5b919d" # add-peer branch

[patch.crates-io.proxy-protocol]
git = "https://github.com/junderw/proxy-protocol"
rev = "5f5431ecdae75c7e8aba0f7aebcfc2e0102b70dc" # fix/eof-panics branch
9 changes: 9 additions & 0 deletions src/bin/electrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ fn run_server(config: Arc<Config>) -> Result<()> {
);
}

if std::env::var("ELECTRS_PERIODIC_THREAD_LOGGER").is_ok() {
electrs::util::spawn_thread("periodic_thread_logger", || loop {
electrs::util::with_spawned_threads(|threads| {
debug!("THREADS: {:?}", threads);
});
std::thread::sleep(std::time::Duration::from_millis(5000));
});
}

loop {
if let Err(err) = signal.wait(Duration::from_millis(config.main_loop_delay), true) {
info!("stopping server: {}", err);
Expand Down
31 changes: 31 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub struct Config {
pub daemon_rpc_addr: SocketAddr,
pub cookie: Option<String>,
pub electrum_rpc_addr: SocketAddr,
pub electrum_proxy_depth: usize,
pub rest_proxy_depth: usize,
pub http_addr: SocketAddr,
pub http_socket_file: Option<PathBuf>,
pub rpc_socket_file: Option<PathBuf>,
Expand Down Expand Up @@ -150,6 +152,23 @@ impl Config {
.help("Electrum server JSONRPC 'addr:port' to listen on (default: '127.0.0.1:50001' for mainnet, '127.0.0.1:60001' for testnet and '127.0.0.1:60401' for regtest)")
.takes_value(true),
)
.arg(
Arg::with_name("electrum_proxy_depth")
.long("electrum-proxy-depth")
.help("Electrum server's PROXY protocol header depth. \
ie. a value of 2 means the 2nd closest hop's PROXY header \
will be used to find the source IP. A value of 0 means all \
IPs are ignored. (default: 0)")
.takes_value(true),
)
.arg(
Arg::with_name("rest_proxy_depth")
.long("rest-proxy-depth")
.help("REST server's X-Forwarded-For IP address depth. \
ie. a value of 2 means the 2nd IP address in the header(s) is used. \
(default: 0)")
.takes_value(true),
)
.arg(
Arg::with_name("http_addr")
.long("http-addr")
Expand Down Expand Up @@ -440,6 +459,16 @@ impl Config {
.unwrap_or(&format!("127.0.0.1:{}", default_electrum_port)),
"Electrum RPC",
);
let electrum_proxy_depth = m
.value_of("electrum_proxy_depth")
.unwrap_or("0")
.parse::<usize>()
.expect("invalid electrum_proxy_depth");
let rest_proxy_depth = m
.value_of("rest_proxy_depth")
.unwrap_or("0")
.parse::<usize>()
.expect("invalid rest_proxy_depth");
let http_addr: SocketAddr = str_to_socketaddr(
m.value_of("http_addr")
.unwrap_or(&format!("127.0.0.1:{}", default_http_port)),
Expand Down Expand Up @@ -515,6 +544,8 @@ impl Config {
cookie,
utxos_limit: value_t_or_exit!(m, "utxos_limit", usize),
electrum_rpc_addr,
electrum_proxy_depth,
rest_proxy_depth,
electrum_txs_limit: value_t_or_exit!(m, "electrum_txs_limit", usize),
electrum_banner,
http_addr,
Expand Down
Loading