Skip to content

Commit 156a60b

Browse files
authored
Update sipgo, use ordered SIP params. (#621)
1 parent d0767e2 commit 156a60b

8 files changed

Lines changed: 18 additions & 19 deletions

File tree

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/livekit/protocol v1.45.1-0.20260310090700-2249c636c0bf
1717
github.com/livekit/psrpc v0.7.1
1818
github.com/livekit/server-sdk-go/v2 v2.11.4-0.20251016050252-63f7c8381817
19-
github.com/livekit/sipgo v0.13.2-0.20260119120547-800bcd1b7184
19+
github.com/livekit/sipgo v0.13.2-0.20260313133657-a878476450a7
2020
github.com/mjibson/go-dsp v0.0.0-20180508042940-11479a337f12
2121
github.com/ory/dockertest/v3 v3.12.0
2222
github.com/pion/rtp v1.8.23
@@ -71,7 +71,7 @@ require (
7171
github.com/docker/docker v28.3.3+incompatible // indirect
7272
github.com/docker/go-connections v0.5.0 // indirect
7373
github.com/docker/go-units v0.5.0 // indirect
74-
github.com/emiago/sipgo v1.1.0 // indirect
74+
github.com/emiago/sipgo v1.2.1 // indirect
7575
github.com/fsnotify/fsnotify v1.9.0 // indirect
7676
github.com/gammazero/deque v1.1.0 // indirect
7777
github.com/go-jose/go-jose/v3 v3.0.4 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj
5555
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
5656
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
5757
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
58-
github.com/emiago/sipgo v1.1.0 h1:ryr9DhoDercbyCmCtGiZD/uB1NY745DZpsUHfSbWWaI=
59-
github.com/emiago/sipgo v1.1.0/go.mod h1:DuwAxBZhKMqIzQFPGZb1MVAGU6Wuxj64oTOhd5dx/FY=
58+
github.com/emiago/sipgo v1.2.1 h1:5JTwogbe3yQFA3sjBVueN2Q4WTU350tGeBwPYT8HMv0=
59+
github.com/emiago/sipgo v1.2.1/go.mod h1:DuwAxBZhKMqIzQFPGZb1MVAGU6Wuxj64oTOhd5dx/FY=
6060
github.com/frostbyte73/core v0.1.1 h1:ChhJOR7bAKOCPbA+lqDLE2cGKlCG5JXsDvvQr4YaJIA=
6161
github.com/frostbyte73/core v0.1.1/go.mod h1:mhfOtR+xWAvwXiwor7jnqPMnu4fxbv1F2MwZ0BEpzZo=
6262
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
@@ -137,8 +137,8 @@ github.com/livekit/psrpc v0.7.1 h1:ms37az0QTD3UXIWuUC5D/SkmKOlRMVRsI261eBWu/Vw=
137137
github.com/livekit/psrpc v0.7.1/go.mod h1:bZ4iHFQptTkbPnB0LasvRNu/OBYXEu1NA6O5BMFo9kk=
138138
github.com/livekit/server-sdk-go/v2 v2.11.4-0.20251016050252-63f7c8381817 h1:y5YYe37lcGMOZMw4rvreljGjLj60eDSce/N6Asp7pw8=
139139
github.com/livekit/server-sdk-go/v2 v2.11.4-0.20251016050252-63f7c8381817/go.mod h1:xebvU/bXHEv2fA2F8yX8PsEBWxuYWo2+cyxFJHDmJRk=
140-
github.com/livekit/sipgo v0.13.2-0.20260119120547-800bcd1b7184 h1:0ZyiaySHM9s4CPwn2ZCTCO3Qhq5UotqbaMoEqOGBSE0=
141-
github.com/livekit/sipgo v0.13.2-0.20260119120547-800bcd1b7184/go.mod h1:d3KZtpAQCRVTNFRg4x33FOcBIU9m9tin2ozJoAHy1M0=
140+
github.com/livekit/sipgo v0.13.2-0.20260313133657-a878476450a7 h1:RZqrHeK2p7I1A5r89/3VxorsHWcdmXgfPzKHfp/JZ7c=
141+
github.com/livekit/sipgo v0.13.2-0.20260313133657-a878476450a7/go.mod h1:aDa6mbFktNzA1D917RhFlIB5IOfNBTmrwt+/lX960j0=
142142
github.com/mackerelio/go-osstat v0.2.5 h1:+MqTbZUhoIt4m8qzkVoXUJg1EuifwlAJSk4Yl2GXh+o=
143143
github.com/mackerelio/go-osstat v0.2.5/go.mod h1:atxwWF+POUZcdtR1wnsUcQxTytoHG4uhl2AKKzrOajY=
144144
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=

pkg/sip/inbound.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1671,7 +1671,7 @@ func (c *sipInbound) sendRinging() {
16711671

16721672
func (c *sipInbound) attachTag() {
16731673
// Set the SIP tag for following requests from us to remote (e.g. BYE).
1674-
c.to.Params["tag"] = string(c.id)
1674+
c.to.Params.Add("tag", string(c.id))
16751675
}
16761676

16771677
func (c *sipInbound) StartRinging() {

pkg/sip/inbound_process_invite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (it *InboundTest) NewInvite(t *testing.T, callID string, cseq uint32, offer
4444
Host: it.addr.String(),
4545
},
4646
Params: sip.HeaderParams{
47-
"tag": fromTag,
47+
{"tag", fromTag},
4848
},
4949
})
5050
inviteReq.AppendHeader(&sip.ToHeader{
@@ -163,5 +163,5 @@ func TestProcessInvite_Reinvite(t *testing.T) {
163163
resp3 := it.TransactionRequest(t, req3)
164164
require.Equal(t, sip.StatusCode(200), resp3.StatusCode, "200 OK")
165165
require.Equal(t, answer, string(resp3.Body()), "answer should be the same")
166-
require.NotEqual(t, resp2.To().Params["tag"], resp3.To().Params["tag"], "to tag should not be the same")
166+
require.NotEqual(t, resp2.To().Params.GetOr("tag", ""), resp3.To().Params.GetOr("tag", ""), "to tag should not be the same")
167167
}

pkg/sip/outbound_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ import (
2020
"testing"
2121
"time"
2222

23-
"github.com/livekit/sipgo/sip"
2423
"github.com/stretchr/testify/require"
24+
25+
"github.com/livekit/sipgo/sip"
2526
)
2627

2728
func TestOutboundRouteHeaderWithRecordRoute(t *testing.T) {
@@ -33,8 +34,8 @@ func TestOutboundRouteHeaderWithRecordRoute(t *testing.T) {
3334
// 4. Make sure the ACK doesn't carry over initial Route header..
3435

3536
// Plumbing
36-
initialRouteURI := sip.Uri{Host: "initial-header.com", UriParams: sip.HeaderParams{"lr": ""}}
37-
addedRouteURI := sip.Uri{Host: "added-header.com", UriParams: sip.HeaderParams{"lr": ""}}
37+
initialRouteURI := sip.Uri{Host: "initial-header.com", UriParams: sip.HeaderParams{{"lr", ""}}}
38+
addedRouteURI := sip.Uri{Host: "added-header.com", UriParams: sip.HeaderParams{{"lr", ""}}}
3839
initialRouteHeader := sip.RouteHeader{Address: initialRouteURI}
3940
addedRouteHeader := sip.RouteHeader{Address: addedRouteURI}
4041
client := NewOutboundTestClient(t, TestClientConfig{})

pkg/sip/service_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import (
1111

1212
"github.com/go-logr/logr"
1313
"github.com/icholy/digest"
14-
msdk "github.com/livekit/media-sdk"
1514
"github.com/stretchr/testify/require"
1615

16+
msdk "github.com/livekit/media-sdk"
17+
1718
"github.com/livekit/mediatransportutil/pkg/rtcconfig"
1819
"github.com/livekit/protocol/livekit"
1920
"github.com/livekit/protocol/logger"
@@ -899,7 +900,7 @@ func TestSameCallIDForAuthFlow(t *testing.T) {
899900
inviteFromHeader := sip.FromHeader{
900901
DisplayName: fromUser,
901902
Address: sip.Uri{User: fromUser, Host: sipServerAddress},
902-
Params: sip.NewParams().Add("tag", fromTag), // Key bit here
903+
Params: sip.HeaderParams{{"tag", fromTag}}, // Key bit here
903904
}
904905

905906
// Create first INVITE request (without auth)

pkg/sip/types.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,6 @@ func (u URI) GetURI() *sip.Uri {
166166
su.Port = int(port)
167167
}
168168
if u.Transport != "" {
169-
if su.UriParams == nil {
170-
su.UriParams = make(sip.HeaderParams)
171-
}
172169
su.UriParams.Add("transport", string(u.Transport))
173170
}
174171
return su
@@ -216,7 +213,7 @@ func GetLocalTagUAS(r *sip.Request) (LocalTag, error) {
216213
}
217214

218215
func getTagFrom(params sip.HeaderParams) (RemoteTag, bool) {
219-
tag, ok := params["tag"]
216+
tag, ok := params.Get("tag")
220217
if !ok {
221218
return "", false
222219
}

pkg/siptest/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ func (c *Client) Dial(ip string, host string, number string, headers map[string]
379379
}
380380

381381
func (c *Client) attemptInvite(ip, host, number string, offer []byte, authHeader string, headers map[string]string, callID string) (*sip.Request, *sip.Response, error) {
382-
uri := sip.Uri{User: number, Host: host, UriParams: make(sip.HeaderParams)}
382+
uri := sip.Uri{User: number, Host: host}
383383
uri.UriParams.Add("transport", "tcp")
384384
req := sip.NewRequest(sip.INVITE, uri)
385385

0 commit comments

Comments
 (0)