Skip to content

Commit 03e962b

Browse files
authored
List LK call IDs in the samples. (#360)
1 parent 006c041 commit 03e962b

File tree

8 files changed

+27
-25
lines changed

8 files changed

+27
-25
lines changed

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/livekit/protocol v1.38.1-0.20250514155317-3ee266441614
1616
github.com/livekit/psrpc v0.6.1-0.20250511053145-465289d72c3c
1717
github.com/livekit/server-sdk-go/v2 v2.5.0
18-
github.com/livekit/sipgo v0.13.2-0.20250410120437-ca5b8ca7b53d
18+
github.com/livekit/sipgo v0.13.2-0.20250516144641-135461905e37
1919
github.com/mjibson/go-dsp v0.0.0-20180508042940-11479a337f12
2020
github.com/ory/dockertest/v3 v3.12.0
2121
github.com/pion/interceptor v0.1.37
@@ -125,7 +125,6 @@ require (
125125
go.uber.org/zap v1.27.0 // indirect
126126
go.uber.org/zap/exp v0.3.0 // indirect
127127
golang.org/x/crypto v0.35.0 // indirect
128-
golang.org/x/mod v0.24.0 // indirect
129128
golang.org/x/net v0.35.0 // indirect
130129
golang.org/x/sync v0.14.0 // indirect
131130
golang.org/x/sys v0.30.0 // indirect

go.sum

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,18 @@ github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
125125
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
126126
github.com/lithammer/shortuuid/v4 v4.2.0 h1:LMFOzVB3996a7b8aBuEXxqOBflbfPQAiVzkIcHO0h8c=
127127
github.com/lithammer/shortuuid/v4 v4.2.0/go.mod h1:D5noHZ2oFw/YaKCfGy0YxyE7M0wMbezmMjPdhyEFe6Y=
128-
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 h1:jm09419p0lqTkDaKb5iXdynYrzB84ErPPO4LbRASk58=
129-
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
130128
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731 h1:9x+U2HGLrSw5ATTo469PQPkqzdoU7be46ryiCDO3boc=
131129
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
132130
github.com/livekit/mediatransportutil v0.0.0-20241220010243-a2bdee945564 h1:GX7KF/V9ExmcfT/2Bdia8aROjkxrgx7WpyH7w9MB4J4=
133131
github.com/livekit/mediatransportutil v0.0.0-20241220010243-a2bdee945564/go.mod h1:36s+wwmU3O40IAhE+MjBWP3W71QRiEE9SfooSBvtBqY=
134132
github.com/livekit/protocol v1.38.1-0.20250514155317-3ee266441614 h1:BcC6Wn7l3TWyJTobffPsIEZzuMwM01r+tK4WHnS/5zA=
135133
github.com/livekit/protocol v1.38.1-0.20250514155317-3ee266441614/go.mod h1:F5GLzgMUFFFgm7ajoYLIEXxlZVnRNusV5Qlnok4dtlc=
136-
github.com/livekit/psrpc v0.6.1-0.20250205181828-a0beed2e4126 h1:fzuYpAQbCid7ySPpQWWePfQOWUrs8x6dJ0T3Wl07n+Y=
137-
github.com/livekit/psrpc v0.6.1-0.20250205181828-a0beed2e4126/go.mod h1:X5WtEZ7OnEs72Fi5/J+i0on3964F1aynQpCalcgMqRo=
138134
github.com/livekit/psrpc v0.6.1-0.20250511053145-465289d72c3c h1:WwEr0YBejYbKzk8LSaO9h8h0G9MnE7shyDu8yXQWmEc=
139135
github.com/livekit/psrpc v0.6.1-0.20250511053145-465289d72c3c/go.mod h1:kmD+AZPkWu0MaXIMv57jhNlbiSZZ/Jx4bzlxBDVmJes=
140136
github.com/livekit/server-sdk-go/v2 v2.5.0 h1:HCKm3f6PvefGp8emNC2mi9+9IXzBYrynuGbtUdp5u+w=
141137
github.com/livekit/server-sdk-go/v2 v2.5.0/go.mod h1:98/Sa+Wgb27ABwu0WYxLaMZaRfGljrrtoZDQ2xA4oVg=
142-
github.com/livekit/sipgo v0.13.2-0.20250410120437-ca5b8ca7b53d h1:x3JSKtsQpWt/fynro+s7MusrOqIcaGdCnuSXKGEajXc=
143-
github.com/livekit/sipgo v0.13.2-0.20250410120437-ca5b8ca7b53d/go.mod h1:nbNi0IsYn4tyY2ab7Rafvifty07miHYvgedPMKWbaI4=
138+
github.com/livekit/sipgo v0.13.2-0.20250516144641-135461905e37 h1:atAYhTvGvbObzMihqlpv/GJ/befGa4wPyxGT7Fdp2Vg=
139+
github.com/livekit/sipgo v0.13.2-0.20250516144641-135461905e37/go.mod h1:nbNi0IsYn4tyY2ab7Rafvifty07miHYvgedPMKWbaI4=
144140
github.com/mackerelio/go-osstat v0.2.5 h1:+MqTbZUhoIt4m8qzkVoXUJg1EuifwlAJSk4Yl2GXh+o=
145141
github.com/mackerelio/go-osstat v0.2.5/go.mod h1:atxwWF+POUZcdtR1wnsUcQxTytoHG4uhl2AKKzrOajY=
146142
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
@@ -295,8 +291,6 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
295291
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
296292
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
297293
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
298-
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
299-
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
300294
golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
301295
golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
302296
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI=
@@ -305,8 +299,6 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
305299
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
306300
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
307301
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
308-
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
309-
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
310302
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
311303
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
312304
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=

pkg/sip/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func (c *Client) Start(agent *sipgo.UserAgent, sc *ServiceConfig) error {
7979
if agent == nil {
8080
ua, err := sipgo.NewUA(
8181
sipgo.WithUserAgent(UserAgent),
82+
sipgo.WithUserAgentLogger(slog.New(logger.ToSlogHandler(c.log))),
8283
)
8384
if err != nil {
8485
return err

pkg/sip/inbound.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package sip
1717
import (
1818
"context"
1919
"fmt"
20+
"log/slog"
2021
"math"
2122
"net/netip"
2223
"slices"
@@ -122,7 +123,7 @@ func (s *Server) handleInviteAuth(log logger.Logger, req *sip.Request, tx sip.Se
122123
return true
123124
}
124125

125-
func (s *Server) onInvite(req *sip.Request, tx sip.ServerTransaction) {
126+
func (s *Server) onInvite(log *slog.Logger, req *sip.Request, tx sip.ServerTransaction) {
126127
// Error processed in defer
127128
_ = s.processInvite(req, tx)
128129
}
@@ -273,11 +274,11 @@ func (s *Server) processInvite(req *sip.Request, tx sip.ServerTransaction) (retE
273274
return call.handleInvite(call.ctx, req, r.TrunkID, s.conf)
274275
}
275276

276-
func (s *Server) onOptions(req *sip.Request, tx sip.ServerTransaction) {
277+
func (s *Server) onOptions(log *slog.Logger, req *sip.Request, tx sip.ServerTransaction) {
277278
_ = tx.Respond(sip.NewResponseFromRequest(req, 200, "OK", nil))
278279
}
279280

280-
func (s *Server) onBye(req *sip.Request, tx sip.ServerTransaction) {
281+
func (s *Server) onBye(log *slog.Logger, req *sip.Request, tx sip.ServerTransaction) {
281282
tag, err := getFromTag(req)
282283
if err != nil {
283284
_ = tx.Respond(sip.NewResponseFromRequest(req, 400, "", nil))
@@ -303,7 +304,7 @@ func (s *Server) onBye(req *sip.Request, tx sip.ServerTransaction) {
303304
}
304305
}
305306

306-
func (s *Server) onNotify(req *sip.Request, tx sip.ServerTransaction) {
307+
func (s *Server) onNotify(log *slog.Logger, req *sip.Request, tx sip.ServerTransaction) {
307308
tag, err := getFromTag(req)
308309
if err != nil {
309310
_ = tx.Respond(sip.NewResponseFromRequest(req, 400, "", nil))

pkg/sip/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ func (s *Server) Start(agent *sipgo.UserAgent, sc *ServiceConfig, unhandled Requ
242242
if agent == nil {
243243
ua, err := sipgo.NewUA(
244244
sipgo.WithUserAgent(UserAgent),
245+
sipgo.WithUserAgentLogger(slog.New(logger.ToSlogHandler(s.log))),
245246
)
246247
if err != nil {
247248
return err
@@ -264,7 +265,7 @@ func (s *Server) Start(agent *sipgo.UserAgent, sc *ServiceConfig, unhandled Requ
264265
s.sipUnhandled = unhandled
265266

266267
// Ignore ACKs
267-
s.sipSrv.OnAck(func(req *sip.Request, tx sip.ServerTransaction) {})
268+
s.sipSrv.OnAck(func(log *slog.Logger, req *sip.Request, tx sip.ServerTransaction) {})
268269
listenIP := s.conf.ListenIP
269270
if listenIP == "" {
270271
listenIP = "0.0.0.0"

pkg/sip/service.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package sip
1717
import (
1818
"context"
1919
"fmt"
20+
"log/slog"
2021
"net/netip"
2122
"strings"
2223
"sync"
@@ -133,7 +134,7 @@ func (s *Service) ActiveCalls() ActiveCalls {
133134
if v == nil || v.cc == nil {
134135
return "<nil>"
135136
}
136-
return v.cc.callID
137+
return string(v.cc.id)
137138
})
138139
st.Outbound = total
139140
st.SampleIDs = append(st.SampleIDs, samples...)
@@ -144,7 +145,7 @@ func (s *Service) ActiveCalls() ActiveCalls {
144145
if v == nil || v.cc == nil {
145146
return "<nil>"
146147
}
147-
return v.cc.callID
148+
return string(v.cc.id)
148149
})
149150
st.Inbound = total
150151
st.SampleIDs = append(st.SampleIDs, samples...)
@@ -185,6 +186,7 @@ func (s *Service) Start() error {
185186
// to pass even without forwarding rules on the firewall. ut it will inevitably fail later on follow-up requests like BYE.
186187
ua, err := sipgo.NewUA(
187188
sipgo.WithUserAgent(UserAgent),
189+
sipgo.WithUserAgentLogger(slog.New(logger.ToSlogHandler(s.log))),
188190
)
189191
if err != nil {
190192
return err

pkg/sip/service_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package sip
33
import (
44
"context"
55
"fmt"
6+
"log/slog"
67
"math/rand"
78
"testing"
89
"time"
@@ -88,12 +89,13 @@ func testInvite(t *testing.T, h Handler, hidden bool, from, to string, test func
8889
mon, err := stats.NewMonitor(&config.Config{MaxCpuUtilization: 0.9})
8990
require.NoError(t, err)
9091

92+
log := logger.NewTestLogger(t)
9193
s, err := NewService("", &config.Config{
9294
HideInboundPort: hidden,
9395
SIPPort: sipPort,
9496
SIPPortListen: sipPort,
9597
RTPPort: rtcconfig.PortRange{Start: testPortRTPMin, End: testPortRTPMax},
96-
}, mon, logger.GetLogger(), func(projectID string) rpc.IOInfoClient { return nil })
98+
}, mon, log, func(projectID string) rpc.IOInfoClient { return nil })
9799
require.NoError(t, err)
98100
require.NotNil(t, s)
99101
t.Cleanup(s.Stop)
@@ -102,7 +104,10 @@ func testInvite(t *testing.T, h Handler, hidden bool, from, to string, test func
102104

103105
require.NoError(t, s.Start())
104106

105-
sipUserAgent, err := sipgo.NewUA(sipgo.WithUserAgent(from))
107+
sipUserAgent, err := sipgo.NewUA(
108+
sipgo.WithUserAgent(from),
109+
sipgo.WithUserAgentLogger(slog.New(logger.ToSlogHandler(s.log))),
110+
)
106111
require.NoError(t, err)
107112

108113
sipClient, err := sipgo.NewClient(sipUserAgent)

pkg/siptest/client.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import (
3737
"github.com/icholy/digest"
3838
"github.com/pion/sdp/v3"
3939

40-
"github.com/livekit/sip/pkg/mixer"
4140
"github.com/livekit/sipgo"
4241
"github.com/livekit/sipgo/sip"
4342

@@ -49,6 +48,7 @@ import (
4948
"github.com/livekit/sip/pkg/media/rtp"
5049
lksdp "github.com/livekit/sip/pkg/media/sdp"
5150
webmm "github.com/livekit/sip/pkg/media/webm"
51+
"github.com/livekit/sip/pkg/mixer"
5252
)
5353

5454
type ClientConfig struct {
@@ -120,6 +120,7 @@ func NewClient(id string, conf ClientConfig) (*Client, error) {
120120

121121
ua, err := sipgo.NewUA(
122122
sipgo.WithUserAgent(conf.Number),
123+
sipgo.WithUserAgentLogger(cli.log),
123124
)
124125
if err != nil {
125126
cli.Close()
@@ -138,20 +139,20 @@ func NewClient(id string, conf ClientConfig) (*Client, error) {
138139
return nil, err
139140
}
140141

141-
cli.sipServer.OnBye(func(req *sip.Request, tx sip.ServerTransaction) {
142+
cli.sipServer.OnBye(func(log *slog.Logger, req *sip.Request, tx sip.ServerTransaction) {
142143
_ = tx.Respond(sip.NewResponseFromRequest(req, 200, "OK", nil))
143144
tx.Terminate()
144145
if conf.OnBye != nil {
145146
conf.OnBye()
146147
}
147148
})
148-
cli.sipServer.OnAck(func(req *sip.Request, tx sip.ServerTransaction) {
149+
cli.sipServer.OnAck(func(log *slog.Logger, req *sip.Request, tx sip.ServerTransaction) {
149150
select {
150151
case cli.ack <- struct{}{}:
151152
default:
152153
}
153154
})
154-
cli.sipServer.OnRefer(func(req *sip.Request, tx sip.ServerTransaction) {
155+
cli.sipServer.OnRefer(func(log *slog.Logger, req *sip.Request, tx sip.ServerTransaction) {
155156
if conf.OnRefer != nil {
156157
conf.OnRefer(req)
157158
}

0 commit comments

Comments
 (0)