From benoit.panizzon@imp.ch Mon Oct 23 07:07:05 2023 From: Benoit Panizzon To: sr-users@lists.kamailio.org Subject: [SR-Users] Re: How to filter out xhttp request in event_route[siptrace:msg] Date: Mon, 23 Oct 2023 09:06:50 +0200 Message-ID: <20231023090650.2b468ea6@go.imp.ch> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2121496125==" --===============2121496125== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi Karsten > how are you measure the traffic you don't want to your Homer? Print stuff > in that Kamailio event route or something else? Basically, I want to mirror sip messages to homer, only sip messages relevant to calls, not anything else which might be processed by kamailio. modules.inc:loadmodule "siptrace.so" modules.inc:modparam("siptrace", "trace_flag", 22); modules.inc:modparam("siptrace", "trace_on", 1) modules.inc:modparam("siptrace", "trace_mode", 1) modules.inc:modparam("siptrace", "hep_mode_on", 1) modules.inc:modparam("siptrace", "hep_version", 3) modules.inc:modparam("siptrace", "hep_capture_id", HEP_CAP_AGENT) modules.inc:modparam("siptrace", "duplicate_uri", HOMERSIPURI) I also use the xhttp interface for jsonrpc and a custom API. For this I have kamailio also listen to TCP port 8080 to have those API xhttp requests clearly separated from call traffic. But, as I understand, xhttp requests are initially handled as if they were sip requests and get processed request_route{} So my request route starts with: request_route { # Handle DMQ requests route(DMQ_CAPTURE); # Make sure we operate on the correct port (not on the xhttp one) if ($Rp !=3D 5060 && $Rp !=3D 5061) { xlog("L_ERROR", "REQUEST_ROUTE $rm to wrong port $Rp\n"); exit; } so all SIP method requests to port 8080 are being dropped. I process xhttp traffic with the appropriate event route and of course reject http requests to sip ports with the appropriate http error message. event_route[xhttp:request] { if ($avp(debug) > 0) { xlog("L_INFO", "$cfg(route): XHTTP Request to URI: $hu Port: $Rp BODY= : $rb\n"); } if ($Rp !=3D 8080) { # We got a HTTP Request on a sip port. Reject! xhttp_reply("418", "I'm a teapot", "text/html", "I'm not = a Web-Server!"); exit; } if ($hu =3D~ "^/RPC") { ### KAMAILIO JSONRCP pass-through jsonrpc_dispatch(); } else if ($hu =3D~ "^/API") { ### IMPROWARE API [...] What I observe is the siptrace module being triggered right at the start of request_route. This makes sense, I want to mirror every sip message. But his also causes mirroring of the xhttp requests and replies to port 8080. Is there a way to prevent this? siptrace has an event route capable of filtering, as I understand it is only possible to filter on the SIP request method, not anything else: event_route[siptrace:msg] { if(is_method("KDMQ")) { drop(); } } Do I miss something? How can I prevent/filter xhttp requests to be mirrored by the siptrace module? Mit freundlichen Gr=C3=BCssen -Beno=C3=AEt Panizzon- --=20 I m p r o W a r e A G - Leiter Commerce Kunden ______________________________________________________ Zurlindenstrasse 29 Tel +41 61 826 93 00 CH-4133 Pratteln Fax +41 61 826 93 01 Schweiz Web http://www.imp.ch ______________________________________________________ --===============2121496125==--