Skip to content

Commit

Permalink
WiP
Browse files Browse the repository at this point in the history
  • Loading branch information
biglittlebigben committed Oct 31, 2024
1 parent 994e0d4 commit 99a33fd
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/sip/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -1064,12 +1064,29 @@ func (c *sipInbound) swapSrcDst(req *sip.Request) {
req.AppendHeader((*sip.FromHeader)(c.to))
req.RemoveHeader("To")
req.AppendHeader((*sip.ToHeader)(c.from))
req.RemoveHeader("Via")
req.PrependHeader(c.generateViaHeader(req))
if route, ok := req.RecordRoute(); ok {
req.RemoveHeader("Record-Route")
req.AppendHeader(&sip.RouteHeader{Address: route.Address})
}
}

func (c *sipInbound) generateViaHeader(req *sip.Request) *sip.ViaHeader {
newvia := &sip.ViaHeader{
ProtocolName: "SIP",
ProtocolVersion: "2.0",
Transport: req.Transport(),
Host: c.s.sconf.SignalingIPLocal.String(), // This can be rewritten by transport layer
Port: c.s.conf.SIPPortListen, // This can be rewritten by transport layer
Params: sip.NewParams(),
}
// NOTE: Consider lenght of branch configurable
newvia.Params.Add("branch", sip.GenerateBranchN(16))

return newvia
}

func (c *sipInbound) setCSeq(req *sip.Request) {
setCSeq(req, c.nextRequestCSeq)

Expand Down

0 comments on commit 99a33fd

Please sign in to comment.