Skip to content

Commit 9118c31

Browse files
committed
Updating changes the followed this PR
1 parent 73a4029 commit 9118c31

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

pkg/sip/inbound.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ import (
4040
"github.com/livekit/protocol/livekit"
4141
"github.com/livekit/protocol/logger"
4242
"github.com/livekit/protocol/rpc"
43-
"github.com/livekit/protocol/utils"
4443
lksip "github.com/livekit/protocol/sip"
4544
"github.com/livekit/protocol/tracer"
45+
"github.com/livekit/protocol/utils"
4646
"github.com/livekit/protocol/utils/traceid"
4747
"github.com/livekit/psrpc"
4848
lksdk "github.com/livekit/server-sdk-go/v2"
@@ -201,12 +201,6 @@ func (s *Server) handleInviteAuth(tid traceid.ID, log logger.Logger, req *sip.Re
201201
_ = tx.Respond(sip.NewResponseFromRequest(req, 100, "Processing", nil))
202202
}
203203

204-
// Extract SIP Call ID for tracking in-progress invites
205-
sipCallID := ""
206-
if h := req.CallID(); h != nil {
207-
sipCallID = h.Value()
208-
}
209-
210204
h := req.GetHeader("Proxy-Authorization")
211205
if h == nil {
212206
inviteState.challenge = digest.Challenge{
@@ -333,12 +327,10 @@ func (s *Server) processInvite(req *sip.Request, tx sip.ServerTransaction) (retE
333327
return psrpc.NewError(psrpc.MalformedRequest, errors.Wrap(err, "cannot parse source IP"))
334328
}
335329
sipCallID := legCallIDFromReq(req)
336-
tid := traceid.FromGUID(callID)
337330
tr := callTransportFromReq(req)
338331
legTr := legTransportFromReq(req)
339332
log := s.log.WithValues(
340333
"sipCallID", sipCallID,
341-
"traceID", tid.String(),
342334
"fromIP", src.Addr(),
343335
"toIP", req.Destination(),
344336
"transport", tr,
@@ -390,19 +382,21 @@ func (s *Server) processInvite(req *sip.Request, tx sip.ServerTransaction) (retE
390382
inviteProgress.lkCallID = callID
391383
}
392384
cc.id = LocalTag(callID)
385+
tid := traceid.FromGUID(sipCallID)
393386

394387
log = log.WithValues("callID", callID)
388+
log = log.WithValues("traceID", tid.String())
395389
cc.log = log
396390
log.Infow("processing invite")
397391

398392
ctx, span := tracer.Start(ctx, "Server.onInvite")
399393
defer span.End()
400394

401395
s.cmu.RLock()
402-
existing := s.byCallID[cc.SIPCallID()]
396+
existing := s.byCallID[sipCallID]
403397
s.cmu.RUnlock()
404398
if existing != nil && existing.cc.InviteCSeq() < cc.InviteCSeq() {
405-
log.Infow("accepting reinvite", "sipCallID", existing.cc.ID(), "content-type", req.ContentType(), "content-length", req.ContentLength())
399+
log.Infow("accepting reinvite", "content-type", req.ContentType(), "content-length", req.ContentLength())
406400
existing.log().Infow("reinvite", "content-type", req.ContentType(), "content-length", req.ContentLength(), "cseq", cc.InviteCSeq())
407401
cc.AcceptAsKeepAlive(existing.cc.OwnSDP())
408402
return nil
@@ -429,7 +423,7 @@ func (s *Server) processInvite(req *sip.Request, tx sip.ServerTransaction) (retE
429423

430424
callInfo := &rpc.SIPCall{
431425
LkCallId: callID,
432-
SipCallId: cc.SIPCallID(),
426+
SipCallId: sipCallID,
433427
SourceIp: src.Addr().String(),
434428
Address: ToSIPUri("", cc.Address()),
435429
From: ToSIPUri("", from),
@@ -500,15 +494,15 @@ func (s *Server) processInvite(req *sip.Request, tx sip.ServerTransaction) (retE
500494
// We will send password request anyway, so might as well signal that the progress is made.
501495
cc.Processing()
502496
}
503-
s.getCallInfo(cc.SIPCallID()).countInvite(log, req)
497+
s.getCallInfo(sipCallID).countInvite(log, req)
504498
if !s.handleInviteAuth(tid, log, req, tx, from.User, r.Username, r.Password, inviteProgress) {
505499
cmon.InviteErrorShort("unauthorized")
506500
// handleInviteAuth will generate the SIP Response as needed
507501
return psrpc.NewErrorf(psrpc.PermissionDenied, "invalid credentials were provided")
508502
}
509503
// ok
510504
case AuthAccept:
511-
s.getCallInfo(cc.SIPCallID()).countInvite(log, req)
505+
s.getCallInfo(sipCallID).countInvite(log, req)
512506
// ok
513507
}
514508

0 commit comments

Comments
 (0)