Skip to content

Commit 7042722

Browse files
committed
fix(#380): Fix reverse udp tunnel
Correctly set the correct destination in the udp connector
1 parent 5584972 commit 7042722

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/main.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ fn parse_local_bind(arg: &str) -> Result<(SocketAddr, &str), io::Error> {
444444
fn parse_tunnel_dest(remaining: &str) -> Result<(Host<String>, u16, BTreeMap<String, String>), io::Error> {
445445
use std::io::Error;
446446

447-
let Ok(remote) = Url::parse(&format!("fake://{}", remaining)) else {
447+
// Using http or else the URL lib don't try to fully parse the host into an IPv4/IPv6
448+
let Ok(remote) = Url::parse(&format!("https://{}", remaining)) else {
448449
return Err(Error::new(
449450
ErrorKind::InvalidInput,
450451
format!("cannot parse remote from {}", remaining),
@@ -867,8 +868,8 @@ async fn main() -> anyhow::Result<()> {
867868
port,
868869
};
869870
let udp_connector = UdpTunnelConnector::new(
870-
&remote.host,
871-
remote.port,
871+
&tunnel.remote.0,
872+
tunnel.remote.1,
872873
cfg.socket_so_mark,
873874
cfg.timeout_connect,
874875
&cfg.dns_resolver,
@@ -910,14 +911,14 @@ async fn main() -> anyhow::Result<()> {
910911
port,
911912
};
912913
let tcp_connector = TcpTunnelConnector::new(
913-
&remote.host,
914-
remote.port,
914+
&tunnel.remote.0,
915+
tunnel.remote.1,
915916
cfg.socket_so_mark,
916917
cfg.timeout_connect,
917918
&cfg.dns_resolver,
918919
);
919920

920-
if let Err(err) = client.run_reverse_tunnel(remote.clone(), tcp_connector).await {
921+
if let Err(err) = client.run_reverse_tunnel(remote, tcp_connector).await {
921922
error!("{:?}", err);
922923
}
923924
});

0 commit comments

Comments
 (0)