[SR-Users] $Rp variable seems to contain wrong port

2022-11-03 Thread Ross McKillop
Hi All, 

At the risk of possibly dragging up an old thread 
(https://lists.kamailio.org/pipermail/sr-users/2021-June/112791.html 
) I’m 
seeing unusual behaviour where $Rp is still showing what I think is the ‘wrong’ 
behaviour, but given Daniel’s reply on the earlier thread I want to be sure 
this isn’t the intended behaviour. 

The thread above confirms that $Rp is not taken from the IP layer but is 
intended to give the attribute of the listen socket associated with the SIP 
traffic, which is fine and what I’m expecting, but in my case it doesn’t seem 
to be working this way. 

(I’ve tried with and without tcp_reuse_port=yes and tcp_connection_match=1 too 
just in case one of the above parameters has changed this behaviour) 

If Kamailio listening on multiple ports e.g.

listen=tcp:10.30.22.73:7701
listen=tcp:10.30.22.73:7702
listen=tcp:10.30.22.73:7703
listen=tls:10.30.22.73:7801
listen=tls:10.30.22.73:7802
listen=tls:10.30.22.73:7803

And I use $fs to force the socket of an outbound message to one of the above 
before t_relay() it works as expected (with tcp_reuse_port it originates from 
the given port number above, without that set it will originate from a 
different ephemeral port even to the same destination, so $fs is working as 
expected)

Then, in reply_route{} I have a simple line to add the port it was received on 
to the headers (I’ve also tried with $RAp)

append_hf("X-Rcvd-Port: $Rp\r\n”);

In every case, the reply seems to contain the *first* port of the protocol type 
(so in the above example every TCP reply irrespective of whether it is to 
7701/02/03 will show $Rp 7701, and every TLS reply will show 7801)

Any advice or insight anyone can offer would be much appreciated. 

Thanks,
Ross__
Kamailio - Users Mailing List - Non Commercial Discussions
sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] corex send()

2021-11-12 Thread Ross McKillop
I know it doesn't make sense, it's a bit of a stop-gap solution that I had 
hoped would be simple and turned into anything but ;-)

Best,
Ross

> On 12 Nov 2021, at 14:45, ‪M S‬  wrote:
> 
> you are trying to use Kamailio as transport bridge (TCP <-> TLS) but don't 
> want to use it's transport bridge capabilities (Route & Via headers etc.), 
> that doesn't makes sense...
> 
> But nevertheless, i think you can,
> 
> 1. Use t_relay and then in "send" event route remove the headers added by 
> kamailio manually using textops module functions.
> 
> 2. Use send_data or sendx methods in corex module.
> 
> https://kamailio.org/docs/modules/5.5.x/modules/corex.html#corex.f.send_data
> 
> 3. Use "network:msg" route and shape the sip packet to the form acceptable by 
> TCP box.
> 
> https://kamailio.org/docs/modules/5.5.x/modules/corex.html#corex.evr.network_msg
> 
> By the way, per my understanding send_tcp suppose to work for TLS 
> connections, since TLS is basically a TCP connection. Anyways, i will run 
> some tests to see its behavior when i have enough time.
> 
> --
> Muhammad Shahzad Shafi
> Tel: +49 176 99 83 10 85
> 
> 
> Sent from my Huawei P40 5G phone
> 
> 
>  Original message 
> From: Ross McKillop 
> Date: Fri, 12 Nov 2021, 14:44
> To: "Kamailio (SER) - Users Mailing List" 
> Subject: [SR-Users] corex send()
> Hi All,
> 
> Is there an equivalent to corex's send_tcp 
> (https://kamailio.org/docs/modules/5.2.x/modules/corex.html#corex.f.send_tcp 
> <https://kamailio.org/docs/modules/5.2.x/modules/corex.html#corex.f.send_tcp>)
>  for TLS? 
> 
> I have a bit of an odd edge case where I can't add Via headers etc, and 
> send_udp and send_tcp allow me to achieve what I want, but it doesn't seem to 
> have a means of doing the same with TLS? 
> 
> Essentially I want to transparently proxy what is received by Kamailio on one 
> interface to a TLS connection e.g. 
> 
>   A = (TCP) => Kamailio = (TLS) => Remote Host 
> 
> (A) in this instance is already setting a Via header of the Kamailio's 
> external IP and transport tis. I appreciate this is a non-standard way of 
> doing it, but (A) is a black box that I can't change, what I'm essentially 
> trying to do is have Kamailio handle the TLS but essentially (A) thinks it's 
> at the edge.
> 
> I can make it work with send_tcp for a standard TCP connection, but if I use 
> t_relay or even forward() to send onwards by TLS then Kamailio obviously adds 
> its own headers as you'd expect.
> 
> Ross

__
Kamailio - Users Mailing List - Non Commercial Discussions
  * sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:
  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


[SR-Users] corex send()

2021-11-12 Thread Ross McKillop
Hi All,

Is there an equivalent to corex's send_tcp 
(https://kamailio.org/docs/modules/5.2.x/modules/corex.html#corex.f.send_tcp 
) 
for TLS? 

I have a bit of an odd edge case where I can't add Via headers etc, and 
send_udp and send_tcp allow me to achieve what I want, but it doesn't seem to 
have a means of doing the same with TLS? 

Essentially I want to transparently proxy what is received by Kamailio on one 
interface to a TLS connection e.g. 

A = (TCP) => Kamailio = (TLS) => Remote Host 

(A) in this instance is already setting a Via header of the Kamailio's external 
IP and transport tis. I appreciate this is a non-standard way of doing it, but 
(A) is a black box that I can't change, what I'm essentially trying to do is 
have Kamailio handle the TLS but essentially (A) thinks it's at the edge.

I can make it work with send_tcp for a standard TCP connection, but if I use 
t_relay or even forward() to send onwards by TLS then Kamailio obviously adds 
its own headers as you'd expect.

Ross__
Kamailio - Users Mailing List - Non Commercial Discussions
  * sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:
  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Forcing Outbound Socket

2021-11-11 Thread Ross McKillop


> On 11 Nov 2021, at 07:22, Olle E. Johansson  wrote:
> 
> 
> 
>> 10 nov. 2021 kl. 18:21 skrev Ross McKillop > <mailto:r...@rsmck.co.uk>>:
>> 
>> Hi,
>> 
>> Thanks, I was almost certain that is set but it seems it may not be so will 
>> double check that, thank you :) 
>> 
>> Now to solve the other issue…. 
> Just a nit-picking note: All these are non-standard fixes. The standard based 
> way is to use the outbound module, it’s the way to allow the sip server to 
> use an inbound TCP connection for outbound requests. This applies to 
> client2server connections.
> 
> For server2server connections there is a requirement of mutual TLS auth in 
> order to be able to reuse the connection in both directions

