Hey All,
I always have issues with substituting out header values. I’ve tried subst and subst_hf.
Here is the value that I want to change out:
Contact: <sip:52.41.52.34:5060;line=sr-h06Cy7RYRFkYacM0a7epa7sVa7sVRcNCW7IbaGZ9RGlC sip:52.41.52.34:5060;line=sr-h06Cy7RYRFkYacM0a7epa7sVa7sVRcNCW7IbaGZ9RGlC>
And this is what I want it to be
Contact: <sip:1313717555@jump.dsiprouter.net sip:1313717555@jump.dsiprouter.net;line=sr-h06Cy7RYRFkYacM0a7epa7sVa7sVRcNCW7IbaGZ9RGlC>
I’m using this
subst('/^Contact: sip:(.*);(.*)$/Contact: <sip:1313717555@jump.dsiprouter.net;\2 sip:1313717555@jump.dsiprouter.net;\2>\r/ig’);
And it doesn’t work, but putting into a online regular expression tester it looks good as shown below. Any ideas?
Hello,
what is the result? Do you use other functions that may change the contact (like those from nathelper)?
Cheers, Daniel
On 06.04.20 15:34, Mack Hendricks wrote:
Hey All,
I always have issues with substituting out header values. I’ve tried subst and subst_hf.
Here is the value that I want to change out:
Contact: sip:52.41.52.34:5060;line=sr-h06Cy7RYRFkYacM0a7epa7sVa7sVRcNCW7IbaGZ9RGlC
And this is what I want it to be
Contact: sip:1313717555@jump.dsiprouter.net;line=sr-h06Cy7RYRFkYacM0a7epa7sVa7sVRcNCW7IbaGZ9RGlC
I’m using this
subst('/^Contact: sip:(.*);(.*)$/Contact: sip:1313717555@jump.dsiprouter.net;\2\r/ig’);
And it doesn’t work, but putting into a online regular expression tester it looks good as shown below. Any ideas?
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Hey Daniel,
I hope all is well!
I tried to make it super simple
The regular expression is this:
subst_hf("Contact", "/@.*>/@107.21.184.251>/", "a”);
The Contact looks like this
Contact: sip:3135421245@10.0.0.140:53349;alias=98.209.240.245~53349~1
It ends up like this (it concatenates it)
Contact: sip:3135421245@10.0.0.140:53349;alias=98.209.240.245~53349~1@107.21.184.251
I really want this
Contact: sip:3135421245@107.21.184.251
I do call Nathelper functions in some cases. I can comment those out. What am I missing?
On Apr 7, 2020, at 2:54 AM, Daniel-Constantin Mierla miconda@gmail.com wrote:
Hello,
what is the result? Do you use other functions that may change the contact (like those from nathelper)?
Cheers, Daniel
On 06.04.20 15:34, Mack Hendricks wrote:
Hey All,
I always have issues with substituting out header values. I’ve tried subst and subst_hf.
Here is the value that I want to change out:
Contact: <sip:52.41.52.34:5060;line=sr-h06Cy7RYRFkYacM0a7epa7sVa7sVRcNCW7IbaGZ9RGlC sip:52.41.52.34:5060;line=sr-h06Cy7RYRFkYacM0a7epa7sVa7sVRcNCW7IbaGZ9RGlC>
And this is what I want it to be
Contact: <sip:1313717555@jump.dsiprouter.net sip:1313717555@jump.dsiprouter.net;line=sr-h06Cy7RYRFkYacM0a7epa7sVa7sVRcNCW7IbaGZ9RGlC>
I’m using this
subst('/^Contact: sip:(.*);(.*) sip:(.*);(.*)$/Contact: <sip:1313717555@jump.dsiprouter.net;\2 sip:1313717555@jump.dsiprouter.net;\2>\r/ig’);
And it doesn’t work, but putting into a online regular expression tester it looks good as shown below. Any ideas?
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org mailto:sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla -- www.asipto.com http://www.asipto.com/ www.twitter.com/miconda http://www.twitter.com/miconda -- www.linkedin.com/in/miconda http://www.linkedin.com/in/miconda
Hello,
if you use more operations over the headers, they do not override each other, they typically add to the content. Use msg_apply_changes() between such operations, see:
* https://www.kamailio.org/wiki/tutorials/faq/main#why_changes_made_to_headers...
Cheers, Daniel
On 07.04.20 09:17, Mack Hendricks wrote:
Hey Daniel,
I hope all is well!
I tried to make it super simple
The regular expression is this:
subst_hf("Contact", "/@.*>/@107.21.184.251>/", "a”);
The Contact looks like this
Contact: sip:3135421245@10.0.0.140:53349;alias=98.209.240.245~53349~1
It ends up like this (it concatenates it)
Contact: sip:3135421245@10.0.0.140:53349;alias=98.209.240.245~53349~1@107.21.184.251
I really want this
Contact: sip:3135421245@107.21.184.251
I do call Nathelper functions in some cases. I can comment those out. What am I missing?
On Apr 7, 2020, at 2:54 AM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
Hello,
what is the result? Do you use other functions that may change the contact (like those from nathelper)?
Cheers, Daniel
On 06.04.20 15:34, Mack Hendricks wrote:
Hey All,
I always have issues with substituting out header values. I’ve tried subst and subst_hf.
Here is the value that I want to change out:
Contact: sip:52.41.52.34:5060;line=sr-h06Cy7RYRFkYacM0a7epa7sVa7sVRcNCW7IbaGZ9RGlC
And this is what I want it to be
Contact: sip:1313717555@jump.dsiprouter.net;line=sr-h06Cy7RYRFkYacM0a7epa7sVa7sVRcNCW7IbaGZ9RGlC
I’m using this
subst('/^Contact: sip:(.*);(.*)$/Contact: sip:1313717555@jump.dsiprouter.net;\2\r/ig’);
And it doesn’t work, but putting into a online regular expression tester it looks good as shown below. Any ideas?
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla -- www.asipto.com www.twitter.com/miconda -- www.linkedin.com/in/miconda
Again, the question has to be asked: why do you want to rewrite the Contact header? And is there a better way to accomplish what you are trying to accomplish?
Contact is constructed by the endpoints, not the proxy. Touching it is almost never a good idea.
Where Contact is statefully rewritten by the topology hiding modules, touching it is also not a good idea.
It’s just not a good idea.
— Sent from mobile, with due apologies for brevity and errors.
On Apr 7, 2020, at 2:29 AM, Mack Hendricks mack@dopensource.com wrote:
Hey All,
I always have issues with substituting out header values. I’ve tried subst and subst_hf.
Here is the value that I want to change out:
Contact: sip:52.41.52.34:5060;line=sr-h06Cy7RYRFkYacM0a7epa7sVa7sVRcNCW7IbaGZ9RGlC
And this is what I want it to be
Contact: sip:1313717555@jump.dsiprouter.net;line=sr-h06Cy7RYRFkYacM0a7epa7sVa7sVRcNCW7IbaGZ9RGlC
I’m using this
subst('/^Contact: sip:(.*);(.*)$/Contact: sip:1313717555@jump.dsiprouter.net;\2\r/ig’);
And it doesn’t work, but putting into a online regular expression tester it looks good as shown below. Any ideas?
<PastedGraphic-1.png> _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users