[Spce-user] How to deal with non-numeric characters in a dialed number

Daniel Grotti dgrotti at sipwise.com
Thu Aug 30 03:42:40 EDT 2018


Matthias,
using cf_loop you may skip also "normal" CF to external numbers.
So maybe you can use the check : !($rd =~ "^.+\.local$")

So check the number is the call is not to a *.local domain.

Daniel



On 08/29/2018 08:51 PM, Hohl Matthias wrote:
>
> Hello Daniel,
>
> thanks for your answer, i tried this but it looks like it is not working:
>
> it looks like it didn’t find the cf_loop variable in the invite so it 
> doesn’t skip it…
>
> if(is_method("INVITE") && !($rU =~ "^\+?[0-9]+$") && !has_totag() && 
> !($var(cf_loop) == "1"))
>
> Reply CF loop - S=100 - Connecting M=INVITE
>
> New request on proxy - M=INVITE R=sip:vmu43720560099 at voicebox.local
>
> Dialed number is not numeric - 'vmu43720560099'
>
> Reply CF loop - S=403 - Dialed number is not numeric M=INVITE
>
> *Von:*Spce-user <spce-user-bounces at lists.sipwise.com> *Im Auftrag von 
> *Daniel Grotti
> *Gesendet:* Mittwoch, 29. August 2018 09:30
> *An:* spce-user at lists.sipwise.com
> *Betreff:* Re: [Spce-user] How to deal with non-numeric characters in 
> a dialed number
>
> Hi,
> you can try to use "$var(cf_loop) == 1" to skip INVITE after CF.
>
>
>
>
>
> -- 
> Daniel Grotti
> Head of Customer Support
> Sipwise GmbH, Campus 21/Europaring F15
> AT-2345 Brunn am Gebirge
> Office: +43(0)130120332
> Email:dgrotti at sipwise.com <mailto:dgrotti at sipwise.com>
> Website:https://www.sipwise.com
>
> On 08/28/2018 09:31 PM, Daniel Grotti wrote:
>
>     Ho Matthias,
>
>     There is a variable or avp called “cf_loop” and it’s set to one
>     when a cf is set.
>
>     You can use that one to skip invite after a cf.
>
>     I need check the code to tell you what is the variable name exactly.
>
>     I can have a look tomorrow.
>
>     Daniel
>
>     Sent from my iPhone
>
>
>     On 28.08.2018, at 20:35, Hohl Matthias
>     <matthias.hohl at telematica.at <mailto:matthias.hohl at telematica.at>>
>     wrote:
>
>         Hello Daniel,
>
>         any update for me on this topic?
>
>         Thank you!
>
>         *Von:*Spce-user <spce-user-bounces at lists.sipwise.com
>         <mailto:spce-user-bounces at lists.sipwise.com>> *Im Auftrag von
>         *Hohl Matthias
>         *Gesendet:* Mittwoch, 22. August 2018 15:38
>         *An:* 'Daniel Grotti' <dgrotti at sipwise.com
>         <mailto:dgrotti at sipwise.com>>
>         *Cc:* spce-user at lists.sipwise.com
>         <mailto:spce-user at lists.sipwise.com>
>         *Betreff:* Re: [Spce-user] How to deal with non-numeric
>         characters in a dialed number
>
>         Hello Daniel,
>
>         one short thing left:
>
>         if there is a callforward to the local mailbox, there there
>         will be also a new INVITE for this call forward.
>
>         How can i identify this one to exclude this from my blocking
>         code? Is there also something like has_totag for that?
>
>         Failure route for local call, code='408'
>
>         CFT to CF map id '1098' found
>
>         CFT to destination 'sip:vmu43662434111 at voicebox.local
>         <mailto:sip:vmu43662434111 at voicebox.local>' with timeout '300'
>         and announcement '<null>' activated
>
>         New request on proxy - M=INVITE
>         R=sip:vmu43662434111 at voicebox.local
>         <mailto:R=sip:vmu43662434111 at voicebox.local>
>
>         *Von:*Spce-user <spce-user-bounces at lists.sipwise.com
>         <mailto:spce-user-bounces at lists.sipwise.com>> *Im Auftrag von
>         *Hohl Matthias
>         *Gesendet:* Dienstag, 21. August 2018 21:59
>         *An:* 'Daniel Grotti' <dgrotti at sipwise.com
>         <mailto:dgrotti at sipwise.com>>
>         *Cc:* spce-user at lists.sipwise.com
>         <mailto:spce-user at lists.sipwise.com>
>         *Betreff:* Re: [Spce-user] How to deal with non-numeric
>         characters in a dialed number
>
>         Hello,
>
>         yes this works now!
>
>         Hopfully the FINAL Version:
>
>                 if(is_method("INVITE") && !($rU =~ "^\+?[0-9]+$") &&
>         !has_totag() )
>
>                 {
>
>                         xlog("L_WARN", "Dialed number is not numeric -
>         '$rU' - [% logreq -%]\n");
>
>                         sl_send_reply("403", "Dialed number is not
>         numeric");
>
>                         route(ROUTE_EXIT);
>
>                 }
>
>         *Von:*Daniel Grotti <dgrotti at sipwise.com
>         <mailto:dgrotti at sipwise.com>>
>         *Gesendet:* Dienstag, 21. August 2018 21:46
>         *An:* Hohl Matthias <matthias.hohl at telematica.at
>         <mailto:matthias.hohl at telematica.at>>
>         *Cc:* spce-user at lists.sipwise.com
>         <mailto:spce-user at lists.sipwise.com>
>         *Betreff:* Re: AW: AW: AW: [Spce-user] How to deal with
>         non-numeric characters in a dialed number
>
>         You can use the has_totag() to check if its a re-invite.
>
>         Initial invites will have has_totag() false.
>
>         Cheers
>
>         Daniel
>
>         Sent from my iPhone
>
>
>         On 21.08.2018, at 21:37, Hohl Matthias
>         <matthias.hohl at telematica.at
>         <mailto:matthias.hohl at telematica.at>> wrote:
>
>             Hello,
>
>             yes this is accepted as well with this regex.
>
>             But we found another problem if there will be a second
>             invite within a call, if there is for an example a fax behind:
>
>             Aug 21 20:34:31 spce proxy[13116]: NOTICE: <script>:
>             NAT-Reply - S=200 - OK M=INVITE IP=92.63.xxx.xx:5060
>             (127.0.0.1:5080) ID=af397a3b-2013-1237-7089-002590386650
>             UA='3CXPhoneSystem 15.5.3849.1 (3849)'
>
>             Aug 21 20:34:31 spce proxy[13116]: NOTICE: <script>:
>             [dialog:start]
>             lua_dlg_callid:[af397a3b-2013-1237-7089-002590386650] -
>             R=<null> ID=af397a3b-2013-1237-7089-002590386650
>             UA='3CXPhoneSystem 15.5.3849.1 (3849)'
>
>             Aug 21 20:34:31 spce proxy[13119]: NOTICE: <script>: New
>             request on proxy - M=ACK R=sip:127.0.0.1:5080;prxroute=1
>             F=sip:4367677777777 at 92.63.xxx.xx
>             <mailto:F=sip:4367677777777 at 92.63.xxx.xx>
>             T=sip:80244311111112 at 92.63.xxx.xx
>             <mailto:T=sip:80244311111112 at 92.63.xxx.xx>
>             IP=92.63.xxx.xx:5060 (127.0.0.1:5060)
>             ID=af397a3b-2013-1237-7089-002590386650 UA='<null>'
>
>             Aug 21 20:34:31 spce proxy[13120]: NOTICE: <script>: New
>             request on proxy - M=INVITE
>             R=sip:mod_sofia at 92.63.xxx.xx:5080
>             <mailto:R=sip:mod_sofia at 92.63.xxx.xx:5080>
>             F=sip:43112345 at 92.63.xxx.xx
>             <mailto:F=sip:43112345 at 92.63.xxx.xx>
>             T=sip:43676777777 at sip.telematica.at
>             <mailto:T=sip:43676777777 at sip.telematica.at>
>             IP=127.0.0.1:5080 (127.0.0.1:5080)
>             ID=af397a3b-2013-1237-7089-002590386650 UA='3CXPhoneSystem
>             15.5.3849.1 (3849)'
>
>             It looks like this happens very often, so I think matching
>             again the $rU is not the best thing, to solve this problem.
>
>             I am also wondering why rate-o-mat has no problem with
>             this invite if this is inside a call. But I think maybe
>             cause rate o mat just look onto the initial call.
>
>             Anyway: how can I solve this problem?
>
>             Is it possible and wise just to look onto the “TO” Sip
>             Header? And if yes, whats the variable for this? We tried
>             “$tu” but it blocks then all incoming calls.
>
>             *Von:*Daniel Grotti <dgrotti at sipwise.com
>             <mailto:dgrotti at sipwise.com>>
>             *Gesendet:* Dienstag, 21. August 2018 20:22
>             *An:* Hohl Matthias <matthias.hohl at telematica.at
>             <mailto:matthias.hohl at telematica.at>>
>             *Cc:* spce-user at lists.sipwise.com
>             <mailto:spce-user at lists.sipwise.com>
>             *Betreff:* Re: AW: AW: [Spce-user] How to deal with
>             non-numeric characters in a dialed number
>
>             Probably you would need to accept number starting with 0
>             and 00 as well.
>
>             Daniel
>
>             Sent from my iPhone
>
>
>             On 21.08.2018, at 20:14, Hohl Matthias
>             <matthias.hohl at telematica.at
>             <mailto:matthias.hohl at telematica.at>> wrote:
>
>                 I tested it and i have to modificate it just a little
>                 but and now it is working J
>
>                 If there is the number NOT in format +123 or 1234 it
>                 will do a log entry and also reply with 403 – dialed
>                 number is not numeric
>
>                 This is the final working code under
>                 /etc/ngcp-config/templates/etc/kamailio/proxy/kamailio.cfg.customtt.tt2
>
>                 /if(is_method("INVITE") && !($rU =~ "^\+?[0-9]+$"))/
>
>                 /{/
>
>                 /xlog("L_WARN", "Dialed number is not numeric - '$rU'
>                 - [% logreq -%]\n");/
>
>                 /sl_send_reply("403", "Dialed number is not numeric");/
>
>                 /route(ROUTE_EXIT);/
>
>                 /} /
>
>                 *Von:*Daniel Grotti <dgrotti at sipwise.com
>                 <mailto:dgrotti at sipwise.com>>
>                 *Gesendet:* Dienstag, 21. August 2018 19:43
>                 *An:* Hohl Matthias <matthias.hohl at telematica.at
>                 <mailto:matthias.hohl at telematica.at>>
>                 *Cc:* spce-user at lists.sipwise.com
>                 <mailto:spce-user at lists.sipwise.com>
>                 *Betreff:* Re: AW: [Spce-user] How to deal with
>                 non-numeric characters in a dialed number
>
>                 At a first sight it looks good.
>
>                 It worth a try.
>
>                 Daniel
>
>                 Sent from my iPhone
>
>
>                 On 21.08.2018, at 19:39, Hohl Matthias
>                 <matthias.hohl at telematica.at
>                 <mailto:matthias.hohl at telematica.at>> wrote:
>
>                     Hello Daniel,
>
>                     i think this will work for reply 403 of the dialed
>                     number don’t match numeric number, right?
>
>                     1.if(is_method("INVITE") && ($rU !~ "^\+?[0-9]+$"))
>
>                     2.        {
>
>                     3.                xlog("L_WARN", "Dialed number is
>                     not numeric - '$rU' - [% logreq_init -%]\n");
>
>                     4.                sl_send_reply("403", "Dialed
>                     number is not numeric");
>
>                     5.route(ROUTE_EXIT);
>
>                     6.        }
>
>                     *Von:*Spce-user
>                     <spce-user-bounces at lists.sipwise.com
>                     <mailto:spce-user-bounces at lists.sipwise.com>> *Im
>                     Auftrag von *Daniel Grotti
>                     *Gesendet:* Dienstag, 21. August 2018 14:01
>                     *An:* spce-user at lists.sipwise.com
>                     <mailto:spce-user at lists.sipwise.com>
>                     *Betreff:* Re: [Spce-user] How to deal with
>                     non-numeric characters in a dialed number
>
>                     H Matthias,
>                     another option, instead of trying to consume the
>                     non-numeric number, is to make sure in kamailio
>                     that the dialed number match a numeric number
>                     series, if not you just reply 403 - not a numeric
>                     number. This will avoid the system to parse the
>                     call any further.
>
>                     Solution from Barry is also ok, but the system
>                     will parse the call until the peer selection, and
>                     call will fails with "no peering rule found" (I
>                     think it's a 500 error).
>
>
>                     Cheers,
>                     Daniel
>
>
>
>                     On 08/21/2018 01:42 PM, Hohl Matthias wrote:
>
>
>
>                         Hey Rene,
>
>                         I already thought on this but this is no real
>                         deal, cause then we will loose the money for
>                         this calls. If someone find out this trick to
>                         add a “ABC” behind the number and this will be
>                         rated as 0 cent then there will be a massive
>                         abuse potential.
>
>                         So easier would be to block all calls to this
>                         dialed numbers or the clear it like I descripe
>                         in option 2, but I don’t know the right regex
>                         to clear all non-numeric characters except a
>                         “+” on the first sign.
>
>                         Can you maybe help me with this solution too?
>
>                         My solution is just working for for
>                         -%()&*.,!“$ but not for letters or
>                         /x;:_=~@#§:[]\^°`´‘|<> and not if there is a
>                         “+” on the first sign.
>
>                         Thank you.
>
>                         *Von:*Rene Krenn <rkrenn at sipwise.com>
>                         <mailto:rkrenn at sipwise.com>
>                         *Gesendet:* Dienstag, 21. August 2018 13:29
>                         *An:* 'Hohl Matthias'
>                         <matthias.hohl at telematica.at>
>                         <mailto:matthias.hohl at telematica.at>;
>                         spce-user at lists.sipwise.com
>                         <mailto:spce-user at lists.sipwise.com>
>                         *Betreff:* AW: [Spce-user] How to deal with
>                         non-numeric characters in a dialed number
>
>                         Hi,
>
>                         why not adding two 0cent fees to cover, ie.:
>
>                         1.Non-digit source:
>
>                         src: [^0-9+]+
>
>                         dst: .
>
>                         2.Non-digit destination:
>
>                         src: .
>
>                         dst: [^0-9+]+
>
>                         Note that 6.5 will bring fee „match modes“
>                         (regex_longest_pattern/legacy,
>                         regex_longest_pattern, prefix, exact, etc.)
>                         for way more speed and flexibility.
>
>                         regards
>
>                         *Von:*Spce-user
>                         [mailto:spce-user-bounces at lists.sipwise.com]
>                         *Im Auftrag von *Hohl Matthias
>                         *Gesendet:* Dienstag, 21. August 2018 13:17
>                         *An:* spce-user at lists.sipwise.com
>                         <mailto:spce-user at lists.sipwise.com>
>                         *Betreff:* [Spce-user] How to deal with
>                         non-numeric characters in a dialed number
>
>                         Hello,
>
>                         we often have the problem, that an UA of a
>                         subscriber is dialing a number with
>                         non-numeric characters like “-%/” or also
>                         letters like “ABCD” and so on.
>
>                         Everytime when this happens, our rate-o-mat
>                         stop working, cause there is no billing
>                         profile destination pattern for such kind of
>                         characters.
>
>                         Normally our billing profile pattern looks
>                         like this: Source Pattern: “.” Destination
>                         Pattern: ^431.+$
>
>                         My ideas to fix this problem:
>
>                         1.)If a UA is calling a non-numeric number,
>                         except “+” in the front, then the call should
>                         be blocked by SPCE.
>                         So calls not formatted like #4312345 or 012345
>                         should be blocked, without trying to reach a
>                         peering.
>                         Is this possible? It would the easiest way to
>                         force a subscriber to dial correct numbers,
>                         otherwise calling is not working.
>
>                         2.)Clear special characters in the INVITE:
>                         /etc/ngcp-config/templates/etc/kamailio/proxy/kamailio.cfg.customtt.tt2
>
>                         I tried to edit the kamailio.cfg.tt2 and edit
>                         it to this:
>                         /        if(is_method("INVITE"))/
>
>                         ///{/
>
>                         /                $rU =
>                         $(rU{re.subst,/^(\+)?[:blank:]?\(?([0-9]*)\)?[
>                         -.]?\(?([0-9]*)\)?[ -.]?\(?([0-9]*)\)?[
>                         -.]?\(?([0-9]*)\)?[
>                         -.]?\(?([0-9]*)\)?$/\1\2\3\4\5\6/});/
>
>                         ///xlog("L_NOTICE", "Consume special chars in
>                         RURI - '$rU' - [% logreq_init -%]\n");/
>
>                         ///}/
>
>                         But this way, just working for -%()&*.,!“$ but
>                         not for letters or /x;:_=~@#§:[]\^°`´‘|<>
>                         How do I have to edit this to clear everything
>                         witch is a non-numeric character or a number
>                         with a “+” in the front?
>
>                         Will this do the trick?
>
>                         /        if(is_method("INVITE"))/
>
>                         /        {/
>
>                         /$rU = $(rU{re.subst,/[^0-9]//g});/
>
>                         ///xlog("L_NOTICE", "Consume special chars in
>                         RURI - '$rU' - [% logreq_init -%]\n");/
>
>                         ///}/
>
>                         3.)Editing the Rewrite Rules to match also
>                         against non-numeric characters in a dialed
>                         number string. But I think this will cause
>                         more problems like it fix.
>
>                         How did you fix this problems? I think the
>                         easiest thing would be to block everything
>                         which is not perfect formatted (1.). Is this
>                         possible?
>
>                         It would be very nice if you could assist me
>                         with this problem.
>
>                         Thank you
>
>                         Mit freundlichen Grüßen,
>
>                         Matthias Hohl
>
>
>
>
>
>
>                         _______________________________________________
>
>                         Spce-user mailing list
>
>                         Spce-user at lists.sipwise.com
>                         <mailto:Spce-user at lists.sipwise.com>
>
>                         https://lists.sipwise.com/listinfo/spce-user
>
>
>
>
>     _______________________________________________
>
>     Spce-user mailing list
>
>     Spce-user at lists.sipwise.com <mailto:Spce-user at lists.sipwise.com>
>
>     https://lists.sipwise.com/listinfo/spce-user
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sipwise.com/pipermail/spce-user_lists.sipwise.com/attachments/20180830/c6cf166a/attachment-0001.html>


More information about the Spce-user mailing list