Skip to content

Commit

Permalink
Set the contact header to the proper value in the REFER request
Browse files Browse the repository at this point in the history
  • Loading branch information
biglittlebigben committed Oct 8, 2024
1 parent 47feff7 commit b549ecc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pkg/sip/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,10 @@ func (c *sipInbound) transferCall(ctx context.Context, transferTo string) error
return psrpc.NewErrorf(psrpc.InvalidArgument, "no From URI in invite")
}

req := NewReferRequest(c.invite, c.inviteOk, transferTo)
// This will effectively redirect future SIP requests to this server instance (if host address is not LB).
contactHeader := &sip.ContactHeader{Address: sip.Uri{Host: c.s.signalingIp, Port: c.s.conf.SIPPort}}

req := NewReferRequest(c.invite, c.inviteOk, contactHeader, transferTo)
c.setCSeq(req)
c.swapSrcDst(req)

Expand Down
2 changes: 1 addition & 1 deletion pkg/sip/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ func (c *sipOutbound) transferCall(ctx context.Context, transferTo string) error
return psrpc.NewErrorf(psrpc.FailedPrecondition, "can't transfer hung up call")
}

req := NewReferRequest(c.invite, c.inviteOk, transferTo)
req := NewReferRequest(c.invite, c.inviteOk, &sip.ContactHeader{Address: c.from.Address}, transferTo)
c.setCSeq(req)
cseq, _ := req.CSeq()

Expand Down
4 changes: 3 additions & 1 deletion pkg/sip/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func sendAndACK(c Signaling, req *sip.Request) {
}
}

func NewReferRequest(inviteRequest *sip.Request, inviteResponse *sip.Response, referToUrl string) *sip.Request {
func NewReferRequest(inviteRequest *sip.Request, inviteResponse *sip.Response, contactHeader *sip.ContactHeader, referToUrl string) *sip.Request {
req := sip.NewRequest(sip.REFER, inviteRequest.Recipient)

req.SipVersion = inviteRequest.SipVersion
Expand Down Expand Up @@ -120,6 +120,8 @@ func NewReferRequest(inviteRequest *sip.Request, inviteResponse *sip.Response, r
sip.CopyHeaders("CSeq", inviteRequest, req)
}

req.AppendHeader(contactHeader)

cseq, _ := req.CSeq()
cseq.SeqNo = cseq.SeqNo + 1
cseq.MethodName = sip.REFER
Expand Down

0 comments on commit b549ecc

Please sign in to comment.