Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] loose_route() can not match pre-loaded route set setted by add_path_received() #1756

Closed
tangshiixang opened this issue Jul 9, 2019 · 7 comments
Assignees

Comments

@tangshiixang
Copy link

tangshiixang commented Jul 9, 2019

My opensips version is 3.0, information related transports in config file(X.X.X.X is public ip):
auto_aliases=no
alias=tcp:192.168.1.2:5060
alias=udp:192.168.1.2:5060
alias=tls:192.168.1.2:5061
alias=tls:192.168.1.2:5065
alias=tls:X.X.X.X:5061
listen=udp:192.168.1.2:5060
listen=tcp:192.168.1.2:5060
listen=tls:192.168.1.2:5061 as X.X.X.X:5061
listen=tls:192.168.1.2:5065

The part of processing message is:
INVITE sip:1000@112.31.212.45:36227;transport=TLS;ob SIP/2.0
Via: SIP/2.0/TLS 192.168.1.2:45061;rport;branch=z9hG4bK75F4ygDaQ0XZr
Route: sip:opensips@192.168.1.2:5065;transport=tls;lr
Max-Forwards: 70
From: "" sip:0000000000@X.X.X.X;tag=QgHaKZBQZ9cre
To: sip:1000@112.31.212.45:36227;transport=TLS;ob
Call-ID: 4e6e0be6-1c95-1238-829a-b8ca3a62ce44
CSeq: 6766126 INVITE
Contact: sip:mod_sofia@192.168.1.2:45061;transport=tls

the key log:
Jul 9 10:37:16 [34888] DBG:sipmsgops:has_totag: no totag
Jul 9 10:37:16 [34888] DBG:core:parse_headers: flags=78
Jul 9 10:37:16 [34888] DBG:core:get_hdr_field: cseq : <6766126>
Jul 9 10:37:16 [34888] DBG:tm:t_lookup_request: start searching: hash=2668, isACK=0
Jul 9 10:37:16 [34888] DBG:tm:matching_3261: RFC3261 transaction matching failed
Jul 9 10:37:16 [34888] DBG:tm:t_lookup_request: no transaction found
Jul 9 10:37:16 [34888] DBG:core:parse_headers: flags=200
Jul 9 10:37:16 [34888] DBG:core:parse_params: Parsing params for:[transport=tls;lr]
Jul 9 10:37:16 [34888] DBG:rr:is_preloaded: Yes
Jul 9 10:37:16 [34888] DBG:core:grep_sock_info_ext: proto: 1
Jul 9 10:37:16 [34888] DBG:core:grep_sock_info_ext: checking if host==us: 11==11 && [192.168.1.2] == [192.168.1.2]
Jul 9 10:37:16 [34888] DBG:core:grep_sock_info_ext: checking if port 5060 matches port 5065
Jul 9 10:37:16 [34888] DBG:core:check_self: host != me
Jul 9 10:37:16 [34888] DBG:rr:after_loose: Topmost URI is NOT myself
Jul 9 10:37:16 [34888] DBG:rr:after_loose: URI to be processed: 'sip:opensips@192.168.1.2:5065'
Jul 9 10:37:16 [34888] DBG:rr:after_loose: Next URI is a strict router
Jul 9 10:37:16 [34888] DBG:core:parse_headers: flags=ffffffffffffffff
Jul 9 10:37:16 [34888] DBG:core:get_hdr_field: content_length=740
Jul 9 10:37:16 [34888] DBG:core:get_hdr_field: found end of header
Jul 9 10:37:16 [34888] DBG:rr:save_ruri: New header: 'Route: sip:1000@112.31.212.45:36227;transport=TLS;ob

I think the problem is that in the grep_sock_info_ext() function, the protocol is taken as udp rather than tls. Did I configure something wrong?

@bogdan-iancu
Copy link
Member

bogdan-iancu commented Jul 9, 2019

@tangshiixang , I agree, according to the logs, it seems that OpenSIPS is trying to search for an UDP listener, not for a TLS one.
Is this
Jul 9 10:37:16 [34888] DBG:core:grep_sock_info_ext: proto: 1
added by you? as I do not find it public code.

And this is happening because the Route hdr is malformed. In this format:
Route: sip:opensips@192.168.1.2:5065;transport=tls;lr

the transport and lr params are header params, not URI params.
The correct format should be:
Route: <sip:opensips@192.168.1.2:5065;transport=tls;lr>

@bogdan-iancu bogdan-iancu self-assigned this Jul 9, 2019
@tangshiixang
Copy link
Author

