Keep server running if failed to create UdpAssociation

- Log error if UdpSocket::connect failed

ref #293
This commit is contained in:
zonyitoo
2020-09-03 13:04:52 +08:00
parent e88a536bd4
commit 5af929004e
5 changed files with 18 additions and 6 deletions

View File

@@ -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
})?;
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}