Skip to content

Commit

Permalink
Keep server running if failed to create UdpAssociation
Browse files Browse the repository at this point in the history
- Log error if UdpSocket::connect failed

ref #293
  • Loading branch information
zonyitoo committed Sep 3, 2020
1 parent e88a536 commit 5af9290
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
20 changes: 18 additions & 2 deletions src/relay/udprelay/association.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,26 @@ impl ProxyAssociation {
async fn connect_remote(context: &Context, svr_cfg: &ServerConfig, remote_udp: &UdpSocket) -> io::Result<()> {
match svr_cfg.addr() {
ServerAddr::SocketAddr(ref remote_addr) => {
remote_udp.connect(remote_addr).await?;
let res = remote_udp.connect(remote_addr).await;
if let Err(ref err) = res {
error!(
"UDP association UdpSocket::connect failed, addr: {}, err: {}",
remote_addr, err
);
}
res?;
}
ServerAddr::DomainName(ref dname, port) => {
lookup_then!(context, dname, *port, |addr| { remote_udp.connect(&addr).await })?;
lookup_then!(context, dname, *port, |addr| {
let res = remote_udp.connect(&addr).await;
if let Err(ref err) = res {
error!(
"UDP association UdpSocket::connect failed, addr: {}:{} (resolved: {}), err: {}",
dname, port, addr, err
);
}
res
})?;
}
}

Expand Down
1 change: 0 additions & 1 deletion src/relay/udprelay/redir_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ pub async fn run(context: SharedContext) -> io::Result<()> {

if let Err(err) = res {
error!("failed to create UDP association, {}", err);
return Err(err);
}
}
}
1 change: 0 additions & 1 deletion src/relay/udprelay/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ async fn listen(context: SharedContext, flow_stat: SharedServerFlowStatistic, sv

if let Err(err) = res {
error!("failed to create UDP association, {}", err);
return Err(err);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/relay/udprelay/socks5_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ pub async fn run(context: SharedContext) -> io::Result<()> {

if let Err(err) = res {
error!("failed to create UDP association, {}", err);
return Err(err);
}
}
}
1 change: 0 additions & 1 deletion src/relay/udprelay/tunnel_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ pub async fn run(context: SharedContext) -> io::Result<()> {

if let Err(err) = res {
error!("failed to create UDP association, {}", err);
return Err(err);
}
}
}

0 comments on commit 5af9290

Please sign in to comment.