Using Dynamic Routes for personal Block/Allow Lists

A recent feature request from forum user @glsarto for the Allow List module to accommodate personal, per-extension allow lists made me realize that this can mostly be done using the dynroutes module, Contact Manager and an AGI file I wrote some time ago. It can also be used with some minor tweaks to act as a per-extension block list.

Step 1 - Get the AGI

You want to get the most recent version of the AGI from this source and confirm the URL to the raw file, then

# cd /var/lib/asterisk/agi-bin
# wget
# chown asterisk:asterisk lgaetz-cmcheck.php
# chmod +x lgaetz-cmcheck.php

Step 2 - Create a Contact Management group

You can create a public group in the Admin GUI, or it can be a private group created by logging into the UCP. For this example, I have a private group called private-6006, but the name is arbitrary. Populate the contact management group with numbers.
Step 3 - Create Dynamic Route
Create a new dynroute with dtmf input disabled. Source type is set to AGI, substitutions is enabled, set the AGI lookup expression to this:


and then set the AGI Result Variable to whitelist. In the GUI it will look like this:

The AGI file will search the specified contact manager group name for the caller’s CID. If there is an exact match, it will return true, and if not, it will return false. Under dynamic route entries, create a separate freepbx destination for true and false, and you are good to go. By reversing the actions of true and false, you can change the operation from allowlist to blocklist.

Once the dynroute exists, you edit the inbound route to go to the new dynroute. Users can control which numbers get thru by editing their contact manager group in UCP, or admins can do it in the Admin GUI. This will function pretty much exactly like the blacklist and allowlist module, except there is no feature code that will allow you to add the last number.


This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.