Author Topic: Blacklist  (Read 7426 times)

Roman

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • View Profile
Blacklist
« on: September 26, 2009, 11:31:56 AM »
I want to make a suggestion since I have no idea how to create packages for askozia.
There is a LookupBlacklist cmd for Asterisk. It would be very nice to have a web interface based editor. Possible features:
- feed the database with new ID's (family 'blacklist')
- enable / disable global blacklisting
- enable / disable for each extension
- forward blacklisted ID's to a voice mail account
- save to / load from a file / load from a url

devon

  • Full Member
  • ***
  • Posts: 98
  • Karma: 4
    • View Profile
Re: Blacklist
« Reply #1 on: October 09, 2009, 03:16:39 AM »
From Askozia's manager interface:

#help database put
       Usage: database put <family> <key> <value>
       Adds or updates an entry in the Asterisk database for
       a given family, key, and value.

From the element library:

DB(/)

This function will read from or write a value to the Asterisk database.  On a
read, this function returns the corresponding value from the database, or blank
if it does not exist.  Reading a database value will also set the variable
DB_RESULT.  If you wish to find out if an entry exists, use the DB_EXISTS
function.


DB_DELETE(/)

This function will retrieve a value from the Asterisk database
 and then remove that key from the database.  DB_RESULT
will be set to the key's value if it exists.


DB_EXISTS(/)

This function will check to see if a key exists in the Asterisk
database. If it exists, the function will return "1". If not,
it will return "0".  Checking for existence of a database key will
also set the variable DB_RESULT to the key's value if it exists.

Anyone willing to write an application to check an incoming call against an asterisk database?

devon

  • Full Member
  • ***
  • Posts: 98
  • Karma: 4
    • View Profile
Re: Blacklist
« Reply #2 on: October 10, 2009, 06:31:06 AM »
This application does the following:
Passes the call to voicemail if callerid number is blank.
Looks up the number in the database and dials SIP/100 if found and value is 'permit.'
Adds the calling number to the database if it does not already exist.


Code: [Select]
1,GotoIf($[${ISNULL(${CALLERID(num)})}=0]?2:6)
2,GotoIf(${DB_EXISTS(blacklist/${CALLERID(num)})}=0?3:4)
3,GotoIf($[${DB_RESULT}=permit]?5:6)
4,Set(DB(blacklist/${CALLERID(num)})=permit)
5,Dial(SIP/100|25|to)
6,Voicemail(300|u|5551234567)
7,Hangup()

In Diagnostics: Manager Interface:

1. show existing entries in blacklist database:
database show blacklist

2. add or update blacklist database:
database put blacklist 1234567 reject

The database does not survive reboots unless the /usr/local/share/asterisk/astdb file is copied to /storage and linked with a <earlyshellcmd> tag.

devon

<comment>removed 1,Answer() and added voicemail redirect for NULL CALLERID(num)</comment>
« Last Edit: October 10, 2009, 11:39:05 PM by devon »

giovanni.v

  • Hero Member
  • *****
  • Posts: 694
  • Karma: 53
    • View Profile
    • BoneOS SDK &  TeeBX VoIP communication platform
Re: Blacklist
« Reply #3 on: October 10, 2009, 06:24:05 PM »
Code: [Select]
1,Answer()

Isn't a good habit answering the call in this scenario, i think the first line should be removed to let the destination answering that call when they really pick up it.


... damn computer please write what "i meant to say"...
« Last Edit: October 10, 2009, 08:07:02 PM by giovanni.v »

devon

  • Full Member
  • ***
  • Posts: 98
  • Karma: 4
    • View Profile
Re: Blacklist
« Reply #4 on: October 10, 2009, 06:48:10 PM »
i think the fist line should be removed
I agree, I've removed the line in my application and also added a redirect to voicemail when CALLERID(num) is NULL, instead of hanging up.

regards,
devon



devon

  • Full Member
  • ***
  • Posts: 98
  • Karma: 4
    • View Profile
Re: Blacklist
« Reply #5 on: October 17, 2009, 02:56:33 AM »
It would be very nice to have a web interface based editor

I found a web based Asterisk database maintenance script written in php on voip-info.org and modified it for use with AskoziaPBX. The original author is ubergoober and the original script is here.

This package allows one to view, add, modify and delete the 'key' and 'value' of database family 'blacklist' from within the webgui.

This is but a part of a larger whole, one still needs to make the database persistent (giovanni's Astmedia package has an option for db persistence or one could use the astdb package included below) and needs an application (like the application in my previous post) to lookup and process incoming calls. I'm not going to try to put this into a comprehensive package. Maybe someone here can use this code as a starting point for a complete package or at least as an example of what not to do.

blacklist_0.1 (webgui blacklist database editor) download 3kb package

astdb_0.1 (adds db persistence) download 1kb package

cheers,
devon

van_nostran

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
Re: Blacklist
« Reply #6 on: April 06, 2010, 08:41:17 PM »
any volunteers to pick up where devon left off on this one?