I already run into issues with this. If I want to only execute a statement if it’s an INVITE with a request domain of 10.10.*.* how do I format? Below is what I have. I always have to play with it a bit. Looking to get a better understanding. The regular expression tester I’m using states that it’s valid. What am I doing wrong?
if ((is_method("INVITE")) && ($rd =~ "10.10..+")) {
# Do something xlog("fix got a 10.10 address");
}
Thanks
Hi Mack,
This might be easier: https://kamailio.org/docs/modules/devel/modules/ipops.html#ipops.f.is_in_sub...
Cheers,
Henning
+1: is_in_subnet is phenomenal...
--fred
On Wed, 2020-09-09 at 19:40 +0000, Henning Westerholt wrote:
Hi Mack,
This might be easier: https://kamailio.org/docs/modules/devel/modules/ipops.html#ipops.f.is_in_sub...
Cheers,
Henning
-- Henning Westerholt – https://skalatan.de/blog/ Kamailio services – https://gilawa.com
-----Original Message----- From: sr-users sr-users-bounces@lists.kamailio.org On Behalf Of Mack Hendricks Sent: Wednesday, September 9, 2020 9:35 PM To: Kamailio - Users Mailing List sr-users@lists.kamailio.org Subject: [SR-Users] Regular Expression Evaluation
I already run into issues with this. If I want to only execute a statement if it’s an INVITE with a request domain of 10.10.*.* how do I format? Below is what I have. I always have to play with it a bit. Looking to get a better understanding. The regular expression tester I’m using states that it’s valid. What am I doing wrong?
if ((is_method("INVITE")) && ($rd =~ "10.10..+")) {
# Do something xlog("fix got a 10.10 address"); }
Thanks _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Cool...I will use that
Thanks
On Wed, Sep 9, 2020 at 3:45 PM Fred Posner fred@palner.com wrote:
+1: is_in_subnet is phenomenal...
--fred
On Wed, 2020-09-09 at 19:40 +0000, Henning Westerholt wrote:
Hi Mack,
This might be easier:
https://kamailio.org/docs/modules/devel/modules/ipops.html#ipops.f.is_in_sub...
Cheers,
Henning
--
Henning Westerholt – https://skalatan.de/blog/
Kamailio services – https://gilawa.com
-----Original Message-----
From: sr-users sr-users-bounces@lists.kamailio.org On Behalf Of
Mack Hendricks
Sent: Wednesday, September 9, 2020 9:35 PM
To: Kamailio - Users Mailing List sr-users@lists.kamailio.org
Subject: [SR-Users] Regular Expression Evaluation
I already run into issues with this. If I want to only execute a
statement if it’s an INVITE with a request domain of 10.10.*.* how
do I format? Below is what I have. I always have to play with it
a bit. Looking to get a better understanding. The regular
expression tester I’m using states that it’s valid. What am I doing
wrong?
if ((is_method("INVITE")) && ($rd =~ "10.10..+")) {
# Do something
xlog("fix got a 10.10 address");
}
Thanks
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
The answer to the question as posed would also be interesting, however. It seems to me it should work.
On 9/9/20 3:34 PM, Mack Hendricks wrote:
I already run into issues with this. If I want to only execute a statement if it’s an INVITE with a request domain of 10.10.*.* how do I format? Below is what I have. I always have to play with it a bit. Looking to get a better understanding. The regular expression tester I’m using states that it’s valid. What am I doing wrong?
if ((is_method("INVITE")) && ($rd =~ "10.10..+")) {
# Do something xlog("fix got a 10.10 address"); }
Thanks _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
I would try:
if(uri=~"10.10.10.[[:digit:]]+.[[:digit:]]+")
or
if(uri=~"10.10.10.[0-9]+.[0-9]+")
--fred
On Wed, 2020-09-09 at 15:53 -0400, Alex Balashov wrote:
The answer to the question as posed would also be interesting, however. It seems to me it should work.
On 9/9/20 3:34 PM, Mack Hendricks wrote:
I already run into issues with this. If I want to only execute a statement if it’s an INVITE with a request domain of 10.10.*.* how do I format? Below is what I have. I always have to play with it a bit. Looking to get a better understanding. The regular expression tester I’m using states that it’s valid. What am I doing wrong?
if ((is_method("INVITE")) && ($rd =~ "10.10..+")) {
# Do something xlog("fix got a 10.10 address"); }
Thanks _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
I had an extra 10 in there ;)
if ((is_method("INVITE")) && ($rd =~ "10.10.[[:digit:]]+.[[:digit:]]+")) {
or
if ((is_method("INVITE")) && ($rd =~ "10.10.[0-9]+.[0-9]+")) {
--fred
On Wed, 2020-09-09 at 16:15 -0400, Fred Posner wrote:
I would try:
if(uri=~"10.10.10.[[:digit:]]+.[[:digit:]]+")
or
if(uri=~"10.10.10.[0-9]+.[0-9]+")
--fred
On Wed, 2020-09-09 at 15:53 -0400, Alex Balashov wrote:
The answer to the question as posed would also be interesting, however. It seems to me it should work.
On 9/9/20 3:34 PM, Mack Hendricks wrote:
I already run into issues with this. If I want to only execute a statement if it’s an INVITE with a request domain of 10.10.*.* how do I format? Below is what I have. I always have to play with it a bit. Looking to get a better understanding. The regular expression tester I’m using states that it’s valid. What am I doing wrong?
if ((is_method("INVITE")) && ($rd =~ "10.10..+")) {
# Do something xlog("fix got a 10.10 address"); }
Thanks _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
This one with matching 4 numbers separated by dots is better, one can add restrictions that the last two numbers are in the range 0-255, if one wants to be more strict, but the expression will get more complex.
However, it is recommended to use ^ and $ to enclose the expression and do not match hostnames like my10.10.10.10domain.com.
The first example in this discussion $rd =~ "10.10..+" can match also other ips not in wanted range, like 8.10.10.23
As for matching the . (dot), it has to be escaped like ., however over the time working with different libraries, scripting languages and parameters evaluation (which may require \.) I developed the habit of using [ ] for matching the special characters, like here it would be $rd =~ "^10[.]10[.].+".
Just to follow on Alex' remark.
Otherwise, the match with ipops function is the most accurate for this case.
To complete for those that are not aware of, one can avoid regex matching if wanted to match on prefix: starts_with("$rd", "10.10."). Then fnmatch() function can be also useful in some cases, it does shell-like pattern matching for file names.
Cheers, Daniel
On 09.09.20 22:18, Fred Posner wrote:
I had an extra 10 in there ;)
if ((is_method("INVITE")) && ($rd =~ "10.10.[[:digit:]]+.[[:digit:]]+")) {
or
if ((is_method("INVITE")) && ($rd =~ "10.10.[0-9]+.[0-9]+")) {
--fred
On Wed, 2020-09-09 at 16:15 -0400, Fred Posner wrote:
I would try:
if(uri=~"10.10.10.[[:digit:]]+.[[:digit:]]+")
or
if(uri=~"10.10.10.[0-9]+.[0-9]+")
--fred
On Wed, 2020-09-09 at 15:53 -0400, Alex Balashov wrote:
The answer to the question as posed would also be interesting, however. It seems to me it should work.
On 9/9/20 3:34 PM, Mack Hendricks wrote:
I already run into issues with this. If I want to only execute a statement if it’s an INVITE with a request domain of 10.10.*.* how do I format? Below is what I have. I always have to play with it a bit. Looking to get a better understanding. The regular expression tester I’m using states that it’s valid. What am I doing wrong?
if ((is_method("INVITE")) && ($rd =~ "10.10..+")) {
# Do something xlog("fix got a 10.10 address"); }
Thanks _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Hey Fred and all,
That solved my problem…now I know to use POSIX format..Thanks again!
On Sep 9, 2020, at 4:18 PM, Fred Posner fred@palner.com wrote:
I had an extra 10 in there ;)
if ((is_method("INVITE")) && ($rd =~ "10.10.[[:digit:]]+.[[:digit:]]+")) {
or
if ((is_method("INVITE")) && ($rd =~ "10.10.[0-9]+.[0-9]+")) {
--fred
On Wed, 2020-09-09 at 16:15 -0400, Fred Posner wrote:
I would try:
if(uri=~"10.10.10.[[:digit:]]+.[[:digit:]]+")
or
if(uri=~"10.10.10.[0-9]+.[0-9]+")
--fred
On Wed, 2020-09-09 at 15:53 -0400, Alex Balashov wrote:
The answer to the question as posed would also be interesting, however. It seems to me it should work.
On 9/9/20 3:34 PM, Mack Hendricks wrote:
I already run into issues with this. If I want to only execute a statement if it’s an INVITE with a request domain of 10.10.*.* how do I format? Below is what I have. I always have to play with it a bit. Looking to get a better understanding. The regular expression tester I’m using states that it’s valid. What am I doing wrong?
if ((is_method("INVITE")) && ($rd =~ "10.10..+")) {
# Do something xlog("fix got a 10.10 address"); }
Thanks _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users