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 Jun 1, 2024
1 parent 4361d7c commit e8278e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
1 change: 0 additions & 1 deletion roles/translator/src/lib/proxy_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 12 additions & 6 deletions roles/translator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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()));

Expand Down

0 comments on commit e8278e3

Please sign in to comment.