I thought this would be possible with TCP too.

I looked at the outbound module but this is a 'drop in' replacement for 
something that already exists, so I'm trying to avoid rewriting headers as 
would be required for flow IDs etc, however it's a definite preferred method 
for improvement.

As an aside, and it may be the same issue in 
https://www.mail-archive.com/sr-users@lists.kamailio.org/msg15589.html 
<https://www.mail-archive.com/sr-users@lists.kamailio.org/msg15589.html>, when 
you force an outbound socket on a specific port and a reply is received on that 
port, both $Rp and $Rut show the port on the first listen directive, not the 
port it was actually received on, which makes it a bit harder to do what I was 
trying to as well :/

Ross

__
Kamailio - Users Mailing List - Non Commercial Discussions
  * sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:
  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Forcing Outbound Socket

2021-11-10 Thread Ross McKillop
Hi,

Thanks, I was almost certain that is set but it seems it may not be so will 
double check that, thank you :) 

Now to solve the other issue 

Ross

> On 10 Nov 2021, at 17:14, Federico Cabiddu  wrote:
> 
> Hi, 
> to force kamailio to use, for outbound connections, a specific tcp port 
> (define in a "listen" directive), you have to set the reuse_tcp_port 
> parameter (https://www.kamailio.org/wiki/cookbooks/5.5.x/core#tcp_reuse_port 
> <https://www.kamailio.org/wiki/cookbooks/5.5.x/core#tcp_reuse_port>).
> 
> Cheers,
> 
> Federico
> 
> On Wed, Nov 10, 2021 at 4:36 PM Ross McKillop  <mailto:r...@rsmck.co.uk>> wrote:
> Hi All,
> 
> Try as I may I cannot force an outbound TCP request to use a non-ephemeral 
> source port.
> 
> Looking at the documentation it seems that as long as I have a line like 
> 
> listen=tcp:10.30.0.55:3339 <http://10.30.0.55:3339/>
> 
> I should be able to force an outbound connection to originate from that host 
> and port, i.e. to establish a persistent connection from a specific socket to 
> a remote host, but having tried to set it via $fs and set_send_socket() it 
> always uses an ephemeral port.
> 
> Ideally I would like kamailio to use a specific source port for contacting a 
> specific remote host and keep the TCP socket established, and it seems like 
> it should be simple enough to do but it's not working as expected. 
> 
> Best,
> Ross
> 
> 
> __
> Kamailio - Users Mailing List - Non Commercial Discussions
>   * sr-users@lists.kamailio.org <mailto:sr-users@lists.kamailio.org>
> Important: keep the mailing list in the recipients, do not reply only to the 
> sender!
> Edit mailing list options or unsubscribe:
>   * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users 
> <https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users>
> __
> Kamailio - Users Mailing List - Non Commercial Discussions
>  * sr-users@lists.kamailio.org
> Important: keep the mailing list in the recipients, do not reply only to the 
> sender!
> Edit mailing list options or unsubscribe:
>  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

__
Kamailio - Users Mailing List - Non Commercial Discussions
  * sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:
  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] TCP Persistent Connections

