Skip to content

Commit

Permalink
fix: add option to use fixed port for BehaviorTest
Browse files Browse the repository at this point in the history
  • Loading branch information
muink committed Sep 8, 2023
1 parent 293c9ea commit fa3ef19
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion stun/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,14 @@ func (c *Client) BehaviorTest() (*NATBehavior, error) {
// create a connection and close it at the end.
conn := c.conn
if conn == nil {
conn, err = net.ListenUDP("udp", nil)
var laddr *net.UDPAddr
if c.localPort != 0 {
laddr, err = net.ResolveUDPAddr("udp", fmt.Sprintf(":%d", c.localPort))
if err != nil {
return nil, err
}
}
conn, err = net.ListenUDP("udp", laddr)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit fa3ef19

Please sign in to comment.