@bogdan-iancu yes, I added the log. This is freeswitch bug(Someone has reported this problem, but it has not been fixed yet.). Can I use some functions in opensips fixing the error header(add missing angle brackets)?
By the way, The information that appears above is also a example of issue(#1739 (comment)).
I used add_path_received() in register message to freeswitch, but received parameters was not added in path header. As you can see, route header in freeswitch outbound invite message doesn't have received parameters.

@bogdan-iancu
Copy link
Member

I see - could you post the REGISTER request (as sent out by OpenSIPS) and the INVITE request (as received by OpenSIPS) to see the inserted Path hdr and the resulting Route hdr ? I just want to be 100% that the Path generated by OpenSIPS is correct.
And there is no (easy) way to try to trick this and fix that hdr, as OpenSIPS will "read" (inside the loose_route) the SIP message as received.
In regards to #1739, I will double check it.

@tangshiixang
Copy link
Author

@bogdan-iancu
REGISTER request (as sent out by OpenSIPS) :
REGISTER sips:X.X.X.X:5061 SIP/2.0
Via: SIP/2.0/TLS 192.168.1.2:5065;branch=z9hG4bK618b.52fadc2.0;i=d42b2855
Via: SIP/2.0/TLS 112.31.212.45:45469;received=112.31.212.45;rport=45469;branch=z9hG4bKPjRafEX7s-oznxkUGwlPWoD9NBLqVvAPL.;alias
Max-Forwards: 69
From: <sips:1000@X.X.X.X>;tag=CsjV2gvBLagHK.8rzvxT3FKcKNirIn91
To: <sips:1000@X.X.X.X>
Call-ID: LeCqMjz08BZY8B4KxwUbyR9U.OpR.4mB
CSeq: 3422 REGISTER
Supported: outbound, path
Contact: <sips:1000@112.31.212.45:45469;transport=TLS;ob>;reg-id=1;+sip.instance="<urn:uuid:00000000-0000-0000-0000-0000e922f243>"
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Authorization: Digest username="1000", realm="X.X.X.X", nonce="cfa59714-5941-496a-8f0a-e7514c3e50e5", uri="sips:X.X.X.X:5061", response="468c9133af20a647513ec32f633f510d", algorithm=MD5, cnonce="4LVfKDjxv6aG4XPEuDqXpqTl.MMdttj2", qop=auth, nc=00000001
Content-Length: 0
Path: <sip:opensips@192.168.1.2:5065;transport=tls;lr>

REGISTER request (as received by freeswitch) is same as above, here is 200 ok (opensips received from freeswitch):
SIP/2.0 200 OK
Via: SIP/2.0/TLS 192.168.1.2:5065;branch=z9hG4bK618b.52fadc2.0;i=d42b2855;rport=50650
Via: SIP/2.0/TLS 112.31.212.45:45469;received=112.31.212.45;rport=45469;branch=z9hG4bKPjRafEX7s-oznxkUGwlPWoD9NBLqVvAPL.;alias
From: <sips:1000@X.X.X.X>;tag=CsjV2gvBLagHK.8rzvxT3FKcKNirIn91
To: <sips:1000@X.X.X.X>;tag=7tKDZX17vHgmF
Call-ID: LeCqMjz08BZY8B4KxwUbyR9U.OpR.4mB
CSeq: 3422 REGISTER
Contact: <sips:1000@112.31.212.45:45469;transport=TLS;ob>;expires=300
Date: Thu, 11 Jul 2019 00:41:52 GMT
User-Agent: FreeSWITCH-mod_sofia/1.8.7+git~20190702T200609Z~6047ebddfc~64bit
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, path, replaces
Path: <sip:opensips@192.168.1.2:5065>;transport=tls;lr
Content-Length: 0

@tangshiixang
Copy link
Author

@bogdan-iancu I take the liberty of saying that opensips can provide a beautiful way to bypass this problem?I'm sorry, this is not opensips' fault. I have used remove_hf ("Route") instead of loose_route () to work around this problem in the initial request. But it seems to me that this is not the right thing in any case.

@stale
Copy link

stale bot commented Jul 26, 2019

Any updates here? No progress has been made in the last 15 days, marking as stale. Will close this issue if no further updates are made in the next 30 days.

@stale stale bot added the stale label Jul 26, 2019
@bogdan-iancu
Copy link
Member

Well, it is not so simple (and even explaining why is not simple is not so simple :) ).
What you can do is to do your own "check for preloaded route" in script, with special handling when coming from FS : is source is FS, grab the full body of the Route hdr (like $hdr(Route)) and parsing it directly as SIP URI (NOT like name-addr as it should) , use the is_myself() core function to see if the IP and port are actually yours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants