GOOD NEWS FreePBX Swiss Army Knife Module

Joined
Jun 29, 2009
Messages
258
Reaction score
0
Okay, I just attempted to test the new (old) route entry method by creating a new outbound route, using the updated module. When I clicked "Submit Changes" it took me to a blank white page and did not create the route.

The route I tried to create was as follows:

Route Name: Test
Source: (I entered just this one pattern):
18004827171+811|/49X

(I wanted to see if it would add the underscore in extensions_additional.conf)

I selected one Trunk just for testing and clicked "Submit Changes". A popup box then complained, "No dial pattern, there must be at least one" so I put a single x in the third field of the "Dial Patterns that will use this Route" and clicked "Submit Changes" again. And that's when I got the blank white page. If I turn off the old dial plan then I can submit pages as usual. This is using FreePBX 2.8 so maybe that's part of the issue? (I typo'ed 2.9 and caught it after about 10 seconds but hope it didn't confuse anyone in that time. I am running 2.8).

Hope this isn't getting too frustrating!
 

tm1000

Schmoozecom INC/FreePBX
Joined
Dec 1, 2009
Messages
1,360
Reaction score
78
Oh wow. That's bad and no it's not a 2.8 issue.

Seems like it's an issue with creating NEW routes while the old dial pattern box is enabled. I will have to look into this.

For now when you create a new route I would just disable 'Turn On Old (Pre 2.8) Dial Plan Textbox'. Then go back and enable the setting and then edit the outbound route.

It still works great if the route has already been created.

I can't look into this until later :-(

Okay, I just attempted to test the new (old) route entry method by creating a new outbound route, using the updated module. When I clicked "Submit Changes" it took me to a blank white page and did not create the route.

The route I tried to create was as follows:

Route Name: Test
Source: (I entered just this one pattern):
18004827171+811|/49X

(I wanted to see if it would add the underscore in extensions_additional.conf)

I selected one Trunk just for testing and clicked "Submit Changes". A popup box then complained, "No dial pattern, there must be at least one" so I put a single x in the third field of the "Dial Patterns that will use this Route" and clicked "Submit Changes" again. And that's when I got the blank white page. If I turn off the old dial plan then I can submit pages as usual. This is using FreePBX 2.8 so maybe that's part of the issue? (I typo'ed 2.9 and caught it after about 10 seconds but hope it didn't confuse anyone in that time. I am running 2.8).

Hope this isn't getting too frustrating!
 
Joined
Jun 29, 2009
Messages
258
Reaction score
0
Edit: Quickly reviewing the posts above, is the _ needed?

I went ahead and created my test route as mentioned in the previous message, but using the new text entry method. I did NOT add the underscore to the pattern in the fourth field. Nevertheless, this was the code that FreePBX generated in extensions_additional.conf:

[outrt-51] ; Test
include => outrt-51-custom
exten => 811,1,Macro(user-callerid,SKIPTTL,)
exten => 811/_49X,1,Macro(user-callerid,SKIPTTL,)
exten => 811/_49X,n,Noop(Calling Out Route: Test)
exten => 811/_49X,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => 811/_49X,n,Set(_NODEST=)
exten => 811/_49X,n,Macro(record-enable,${AMPUSER},OUT,)
exten => 811/_49X,n,Macro(dialout-trunk,8,18004827171${EXTEN:3},)
exten => 811/_49X,n,Macro(outisbusy,)

; end of [outrt-51]

I don't really understand all that, but you can see that FreePBX is adding the underscore in front of the 49X pattern in the generated code. So if you are using their logic to process the fields, it may not be necessary to enter it, however in FreePBX 2.7 I believe it WAS necessary to enter it there. If you can fix the blank white screen issue, I can try it using the textbox entry and see if the underscore is added automatically.
 
Joined
Jun 29, 2009
Messages
258
Reaction score
0
Oh wow. That's bad and no it's not a 2.8 issue.

Seems like it's an issue with creating NEW routes while the old dial pattern box is enabled. I will have to look into this.

For now when you create a new route I would just disable 'Turn On Old (Pre 2.8) Dial Plan Textbox'. Then go back and enable the setting and then edit the outbound route.

It still works great if the route has already been created.

I can't look into this until later :-(

Not a problem, there are only so many hours in a day you can devote to this and you have already done PLENTY for today!

Since I had already created my test route, I turned the old Dial Plan Textbox back on and went back to my test route. The textbox appeared and it was the rule the way I had planned to enter it:

