Skip to content

Commit

Permalink
tproxy: allow to specify hostname for upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
nikicat committed Sep 1, 2024
1 parent 8e83f81 commit 1f3d83a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions roles/translator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use proxy_config::ProxyConfig;
use rand::Rng;
use roles_logic_sv2::utils::Mutex;
use std::{
net::{IpAddr, SocketAddr},
net::{IpAddr, SocketAddr, ToSocketAddrs},
str::FromStr,
sync::Arc,
};
Expand Down Expand Up @@ -185,11 +185,19 @@ async fn start<'a>(
let (tx_sv2_set_new_prev_hash, rx_sv2_set_new_prev_hash) = bounded(10);

// Format `Upstream` connection address
let upstream_addr = SocketAddr::new(
IpAddr::from_str(&proxy_config.upstream_address)
.expect("Failed to parse upstream address!"),
let upstream_addr = (
proxy_config.upstream_address.as_str(),
proxy_config.upstream_port,
);
)
.to_socket_addrs()
.unwrap_or_else(|e| {
panic!(
"Invalid upstream address {}:{}: {}",
proxy_config.upstream_address, proxy_config.upstream_port, e
)
})
.next()
.unwrap();

let diff_config = Arc::new(Mutex::new(proxy_config.upstream_difficulty_config.clone()));
let task_collector_upstream = task_collector.clone();
Expand Down

0 comments on commit 1f3d83a

Please sign in to comment.