Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/sip/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ func (c *Client) SetHandler(handler Handler) {
c.handler = handler
}

func (c *Client) ContactURI(tr Transport) URI {
return getContactURI(c.conf, c.sconf.SignalingIP, tr)
func (c *Client) ContactURI(tr Transport, user string) URI {
return getContactURI(c.conf, c.sconf.SignalingIP, tr, user)
}

func (c *Client) CreateSIPParticipant(ctx context.Context, req *rpc.InternalCreateSIPParticipantRequest) (*rpc.InternalCreateSIPParticipantResponse, error) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/sip/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ func (s *Server) processInvite(req *sip.Request, tx sip.ServerTransaction) (retE
var call *inboundCall

tr := transportFromReq(req)
cc := s.newInbound(LocalTag(callID), s.ContactURI(tr), req, tx, func(headers map[string]string) map[string]string {
user := toUserFromReq(req)
cc := s.newInbound(LocalTag(callID), s.ContactURI(tr, user), req, tx, func(headers map[string]string) map[string]string {
c := call
if c == nil || len(c.attrsToHdr) == 0 {
return headers
Expand Down
2 changes: 1 addition & 1 deletion pkg/sip/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (c *Client) newCall(ctx context.Context, conf *config.Config, log logger.Lo
}

tr := TransportFrom(sipConf.transport)
contact := c.ContactURI(tr)
contact := c.ContactURI(tr, sipConf.from)
if sipConf.host == "" {
sipConf.host = contact.GetHost()
}
Expand Down
12 changes: 11 additions & 1 deletion pkg/sip/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,21 @@ func transportPort(c *config.Config, t Transport) int {
return c.SIPPort
}

func getContactURI(c *config.Config, ip netip.Addr, t Transport) URI {
func toUserFromReq(req *sip.Request) string {
to := req.To()
if to == nil {
return ""
}

return to.Address.User
}

func getContactURI(c *config.Config, ip netip.Addr, t Transport, user string) URI {
return URI{
Host: c.SIPHostname,
Addr: netip.AddrPortFrom(ip, uint16(transportPort(c, t))),
Transport: t,
User: user,
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/sip/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ func (s *Server) SetHandler(handler Handler) {
s.handler = handler
}

func (s *Server) ContactURI(tr Transport) URI {
return getContactURI(s.conf, s.sconf.SignalingIP, tr)
func (s *Server) ContactURI(tr Transport, user string) URI {
return getContactURI(s.conf, s.sconf.SignalingIP, tr, user)
}

func (s *Server) startUDP(addr netip.AddrPort) error {
Expand Down
Loading