18004827171+811|/49X

So I clicked "Submit Changes" just to see if that would change the generated code. The first time I did that, when the page reloaded the text box went away(!) and went I went back to check, the old entry method had somehow been turned back off (unchecked). So I turned it on again, went back to my test route and clicked "Submit Changes" once more, and this time the text box stayed put after the page reloaded. No idea what happened there! :crazy:

So then I did an orange bar reload to regenerate extensions_additional.conf and this is what was generated:

[outrt-51] ; Test
include => outrt-51-custom
exten => 811,1,Macro(user-callerid,SKIPTTL,)
exten => 811/_49X,1,Macro(user-callerid,SKIPTTL,)
exten => 811/_49X,n,Noop(Calling Out Route: Test)
exten => 811/_49X,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => 811/_49X,n,Set(_NODEST=)
exten => 811/_49X,n,Macro(record-enable,${AMPUSER},OUT,)
exten => 811/_49X,n,Macro(dialout-trunk,8,18004827171${EXTEN:3},)
exten => 811/_49X,n,Macro(outisbusy,)

; end of [outrt-51]

That looks exactly the same to me, so I believe that it is adding the underscore properly. Just to be sure, I went back and changed the rule slightly and it did pick up my change and still added the underscore in front of the pattern.

So, to recap, it appears you do not need to manually add the underscore (as in 2.7) to a pattern in the fourth field, but for now you do need to create any new Outbound Routes with "Old (Pre 2.8) Dial Plan Textbox" disabled (you can add one dummy pattern consisting of a single X to stop it FreePBX from complaining) and then once it is created, you can re-enable the Old Dial Plan Textbox and enter the patterns you really want. If you have a large number of patterns, that's still a whole lot easier than dealing with the infernal new entry method!

THANK YOU x1000 for all your work on this, tm1000!
 

tm1000

Schmoozecom INC/FreePBX
Joined
Dec 1, 2009
Messages
1,360
Reaction score
78
All,

Dward has again used his amazing abilities and fixed the blank page error before I even got to it!

He also went one step further and added some javascript that will remove the javascript popups FreePBX was generating by simply entering X's into the fields (automatically)

I've now released version 1.1.1

Let the reporting being! :smile5:

http://www.the159.com/sak/sak-1.1.1.tgz

outbound_r.jpg
 
Joined
Jun 29, 2009
Messages
258
Reaction score
0
I think that last fix was the charm - seems to be working perfectly now, as far as I can tell. I created my test route again (after having deleted it previously) and this time it went off without a hitch!

Thank you again to both tm1000 and Dward for making this available and for fixing the remaining issues so quickly!

:party::party::party::party::party:
 

sukasem

Guru
Joined
Sep 13, 2008
Messages
142
Reaction score
26
Hi,

Is there anyway to put those dial rules in database like A2billing or reload asterisk without reload outbound rule dialplan? I have a big list of outbound dial rules (5000 entries). Everytime I reload asterisk it takes a lot of time.

Thanks,
Sukasem
 

tm1000

Schmoozecom INC/FreePBX
Joined
Dec 1, 2009
Messages
1,360
Reaction score
78
All this module does is put them into the database. So i'm already doing that.

If you want speedier reload times through FreePBX then you NEED/MUST use 2.9. As we started to use asterisk caching which speeds up the reload ten-fold.

Hi,

Is there anyway to put those dial rules in database like A2billing or reload asterisk without reload outbound rule dialplan? I have a big list of outbound dial rules (5000 entries). Everytime I reload asterisk it takes a lot of time.

Thanks,
Sukasem
 

sukasem

Guru
Joined
Sep 13, 2008
Messages
142
Reaction score
26
Great, It's time to upgrade my old Asterisk 1.4 and FreePBX 2.7 ;)
 
Joined
Jun 29, 2009
Messages
258
Reaction score
0
Ooooh, is this something coming in the next version of SAK? :hurray:

I want to block everything with an "area code" of 000 through 199, or an "exchange prefix" of 000 through 199!
 

tm1000

Schmoozecom INC/FreePBX
Joined
Dec 1, 2009
Messages
1,360
Reaction score
78
Yes. and it works. Just need to check pre 2.8. I need to find a system or install one.

Ooooh, is this something coming in the next version of SAK? :hurray:

I want to block everything with an "area code" of 000 through 199, or an "exchange prefix" of 000 through 199!
 
