From 0f31580df5b0c4e508e79a2744aee2c5d3f18878 Mon Sep 17 00:00:00 2001 From: hechen-eng Date: Tue, 31 Mar 2026 16:45:56 -0700 Subject: [PATCH] TEL-459: fix potential port conflict between siptest.NewClient and runSIPServer --- pkg/siptest/client.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/siptest/client.go b/pkg/siptest/client.go index 6ae83c8c..20ac6438 100644 --- a/pkg/siptest/client.go +++ b/pkg/siptest/client.go @@ -88,9 +88,6 @@ func NewClient(id string, conf ClientConfig) (*Client, error) { conf.IP = localIP conf.Log.Debug("setting local address", "ip", localIP) } - if conf.Port == 0 { - conf.Port = 5060 + uint16(rand.Intn(1000)) - } if conf.Number == "" { conf.Number = "1000" } @@ -177,6 +174,8 @@ func NewClient(id string, conf ClientConfig) (*Client, error) { cli.Close() return nil, err } + // cli.conf.Port may be 0 if port was not specified, so we need to set it to the actual port. + cli.conf.Port = uint16(l.Addr().(*net.TCPAddr).Port) cli.sipLis = l go cli.sipServer.ServeTCP(l)