2021-11-10 Thread Ross McKillop
>> Any ideas? I get the feeling I'm missing something obvious!
> 
> Perhaps this could help:
> 
> https://www.kamailio.org/docs/modules/5.5.x/modules/nathelper.html#nathelper.f.add_contact_alias

This involves adding additional data to the Contact URI which I want to avoid 
if possible.

Also, unless I misunderstand, it seems that the alias parameter is used to 
populate the $du which I can do effectively, it's the source that I'm having 
issues with or having it use an existing socket to that same destination.

Ross
__
Kamailio - Users Mailing List - Non Commercial Discussions
  * sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:
  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


[SR-Users] TCP Persistent Connections

2021-11-10 Thread Ross McKillop
Hopefully the collective hive mind can help with this one, as I have little 
experience of using TCP in this manner and neither does a friendly Kamailio 
expert I know personally. 

I'm replacing a closed box thing that accepts connections from various nodes 
over TCP. They send INVITEs and REGISTERs over that TCP socket and expect to 
receive inbound calls over the same established TCP socket. 

Struggling to make Kamailio behave the same way, but it should be possible. 

The first time it receives a message, I add the sender to the dispatcher as 
follows;

jsonrpc_exec('{"jsonrpc": "2.0", "method": "dispatcher.add", "params": [5, 
"sip:$si:$sp;transport=tcp", 0, "socket=tcp:127.0.0.1:5776"], "id": 1}');

This works great, but despite setting the socket to use there, when a call 
later comes in and it's routed to one of the dispatcher nodes that's been added 
in this way it fails because Kamailio attempts to open a new connection to the 
IP / PORT rather than having kept the socket open from the earlier message and 
reusing the same connection/.

Any ideas? I get the feeling I'm missing something obvious! 

Ross__
Kamailio - Users Mailing List - Non Commercial Discussions
  * sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:
  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


[SR-Users] Forcing Outbound Socket

2021-11-10 Thread Ross McKillop
Hi All,

Try as I may I cannot force an outbound TCP request to use a non-ephemeral 
source port.

Looking at the documentation it seems that as long as I have a line like 

listen=tcp:10.30.0.55:3339

I should be able to force an outbound connection to originate from that host 
and port, i.e. to establish a persistent connection from a specific socket to a 
remote host, but having tried to set it via $fs and set_send_socket() it always 
uses an ephemeral port.

Ideally I would like kamailio to use a specific source port for contacting a 
specific remote host and keep the TCP socket established, and it seems like it 
should be simple enough to do but it's not working as expected. 

Best,
Ross


__
Kamailio - Users Mailing List - Non Commercial Discussions
  * sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:
  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Capturing response from uac_reg module

2021-09-11 Thread Ross McKillop
I did try with failure_route but didn’t seem to get the response from the 
automatically initiated REGISTER requests, if that should work I shall try 
again!

Thanks
Ross 

--
Sent from my mobile device. 
Please excuse brevity. 

> On 11 Sep 2021, at 21:13, Henning Westerholt  wrote:
> 
> Hello Ross,
> 
> have you already tried to use a onreply_route for this? If you are interested 
> in the authentication 401/407 responses on the REGISTER request, a 
> failure_route is the way to go, as indicated in the module docs for 
> uac_auth() function.
> 
> Cheers,
> 
> Henning
> 
> -- 
> Henning Westerholt - https://skalatan.de/blog/
> Kamailio services - https://gilawa.com 
> 
> -Original Message-
> From: sr-users  On Behalf Of Ross 
> McKillop
> Sent: Friday, September 10, 2021 12:41 PM
> To: sr-users@lists.kamailio.org
> Subject: [SR-Users] Capturing response from uac_reg module
> 
> Hi,
> 
> What's the best way to capture the response from REGISTER requests 
> automatically initiated by the uac_reg module? 
> 
> I was looking to use event_route[uac:reply] {} but that is only triggered if 
> the evroute flag is set on the initial call made to uac_req_send()
> 
> Is there a way to set this globally so that uac:reply is called for all 
> requests initiated for peers in the uacreg table or a better way to capture 
> the response?
> 
> Best,
> Ross
> 
> 
> __
> Kamailio - Users Mailing List - Non Commercial Discussions
>  * sr-users@lists.kamailio.org
> Important: keep the mailing list in the recipients, do not reply only to the 
> sender!
> Edit mailing list options or unsubscribe:
>  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

__
Kamailio - Users Mailing List - Non Commercial Discussions
  * sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:
  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


[SR-Users] Capturing response from uac_reg module

2021-09-10 Thread Ross McKillop
Hi,

What's the best way to capture the response from REGISTER requests 
automatically initiated by the uac_reg module? 

I was looking to use event_route[uac:reply] {} but that is only triggered if 
the evroute flag is set on the initial call made to uac_req_send()

Is there a way to set this globally so that uac:reply is called for all 
requests initiated for peers in the uacreg table or a better way to capture the 
response?

Best,
Ross


__
Kamailio - Users Mailing List - Non Commercial Discussions
  * sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:
  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users