Joined
Jun 29, 2009
Messages
258
Reaction score
0
First of all, thank you for adding the regular expressions feature to the blacklist, it will definitely come in handy.

But I want to be absolutely certain of how it works so I don't accidentally block "good" calls. So let me propose a few examples and if you would, please tell me if they would work as intended. For example, could I use

[01][0-9]{9}

To block ten digit numbers where the first digit of the "area code" is 0 or 1? How about this, would this also work exactly the same way?

[01]\d{9}

(It's my understanding that \d represents "any digit" in regex).

To block invalid exchange prefixes in ten digit numbers (that have 0 or 1 as the first digit), could you use this?

\d{3}[01]\d{6}

I assume that to block calls from all "area codes" ending in 00 EXCEPT 800 you could use a block rule like this?

[0-79]00\d{7}

And to block any calls from a "976" prefix (in any area code) you could use this block rule?

\d{3}976\d{4}

And finally, I would guess that

0\d*

would match any number of any length that starts with "0". Or you could use

0.*

Which would match 0 followed by any characters (or no characters), even non-numeric ones.

Again, I'm assuming that you can use \d to represent "any digit", that the number in braces indicates how many times the previous character or expression must repeat, and that the * character means "repeat the previous character zero or more times". Just trying to get a feel for this so I don't accidentally block "good" calls! Am I on the right track here?

Here's a site I found handy in trying to figure out some of the above:
Regular Expression Quick Start
 
Joined
Jun 29, 2009
Messages
258
Reaction score
0
Just discovered a problem with the Regular Expression White/Black List...

If I blacklist a number using the regular or modified blacklist, the CLI shows this progression:

-- Executing [9999999999@from-trunk:3] Gosub("IAX2/Trunkname-10808", "app-blacklist-check,s,1") in new stack
-- Executing [s@app-blacklist-check:1] GotoIf("IAX2/Trunkname-10808", "1?blacklisted") in new stack
-- Goto (app-blacklist-check,s,4)
-- Executing [s@app-blacklist-check:4] Answer("IAX2/Trunkname-10808", "") in new stack
-- Executing [s@app-blacklist-check:5] Wait("IAX2/Trunkname-10808", "1") in new stack
-- Executing [s@app-blacklist-check:6] Zapateller("IAX2/Trunkname-10808", "") in new stack
-- Executing [s@app-blacklist-check:7] Playback("IAX2/Trunkname-10808", "ss-noservice") in new stack
-- <IAX2/Trunkname-10808> Playing 'ss-noservice.ulaw' (language 'en')
-- Executing [s@app-blacklist-check:8] Hangup("IAX2/Trunkname-10808", "") in new stack
== Spawn extension (app-blacklist-check, s, 8) exited non-zero on 'IAX2/Trunkname-10808'
-- Hungup 'IAX2/Trunkname-10808'

If I blacklist the same number using the Regular Expression White/Black List, this is what happens:

-- Executing [9999999999@from-trunk:3] Gosub("IAX2/Trunkname-4938", "app-blacklist-check,s,1") in new stack
-- Executing [s@app-blacklist-check:1] GotoIf("IAX2/Trunkname-4938", "0?blacklisted") in new stack
-- Executing [s@app-blacklist-check:2] Set("IAX2/Trunkname-4938", "CALLED_BLACKLIST=1") in new stack
-- Executing [s@app-blacklist-check:3] Return("IAX2/Trunkname-4938", "") in new stack
-- Executing [9999999999@from-trunk:4] ExecIf("IAX2/Trunkname-4938", "0 ?Set(CALLERID(name)=1111111111)") in new stack
-- Executing [9999999999@from-trunk:5] AGI("IAX2/Trunkname-4938", "/var/www/html/admin/modules/sak/agi/bwlist.agi") in new stack
-- Launched AGI Script /var/www/html/admin/modules/sak/agi/bwlist.agi
-- <IAX2/Trunkname-4938>AGI Script /var/www/html/admin/modules/sak/agi/bwlist.agi completed, returning 4
== Spawn extension (from-trunk, 9999999999, 5) exited non-zero on 'IAX2/Trunkname-4938'
-- Executing [h@from-trunk:1] Set("IAX2/Trunkname-4938", "__FROM_DID=h") in new stack
-- Executing [h@from-trunk:2] Gosub("IAX2/Trunkname-4938", "app-blacklist-check,s,1") in new stack
-- Executing [s@app-blacklist-check:1] GotoIf("IAX2/Trunkname-4938", "0?blacklisted") in new stack
-- Executing [s@app-blacklist-check:2] Set("IAX2/Trunkname-4938", "CALLED_BLACKLIST=1") in new stack
-- Executing [s@app-blacklist-check:3] Return("IAX2/Trunkname-4938", "") in new stack
-- Executing [h@from-trunk:3] ExecIf("IAX2/Trunkname-4938", "0 ?Set(CALLERID(name)=1111111111)") in new stack
-- Executing [h@from-trunk:4] AGI("IAX2/Trunkname-4938", "/var/www/html/admin/modules/sak/agi/bwlist.agi") in new stack
-- Launched AGI Script /var/www/html/admin/modules/sak/agi/bwlist.agi
-- <IAX2/Trunkname-4938>AGI Script /var/www/html/admin/modules/sak/agi/bwlist.agi completed, returning 0
-- Executing [h@from-trunk:5] Set("IAX2/Trunkname-4938", "__CALLINGPRES_SV=allowed_not_screened") in new stack
-- Executing [h@from-trunk:6] Set("IAX2/Trunkname-4938", "CALLERPRES()=allowed_not_screened") in new stack
-- Executing [h@from-trunk:7] Goto("IAX2/Trunkname-4938", "app-blackhole,hangup,1") in new stack
-- Goto (app-blackhole,hangup,1)
-- Executing [hangup@app-blackhole:1] NoOp("IAX2/Trunkname-4938", "Blackhole Dest: Hangup") in new stack
-- Executing [hangup@app-blackhole:2] Hangup("IAX2/Trunkname-4938", "") in new stack
== Spawn extension (app-blackhole, hangup, 2) exited non-zero on 'IAX2/Trunkname-4938'

The problem (aside from the fact that it looks like some redundant code might be being executed, such as, /var/www/html/admin/modules/sak/agi/bwlist.agi is run twice) is that at this point the call simply comes back into the system again, causing an endless loop until the caller hangs up. The reason appears to be that in the Regular Expression White/Black List code, this part isn't happening:

-- Executing [s@app-blacklist-check:4] Answer("IAX2/Trunkname-10808", "") in new stack
-- Executing [s@app-blacklist-check:5] Wait("IAX2/Trunkname-10808", "1") in new stack
-- Executing [s@app-blacklist-check:6] Zapateller("IAX2/Trunkname-10808", "") in new stack
-- Executing [s@app-blacklist-check:7] Playback("IAX2/Trunkname-10808", "ss-noservice") in new stack
-- <IAX2/Trunkname-10808> Playing 'ss-noservice.ulaw' (language 'en')
-- Executing [s@app-blacklist-check:8] Hangup("IAX2/Trunkname-10808", "") in new stack

In particular, the problem is that in the original code, the call is answered, the zapateller tones and an announcement are played, and the hangup is sent. In the new code it appears that the hangup has no effect because the call was never answered in the first place. So after the hangup, the system thinks a new call is coming in and starts all over again. Another effect is that the call never gets recorded in the CDR.

This is occurring in a FreePBX 2.8 system. Hopefully this should be easy to fix?
 

tm1000

Schmoozecom INC/FreePBX
Joined
Dec 1, 2009
Messages
1,360
Reaction score
78
It would be helpful to know if the number was even matched against what you put in the reg-exp.

You can see that under the matched column.

Can you let me know
 
Joined
Jun 29, 2009
Messages
258
Reaction score
0
Thanks, it is working now… except, the Times Matched count stays at 0. This is the CLI output now.

-- Executing [9999999999@from-trunk:3] Gosub("IAX2/Trunkname-1572", "app-blacklist-check,s,1") in new stack
-- Executing [s@app-blacklist-check:1] GotoIf("IAX2/Trunkname-1572", "0?blacklisted") in new stack
-- Executing [s@app-blacklist-check:2] Set("IAX2/Trunkname-1572", "CALLED_BLACKLIST=1") in new stack
-- Executing [s@app-blacklist-check:3] Return("IAX2/Trunkname-1572", "") in new stack
-- Executing [9999999999@from-trunk:4] ExecIf("IAX2/Trunkname-1572", "0 ?Set(CALLERID(name)=1111111111)") in new stack
-- Executing [9999999999@from-trunk:5] AGI("IAX2/Trunkname-1572", "/var/www/html/admin/modules/sak/agi/bwlist.agi") in new stack
-- Launched AGI Script /var/www/html/admin/modules/sak/agi/bwlist.agi
-- AGI Script Executing Application: (WAIT) Options: (1)
-- AGI Script Executing Application: (Zapteller) Options: ()
-- Playing 'ss-noservice' (escape_digits=) (sample_offset 0)
-- <IAX2/Trunkname-1572>AGI Script /var/www/html/admin/modules/sak/agi/bwlist.agi completed, returning 4
== Spawn extension (from-trunk, 9999999999, 5) exited non-zero on 'IAX2/Trunkname-1572'
-- Executing [h@from-trunk:1] Set("IAX2/Trunkname-1572", "__FROM_DID=h") in new stack
-- Executing [h@from-trunk:2] Gosub("IAX2/Trunkname-1572", "app-blacklist-check,s,1") in new stack
-- Executing [s@app-blacklist-check:1] GotoIf("IAX2/Trunkname-1572", "0?blacklisted") in new stack
-- Executing [s@app-blacklist-check:2] Set("IAX2/Trunkname-1572", "CALLED_BLACKLIST=1") in new stack
-- Executing [s@app-blacklist-check:3] Return("IAX2/Trunkname-1572", "") in new stack
-- Executing [h@from-trunk:3] ExecIf("IAX2/Trunkname-1572", "0 ?Set(CALLERID(name)=1111111111)") in new stack
-- Executing [h@from-trunk:4] AGI("IAX2/Trunkname-1572", "/var/www/html/admin/modules/sak/agi/bwlist.agi") in new stack
-- Launched AGI Script /var/www/html/admin/modules/sak/agi/bwlist.agi
-- AGI Script Executing Application: (WAIT) Options: (1)
-- AGI Script Executing Application: (Zapteller) Options: ()
-- AGI Script Executing Application: (WAIT) Options: (1)
-- AGI Script Executing Application: (Zapteller()) Options: ()
-- <IAX2/Trunkname-1572>AGI Script /var/www/html/admin/modules/sak/agi/bwlist.agi completed, returning 0
-- Executing [h@from-trunk:5] Set("IAX2/Trunkname-1572", "__CALLINGPRES_SV=allowed_not_screened") in new stack
-- Executing [h@from-trunk:6] Set("IAX2/Trunkname-1572", "CALLERPRES()=allowed_not_screened") in new stack
-- Executing [h@from-trunk:7] Goto("IAX2/Trunkname-1572", "app-blackhole,hangup,1") in new stack
-- Goto (app-blackhole,hangup,1)
-- Executing [hangup@app-blackhole:1] NoOp("IAX2/Trunkname-1572", "Blackhole Dest: Hangup") in new stack
-- Executing [hangup@app-blackhole:2] Hangup("IAX2/Trunkname-1572", "") in new stack
== Spawn extension (app-blackhole, hangup, 2) exited non-zero on 'IAX2/Trunkname-1572'
-- Hungup 'IAX2/Trunkname-1572'

But after at least two successful blocks, the "Times Matched" still shows 0. If I have the rule in place, the call gets blocked, otherwise it doesn't.

I found another wrinkle, though. For the above tests I simply used an exact number match, that is, all ten digits. Next I tried using an actual regular expression, such as 999\d{7}, but when I try to save that the backslash disappears and what is saved is 999d{7}, which doesn't work (replace 999 with any area code).

If I instead use 999[0-9]{7} then it does work. Or, interestingly, if I submit the number with a double backslash, such as 999\\d{7}, then it gets saved with the single backslash 999\d{7} and that also does work. So it seems that it's an issue with the single backslash getting eaten at the time it is entered. If this can't be easily fixed, you might want to add a note to the page advising users to escape backslashes by using \\ when they want a \.

In all these tests, the count was never incremented on the "Deny" rule, but it does increment on the default "Permit" rule which is lowest in priority (only on "permitted" calls, of course). I've tried reloading the page, going to another page and coming back, etc. but the count doesn't increment, however as you can see the calls are definitely getting blocked when they match a blacklist pattern. I hope this info is useful to you.

EDIT: One other minor nit, after submitting a "Deny" pattern I find that the FIRST click of an "Order" arrow button doesn't do anything, but subsequent clicks do.
 

Members online

Forum statistics

Threads
25,810
Messages
167,752
Members
19,240
Latest member
nikko
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top