Skip to content

Commit

Permalink
fix: udp listen connection should be based on remote
Browse files Browse the repository at this point in the history
  • Loading branch information
emiago committed Nov 25, 2024
1 parent 0cf3260 commit 4fd9a96
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sip/transport_udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ func (t *transportUDP) CreateConnection(ctx context.Context, laddr Addr, raddr A
func (t *transportUDP) createConnection(ctx context.Context, laddr Addr, raddr Addr, handler MessageHandler) (Connection, error) {
laddrStr := laddr.String()
lc := &net.ListenConfig{}
udpconn, err := lc.ListenPacket(ctx, "udp", laddrStr)

protocol := "udp"
if laddr.IP == nil && raddr.IP.To4() != nil {
// Use IPV4 if remote is same
protocol = "udp4"
}

udpconn, err := lc.ListenPacket(ctx, protocol, laddrStr)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 4fd9a96

Please sign in to comment.