WWW.DUMAIS.IO
ARTICLES
OVERLAY NETWORKS WITH MY SDN CONTROLLERSIMPLE LEARNING SWITCH WITH OPENFLOWINSTALLING KUBERNETES MANUALLYWRITING A HYPERVISOR WITH INTEL VT-X CREATING YOUR OWN LINUX CONTAINERSVIRTIO DRIVER IMPLEMENTATIONNETWORKING IN MY OSESP8266 BASED IRRIGATION CONTROLLERLED STRIP CONTROLLER USING ESP8266.OPENVSWITCH ON SLACKWARESHA256 ASSEMBLY IMPLEMENTATIONPROCESS CONTEXT ID AND THE TLBTHREAD MANAGEMENT IN MY HOBBY OSENABLING MULTI-PROCESSORS IN MY HOBBY OSNEW HOME AUTOMATION SYSTEMINSTALLING AND USING DOCKER ON SLACKWARESYSTEM ON A CHIP EMULATORUSING JSSIP AND ASTERISK TO MAKE A WEBPHONEC++ WEBSOCKET SERVERSIP ATTACK BANNINGBLOCK CACHING AND WRITEBACKBEAGLEBONE BLACK BARE METAL DEVELOPEMENTARM BARE METAL DEVELOPMENTUSING EPOLLMEMORY PAGINGIMPLEMENTING HTTP DIGEST AUTHENTICATIONSTACK FRAME AND THE RED ZONE (X86_64)AVX/SSE AND CONTEXT SWITCHINGHOW TO ANSWER A QUESTION THE SMART WAY.REALTEK 8139 NETWORK CARD DRIVERREST INTERFACE ENGINECISCO 1760 AS AN FXS GATEWAYHOME AUTOMATION SYSTEMEZFLORA IRRIGATION SYSTEMSUMP PUMP MONITORINGBUILDING A HOSTED MAILSERVER SERVICEI AM NOW HOSTING MY OWN DNS AND MAIL SERVERS ON AMAZON EC2DEPLOYING A LAYER3 SWITCH ON MY NETWORKACD SERVER WITH RESIPROCATEC++ JSON LIBRARYIMPLEMENTING YOUR OWN MUTEX WITH CMPXCHGWAKEUPCALL SERVER USING RESIPROCATEFFT ON AMD64CLONING A HARD DRIVECONFIGURING AND USING KVM-QEMUUSING COUCHDBINSTALLING COUCHDB ON SLACKWARENGW100 MY OS AND EDXS/LSENGW100 - MY OSASTERISK FILTER APPLICATIONCISCO ROUTER CONFIGURATIONAASTRA 411 XML APPLICATIONSPA941 PHONEBOOKSPEEDTOUCH 780 DOCUMENTATIONAASTRA CONTACT LIST XML APPLICATIONAVR32 OS FOR NGW100ASTERISK SOUND INJECTION APPLICATIONNGW100 - DIFFERENT PROBLEMS AND SOLUTIONSAASTRA PRIME RATE XML APPLICATIONSPEEDTOUCH 780 CONFIGURATIONUSING COUCHDB WITH PHPAVR32 ASSEMBLY TIPAP7000 AND NGW100 ARCHITECTUREAASTRA WEATHER XML APPLICATIONNGW100 - GETTING STARTEDAASTRA ALI XML APPLICATION

ASTERISK FILTER APPLICATION

2012-02-25

Filter application

I use this application to manage a blacklist of telemarketers. Althought this could be easily done with a perl script, I'd rather have a real application for it. This application will allow you to define several groups. In each group, you add a list of callerID, an optional greeting message and a context/extension pair to jump to. If the callerID of an incomming call matches a callerID defined in a group, the group's greeting message will be played and the dialplan will jump to the context/extension defined for that group. If no greeting is defined, none will be played. If no context/extension pair is defined, dialplan execution will continue normaly.

Compiling and Installing

After downloading app_filter.c, copy the file in your asterisk source three and compile it. In my example, I am assuming that your asterisk source code is in /usr/src/asterisk-1.4.21.1/apps/ and that your modules are located in /usr/lib/asterisk/modules/.

cp app_filter.c /usr/src/asterisk-1.4.21.1/apps/ cd /usr/src/asterisk-1.4.21.1 make apps cp apps/app_filter.so /usr/lib/asterisk/modules/

next, go into the asterisk CLI and load the module using "module load app_filter.so". Of course it is also possible to have the module loaded automatically using /etc/asterisk/modules.conf. Now you are ready to use the module

Configuration

You must first create /etc/asterisk/filter.conf. Add the following:

[general] dbtype => 0

"dbtype" must be set to 0 if the same configuration file is going to be used for defining filter groups. Set dbtype to 1 if you prefer mysql. If you are going to be using mysql, you can skip to the next section. Otherwise, here's how to do it. Note that the configuration file is read each time that Filter() is called

You can several sections, in the file. In each section, add as many callerIDs as you want using the "cid:" directive. Define an optional greeting with "greeting", context with "context" and extension to "exten" Complete example:

[general] dbtype => 0 [test1] cid => 1001234567 cid => 1001234566 greeting => greeting1 ; do not add the extension. This file must be present in /var/lib/asterisk/sounds [test2] cid => 1001234565 cid => 1001234564 greeting => not-welcome context => telemarketer-torture exten => s

In this example, caller with callerID 100-123-4565 will hear the "not-welcome.wav" greeting message and will be redirected to extension "s" in the "telemarketer-torture" context

Configuration with mysql

mysql support is not implemented yet

Dialplan

Here is how you should use it in the dialplan:

exten => s,1,Answer() exten => s,2,Filter()

Download

The source code can be found here: app_filter.c