fix(#380): Fix reverse udp tunnel

Correctly set the correct destination in the udp connector
This commit is contained in:
Σrebe - Romain GERARD 2024-12-11 15:59:13 +01:00
parent 5584972c46
commit 70427227b1
No known key found for this signature in database
GPG key ID: 7A42B4B97E0332F4

View file

@ -444,7 +444,8 @@ fn parse_local_bind(arg: &str) -> Result<(SocketAddr, &str), io::Error> {
fn parse_tunnel_dest(remaining: &str) -> Result<(Host<String>, u16, BTreeMap<String, String>), io::Error> { fn parse_tunnel_dest(remaining: &str) -> Result<(Host<String>, u16, BTreeMap<String, String>), io::Error> {
use std::io::Error; use std::io::Error;
let Ok(remote) = Url::parse(&format!("fake://{}", remaining)) else { // Using http or else the URL lib don't try to fully parse the host into an IPv4/IPv6
let Ok(remote) = Url::parse(&format!("https://{}", remaining)) else {
return Err(Error::new( return Err(Error::new(
ErrorKind::InvalidInput, ErrorKind::InvalidInput,
format!("cannot parse remote from {}", remaining), format!("cannot parse remote from {}", remaining),
@ -867,8 +868,8 @@ async fn main() -> anyhow::Result<()> {
port, port,
}; };
let udp_connector = UdpTunnelConnector::new( let udp_connector = UdpTunnelConnector::new(
&remote.host, &tunnel.remote.0,
remote.port, tunnel.remote.1,
cfg.socket_so_mark, cfg.socket_so_mark,
cfg.timeout_connect, cfg.timeout_connect,
&cfg.dns_resolver, &cfg.dns_resolver,
@ -910,14 +911,14 @@ async fn main() -> anyhow::Result<()> {
port, port,
}; };
let tcp_connector = TcpTunnelConnector::new( let tcp_connector = TcpTunnelConnector::new(
&remote.host, &tunnel.remote.0,
remote.port, tunnel.remote.1,
cfg.socket_so_mark, cfg.socket_so_mark,
cfg.timeout_connect, cfg.timeout_connect,
&cfg.dns_resolver, &cfg.dns_resolver,
); );
if let Err(err) = client.run_reverse_tunnel(remote.clone(), tcp_connector).await { if let Err(err) = client.run_reverse_tunnel(remote, tcp_connector).await {
error!("{:?}", err); error!("{:?}", err);
} }
}); });