diff --git a/roles/translator/src/lib/proxy_config.rs b/roles/translator/src/lib/proxy_config.rs index d0a8357261..a00343f97c 100644 --- a/roles/translator/src/lib/proxy_config.rs +++ b/roles/translator/src/lib/proxy_config.rs @@ -4,7 +4,6 @@ use serde::Deserialize; #[derive(Debug, Deserialize, Clone)] pub struct ProxyConfig { pub upstream_address: String, - pub upstream_port: u16, pub upstream_authority_pubkey: Secp256k1PublicKey, pub downstream_address: String, pub downstream_port: u16, diff --git a/roles/translator/src/main.rs b/roles/translator/src/main.rs index 84acbdbbaa..6243bdb5b2 100644 --- a/roles/translator/src/main.rs +++ b/roles/translator/src/main.rs @@ -11,7 +11,7 @@ use roles_logic_sv2::utils::Mutex; use async_channel::{bounded, unbounded}; use futures::{select, FutureExt}; use std::{ - net::{IpAddr, SocketAddr}, + net::{IpAddr, SocketAddr, ToSocketAddrs}, str::FromStr, sync::Arc, }; @@ -78,11 +78,17 @@ async fn main() { ) = broadcast::channel(10); // Format `Upstream` connection address - let upstream_addr = SocketAddr::new( - IpAddr::from_str(&proxy_config.upstream_address) - .expect("Failed to parse upstream address!"), - proxy_config.upstream_port, - ); + let upstream_addr = proxy_config + .upstream_address + .to_socket_addrs() + .unwrap_or_else(|e| { + panic!( + "Invalid upstream address {}: {}", + proxy_config.upstream_address, e + ) + }) + .next() + .unwrap(); let diff_config = Arc::new(Mutex::new(proxy_config.upstream_difficulty_config.clone()));