Hi,
I'm trying to capture and substitute the host IP of contact header using the subst_hf but it's not working as expected. I tested my regex in a tester and it works fine there but not in the Kamailio config.
Regex: @(.+?)>
Substitution: @PUBLIC_IP:5060>
Three contact headers that I'm trying to match;
Contact:<sip:0065*7766@172.16.1.217:5060
;methods="INVITE,ACK,BYE,CANCEL,OPTIONS,INFO,MESSAGE,SUBSCRIBE,NOTIFY,PRACK,UPDATE,REFER"
Contact: sip:0065*7788@172.16.1.216 ;transport=udp;expires=3600;reg-id=1;+sip.instance="urn:uuid:03660bc5-bb70-4784-8ac5-000413B108BA"
Contact: sip:0925*0007@172.16.1.218:5060
Outcome I'm expecting for the three contact headers;
Contact:sip:0065*7766@PUBLIC_IP :5060;methods="INVITE,ACK,BYE,CANCEL,OPTIONS,INFO,MESSAGE,SUBSCRIBE,NOTIFY,PRACK,UPDATE,REFER"
Contact: sip:0065*7788@PUBLIC_IP :5060;expires=3600;reg-id=1;+sip.instance="urn:uuid:03660bc5-bb70-4784-8ac5-000413B108BA"
Contact: sip:0925*0007@PUBLIC_IP:5060
This regex in Kamailio works fine for the first and third contact header but for the second contact header it matches all the way to the end of the contact header excluding the quote (") sign. I've tried so many other combinations [like @(.+?)>;? ] of regex but nothing seems to work.
Is there a way to accomplish this with one regex?
Thanks, Sal
On Fri, 25 Nov 2022 at 16:10, Salvinder Parhar salvinder.parhar09@gmail.com wrote:
Hi,
I'm trying to capture and substitute the host IP of contact header using the subst_hf but it's not working as expected. I tested my regex in a tester and it works fine there but not in Kamailio config.
*Regex:* @(.+?)>
*Substitution:* @PUBLIC_IP:5060>
*Three contact headers that I'm trying to match;*
Contact:<sip:0065*7766@199.48.100.166:5060
;methods="INVITE,ACK,BYE,CANCEL,OPTIONS,INFO,MESSAGE,SUBSCRIBE,NOTIFY,PRACK,UPDATE,REFER"
Contact: sip:0065*7788@172.16.1.216 ;transport=udp;expires=3600;reg-id=1;+sip.instance="urn:uuid:03660bc5-bb70-4784-8ac5-000413B108BA"
Contact: sip:0925*0007@199.48.100.166:5060
*Outcome I'm expecting for the three contact headers;*
Contact:sip:0065*7766*@PUBLIC_IP:5060* ;methods="INVITE,ACK,BYE,CANCEL,OPTIONS,INFO,MESSAGE,SUBSCRIBE,NOTIFY,PRACK,UPDATE,REFER"
Contact: sip:0065*7788*@PUBLIC_IP:5060* ;expires=3600;reg-id=1;+sip.instance="urn:uuid:03660bc5-bb70-4784-8ac5-000413B108BA"
Contact: sip:0925*0007*@PUBLIC_IP:5060*
This regex in Kamailio works fine for the first and third contact header but for the second contact header it matches all the way to the end of the contact header excluding the quote (") sign. I've tried so many other combinations [like *@(.+?)>;?* ] of regex but nothing seems to work.
Is there a way to accomplish this with one regex?
Thanks, Sal