-
-
Notifications
You must be signed in to change notification settings - Fork 149
Open
Description
When resolving an address it is not set in the message
func TestTransportLayerClientRequestConnectionResolution(t *testing.T) {
for _, tran := range []string{"UDP"} {
t.Run(tran, func(t *testing.T) {
tp := NewTransportLayer(net.DefaultResolver, NewParser(), nil)
req := NewRequest(OPTIONS, Uri{Host: "localhost"})
req.AppendHeader(&ViaHeader{Host: "127.0.0.1", Port: 0, Params: NewParams()})
_, err := tp.ClientRequestConnection(context.TODO(), req)
require.NoError(t, err)
tp.Close()
require.Equal(t, "127.0.0.1:5060", req.Destination()) <-- This is set to localhost:5060 in the latest version
})
}
}
Uncommenting the line 406 in sip/transport_layer.go fixes the issue but not sure that is the correct solution.
if raddr.IP == nil {
if err := l.resolveAddr(ctx, network, host, req.Recipient.Scheme, &raddr); err != nil {
return nil, err
}
// Save destination in request to avoid repeated resolving
// This also solves problem where subsequent request like NON 2xx ACK can
// send on same destination without resolving again.
// req.SetDestination(raddr.String()) <-- Uncomment this line fixes the issue
}
Metadata
Metadata
Assignees
Labels
No labels