diff --git a/.gitignore b/.gitignore index de0ccc5..ffb1afc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ certs # Binaries for programs and plugins +.idea *.exe *.exe~ *.dll diff --git a/pkg/session/session.go b/pkg/session/session.go index 2cb88f4..ca2990f 100644 --- a/pkg/session/session.go +++ b/pkg/session/session.go @@ -241,10 +241,9 @@ func (s *Session) ReInvite() { } //Bye send Bye request. -func (s *Session) Bye() { - method := sip.BYE - req := s.makeRequest(s.uaType, method, sip.MessageID(s.callID), s.request, s.response) - s.sendRequest(req) +func (s *Session) Bye() (sip.Response, error) { + req := s.makeRequest(s.uaType, sip.BYE, sip.MessageID(s.callID), s.request, s.response) + return s.sendRequest(req) } func (s *Session) sendRequest(req sip.Request) (sip.Response, error) { @@ -363,6 +362,8 @@ func (s *Session) Provisional(statusCode sip.StatusCode, reason string) { } func (s *Session) makeRequest(uaType string, method sip.RequestMethod, msgID sip.MessageID, inviteRequest sip.Request, inviteResponse sip.Response) sip.Request { + var rh *sip.RouteHeader + newRequest := sip.NewRequest( msgID, method, @@ -385,6 +386,15 @@ func (s *Session) makeRequest(uaType string, method sip.RequestMethod, msgID sip newRequest.AppendHeader(s.contact) if uaType == "UAC" { + for _, header := range s.response.Headers() { + if header.Name() == "Record-Route" { + h := header.(*sip.RecordRouteHeader) + rh = &sip.RouteHeader{ + Addresses: h.Addresses, + } + } + } + newRequest.AppendHeader(rh) if len(inviteRequest.GetHeaders("Route")) > 0 { sip.CopyHeaders("Route", inviteRequest, newRequest) }