UDP associate

This commit is contained in:
ssrlive 2023-08-11 19:18:18 +08:00
parent 46ca342aba
commit da87fa8d5a
3 changed files with 34 additions and 6 deletions

View file

@ -224,7 +224,9 @@ impl SocksProxyImpl {
return Err(format!("SOCKS connection failed: {}", response.reply).into());
}
if self.command == protocol::Command::UdpAssociate {
self.udp_associate = Some(SocketAddr::try_from(response.address)?);
self.udp_associate = Some(SocketAddr::try_from(&response.address)?);
assert!(self.data_buf.is_empty());
log::debug!("UDP associate: {}", response.address);
}
self.server_outbuf.append(&mut self.data_buf);
@ -326,6 +328,10 @@ impl TcpProxy for SocksProxyImpl {
fn reset_connection(&self) -> bool {
false
}
fn get_udp_associate(&self) -> Option<SocketAddr> {
self.udp_associate
}
}
pub(crate) struct SocksProxyManager {