Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
OpenSIPs assumes when calling loose_route that if the request domain is one of its own domains that when calling loose_route it assumes the path back to itself came through a strict route and regardless of whether the last Route header is an loose router or not it replaces the request URI with that Route header. This is correct behaviour if the server does put itself in the Route path as a strict router according to this RFC https://www.rfc-editor.org/rfc/rfc3261.html#section-16.4
The problem becomes when you don't do that and the request domain is just the Contact domain and in the scenario this fixes it would be where OpenSIPs does a loopback through a proxy that puts itself as a loose router between the OpenSIPs instance.
OpenSIPs advertised contact domain of my.opensips.com -> other proxy -> Back to OpenSIPs, the Contact header will have the same domain between both sides of the call and the Route header ensures sequentials go through that other proxy. Instead OpenSIPs on sequential will match the request domain to itself, assume a strict route, replace the request domain with the other proxies Route header and route using that and the other proxy could not get the request back to OpenSIPs.
This adds a flag for the loose_route function which allows us to specify to loose route when matching ourselves.