@@ -30,7 +30,7 @@ import (
3030
3131 msdk "github.com/livekit/media-sdk"
3232 "github.com/livekit/protocol/rpc"
33- uuid "github.com/satori/go.uuid "
33+ "github.com/livekit/protocol/utils "
3434
3535 "github.com/frostbyte73/core"
3636 "github.com/icholy/digest"
@@ -138,7 +138,11 @@ func (s *Server) getCallInfo(id string) *inboundCallInfo {
138138}
139139
140140func (s * Server ) getInvite (sipCallID , toTag , fromTag string ) * inProgressInvite {
141- key := fmt .Sprintf ("%s:%s:%s" , sipCallID , toTag , fromTag )
141+ key := dialogKey {
142+ sipCallID : sipCallID ,
143+ toTag : toTag ,
144+ fromTag : fromTag ,
145+ }
142146 s .imu .Lock ()
143147 defer s .imu .Unlock ()
144148 is , ok := s .inProgressInvites [key ]
@@ -325,6 +329,7 @@ func (s *Server) processInvite(req *sip.Request, tx sip.ServerTransaction) (retE
325329 log = LoggerWithHeaders (log , cc )
326330
327331 if err := cc .ValidateInvite (); err != nil {
332+ log .Errorw ("invalid invite" , err )
328333 if s .conf .HideInboundPort {
329334 cc .Drop ()
330335 } else {
@@ -335,13 +340,16 @@ func (s *Server) processInvite(req *sip.Request, tx sip.ServerTransaction) (retE
335340
336341 // Establish ID
337342 fromTag , _ := req .From ().Params .Get ("tag" ) // always exists, via ValidateInvite() check
338- toTag , ok := req .To ().Params .Get ("tag" ) // To() always exists, via ValidateInvite() check
343+ toParams := req .To ().Params // To() always exists, via ValidateInvite() check
344+ if toParams == nil {
345+ toParams = sip .NewParams ()
346+ req .To ().Params = toParams
347+ }
348+ toTag , ok := toParams .Get ("tag" )
339349 if ! ok {
340350 // No to-tag on the invite means we need to generate one per RFC 3261 section 12.
341351 // Generate a new to-tag early, to make sure both INVITES have the same ID.
342- uuid , _ := uuid .NewV4 () // Same as NewResponseFromRequest in sipgo
343- toTag = uuid .String ()
344- req .To ().Params .Add ("tag" , toTag )
352+ toParams .Add ("tag" , utils .NewGuid ("" ))
345353 }
346354 inviteProgress := s .getInvite (sipCallID , toTag , fromTag )
347355 callID := inviteProgress .lkCallID
0 commit comments