Skip to content

Commit

Permalink
UDP association socket shouldn't bind local_address
Browse files Browse the repository at this point in the history
ref #294
  • Loading branch information
zonyitoo committed Sep 15, 2020
1 parent 9ef4c29 commit 1d2f2b5
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/relay/udprelay/association.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,16 +636,8 @@ impl ServerAssociation {
mut response_tx: mpsc::Sender<(SocketAddr, BytesMut)>,
) -> io::Result<ServerAssociation> {
// Create a socket for receiving packets
let local_addr = match context.config().local_addr {
None => {
// Let system allocate an address for us
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 0)
}
Some(ref addr) => {
// Uses configured local address
addr.bind_addr(&context).await?
}
};
// Let system allocate an address for us (INADDR_ANY)
let local_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 0);
let remote_udp = create_udp_socket(&local_addr).await?;

let local_addr = remote_udp.local_addr().expect("could not determine port bound to");
Expand Down

0 comments on commit 1d2f2b5

Please sign in to comment.