Here is how I use it in my dialplan.  This subroutine is called on every
DID...

[globals]
PRIVACY_MGR_VOICEMAIL = voicemenu-custom-3
PRIVACY_MGR_EXTEN = local/601@ringgroups
PRIVACY_MGR_IVR = voicemenu-custom-2

[default]
exten = s,1,Gosub(check-private,s,1)
exten = s,n,NoOp(do whatever you would normally do)

[check-private]
; Subroutine to check callerID number against whitelist, blacklist,
anonymous callers
; and to implement Privacy Manager.
; Constants must be set in [globals] section of this file...
;    PRIVACY_MGR_VOICEMAIL = context to handle voicemail, will branch to s,1
;    PRIVACY_MGR_IVR = context to handle IVR, will branch to s,1
;    PRIVACY_MGR_EXTEN = internal extension to ring, eg.
local/601@ringgroups
; If caller presses 0 (zero) during prompt to leave name, then they can
enter PIN to bypass
; leaving an introduction message. PINs are retrieved from the Asterisk DB
Whitelist.
exten = s,1,NoOp(PrivacyManager - ${CALLERID(name)} ${CALLERID(num)}
${CALLERID(ani)})
;exten = s,n,Log(NOTICE,PrivacyManager - ${CALLERID(name)} ${CALLERID(num)}
${CALLERID(ani)} ${CALLERID(dnid)} )
exten = s,n,Set(PRIVACY_MGR_RETVAL=0)
exten = s,n,Ringing()
; First lookup number in asterisk DB for a Caller ID name.
exten =
s,n,Set(CALLERID(name)=${IF(${DB_EXISTS(cidname/${CALLERID(num)})}?${DB_RESULT}:${CALLERID(name)})})
; Now check against whitelist.
exten = s,n,GotoIf(${DB_EXISTS(whitelist/${CALLERID(num)})}?onwhitelist)
; Not on whitelist, check it against blacklist
exten = s,n,GotoIf(${DB_EXISTS(blacklist/${CALLERID(num)})}?onblacklist)
; Not on blacklist either, check Caller ID number for anonymous
conditions...
; If all zeros (with or without international dialing + sign) then caller is
anonymous.
exten = s,n,GotoIf($[${REGEX("^[+]?0+$" ${CALLERID(num)})} = 1]?unknown)
; If Caller ID is not a number at least 4 digits long (with or without +
sign)
; then caller is assumed to be anonymous. Alphabetic Caller ID "numbers"
; will therefore be considered anonymous. Common numbers for anonymous
callers
; are: "asterisk, unknown, anonymous, private, unavailable" which may be
upper, lower
; or mixed case. The regular expression catches everything non-numeric.
; If you want to permit a specific non-numeric Caller ID "number" add it to
whitelist.
exten = s,n,GotoIf($[${REGEX("^[+]?[0-9]{4\,}$" ${CALLERID(num)})} !=
1]?unknown)
; Caller ID looks good. Return to continue with dialplan processing.
exten = s,n,Return()
; Anonymous caller. Set Caller ID name to "Privacy Manager"...
exten = s,n(unknown),Set(CALLERID(name)="Privacy Manager")
exten = s,n,Set(CDR(userfield)=Anonymous)
exten = s,n,Goto(privacymgr,1)
; Caller is on whitelist...
exten = s,n(onwhitelist),Set(CDR(userfield)=Whitelist)
exten = s,n,Goto(whitelist,1)
; Caller is on blacklist...
exten = s,n(onblacklist),Set(CDR(userfield)=Blacklist)
exten = s,n,Goto(blacklist,1)
; Implement privacy manager. Play a message to caller, record introduction,
dial callee...
exten = privacymgr,1,Answer()
exten = privacymgr,n,Ringing()
exten = privacymgr,n,Wait(2)
exten = privacymgr,n,GoSub(check-vacation,s,1)
exten = privacymgr,n,Set(myringtime=${IF($[${ONVACATION}=1]?8:20)})
exten = privacymgr,n,GoSub(check-time,s,1)
exten = privacymgr,n,Background(privacy-unident&vm-rec-name,m)  ; Asterisk
1.8
;exten = privacymgr,n,NVBackgroundDetect(privacy-unident,t)  ;Asterisk 1.4
;exten = privacymgr,n,NVBackgroundDetect(vm-rec-name,t)  ;Asterisk 1.4
exten =
privacymgr,n,Set(SCREEN_FILE=/tmp/ast-priv-${FILTER(0123456789,${UNIQUEID})})
exten = privacymgr,n,Record(${SCREEN_FILE}.gsm,4,5)
exten = privacymgr,n,Background(priv-introsaved,m)
; Caller has recorded a message. Dial inbound extension. If extension
answers then pass
; control to macro-call-screen that will inform callee of the Anonymous
caller.
; UniqueID is passed as parameter so that we can capture a return value from
the macro.
exten =
privacymgr,n,Dial(${PRIVACY_MGR_EXTEN},${myringtime},gmM(call-screen^${SCREEN_FILE}^${UNIQUEID}))
; We are back from the call. First delete the recorded file, then act on the
return code...
exten = privacymgr,n,System(rm ${SCREEN_FILE}.gsm)
exten = privacymgr,n,Goto(privacymgr-${DIALSTATUS},1)
; Callee extension answered. Check whether they accepted the caller or just
hungup...
exten = privacymgr-ANSWER,1,Set(CDR(userfield)=${CDR(userfield)}-Ignore)
; If hangup without accepting then go to voicemail, else just hangup...
exten = privacymgr-ANSWER,n,GotoIf($[${${UNIQUEID}} != 1]?voicemail,1)
exten = privacymgr-ANSWER,n,Set(CDR(userfield)=${CDR(userfield)}-Answer)
exten = privacymgr-ANSWER,n,Hangup()
; Callee extension did not answer...
exten = privacymgr-NOANSWER,1,Set(CDR(userfield)=${CDR(userfield)}-NoAnswer)
exten = privacymgr-NOANSWER,n,Goto(voicemail,1)
; Callee extension was busy...
exten = privacymgr-BUSY,1,Set(CDR(userfield)=${CDR(userfield)}-Busy)
exten = privacymgr-BUSY,n,Goto(voicemail,1)
exten = _privacymgr-!,1,Log(WARNING,Unhandled Dial Status in Privacy
Manager: ${DIALSTATUS})
exten = _privacymgr-!,n,Goto(voicemail,1)
; Caller is on whitelist, or authenticated with whitelisted number...
exten = whitelist,1,Set(WL_ACTION=${DB_RESULT})
exten =
whitelist,n,Set(CALLERID(name)=${IF(${DB_EXISTS(whitelistcomment/${CALLERID(num)})}?${DB_RESULT}:${CALLERID(name)})})
exten = whitelist,n,Goto(whitelist-${WL_ACTION},1)
exten = whitelist-0,1,Goto(whitelist-voicemail,1)
exten = whitelist-1,1,Goto(whitelist-priority,1)
exten = whitelist-2,1,Goto(whitelist-standard,1)
exten = whitelist-3,1,Goto(whitelist-follow-me,1)
exten = whitelist-4,1,Goto(whitelist-ivr,1)
exten = whitelist-5,1,Goto(whitelist-google,1)
exten =
whitelist-voicemail,1,Set(CDR(userfield)=${CDR(userfield)}-Voicemail)
exten = whitelist-voicemail,n,Wait(2)
exten = whitelist-voicemail,n,Goto(voicemail,1)
exten = whitelist-priority,1,Set(CDR(userfield)=${CDR(userfield)}-Priority)
exten = whitelist-priority,n,Set(PRIVACY_MGR_RETVAL=priority)
exten =
whitelist-priority,n,Goto(${CUT(PRIVACY_MGR_EXTEN,@,2)},${CUT(CUT(PRIVACY_MGR_EXTEN,@,1),/,2)},1);
exten = whitelist-priority,n,Return()
exten = whitelist-standard,1,Set(CDR(userfield)=${CDR(userfield)}-Standard)
exten = whitelist-standard,n,Set(PRIVACY_MGR_RETVAL=standard)
exten = whitelist-standard,n,Return()
exten = whitelist-follow-me,1,Set(CDR(userfield)=${CDR(userfield)}-FollowMe)
exten = whitelist-follow-me,n,Set(PRIVACY_MGR_RETVAL=followme)
exten = whitelist-follow-me,n,Return()
exten = whitelist-ivr,1,Set(CDR(userfield)=${CDR(userfield)}-IVR)
exten = whitelist-ivr,n,Goto(${PRIVACY_MGR_IVR},s,1)
exten = whitelist-google,1,Set(CDR(userfield)=${CDR(userfield)}-Google)
exten = whitelist-google,n,Set(PRIVACY_MGR_RETVAL=google)
exten = whitelist-google,n,Return()
exten = _whitelist-!,1,Log(WARNING,Unrecognized whitelist action:
${WL_ACTION})
exten = _whitelist-!,n,Return()
; Caller is on blacklist...
exten = blacklist,1,Ringing()
exten = blacklist,n,Goto(blacklist-${DB_RESULT},1)
exten = blacklist-0,1,Goto(blacklist-noanswer,1)
exten = blacklist-1,1,Goto(blacklist-zapateller,1)
exten = blacklist-2,1,Goto(blacklist-voicemail,1)
exten = blacklist-3,1,Goto(blacklist-privacymgr,1)
exten =
blacklist-voicemail,1,Set(CDR(userfield)=${CDR(userfield)}-Voicemail)
exten = blacklist-voicemail,n,Wait(2)
exten = blacklist-voicemail,n,Goto(voicemail,1)
exten = blacklist-noanswer,1,Set(CDR(userfield)=${CDR(userfield)}-NoAnswer)
exten = blacklist-noanswer,n,wait(45)
exten = blacklist-noanswer,n,Hangup()
exten =
blacklist-zapateller,1,Set(CDR(userfield)=${CDR(userfield)}-Zapateller)
exten = blacklist-zapateller,n,Zapateller(answer)
exten = blacklist-zapateller,n,Playback(discon-or-out-of-service)
exten = blacklist-zapateller,n,Hangup()
exten =
blacklist-privacymgr,1,Set(CDR(userfield)=${CDR(userfield)}-PrivacyMgr)
exten = blacklist-privacymgr,n,Goto(privacymgr,1)
exten = _blacklist-!,1,Log(WARNING,Unrecognized blacklist action:
${DB_RESULT})
exten = _blacklist-!,n,Goto(voicemail,1)
; Send caller to voicemail...
exten = voicemail,1,Goto(${PRIVACY_MGR_VOICEMAIL},s,1)
; Handle invalid key pressed...
exten = i,1,Playback(call-terminated&goodbye)
exten = i,n,Set(CDR(userfield)=${CDR(userfield)}-Invalid)
exten = i,n,Hangup()
; Handle timeout situation...
exten = t,1,Playback(call-terminated&goodbye)
exten = t,n,Set(CDR(userfield)=${CDR(userfield)}-Timeout)
exten = t,n,Hangup()
; Caller hangs up...
exten = h,1,Set(CDR(userfield)=${CDR(userfield)}-Hungup)
exten = h,n,Hangup()
; Caller interrupted prompts by pressing 0 (zero). This is an escape to let
caller
; authenticate themselves with a PIN, thereby bypassing need to record their
name...
exten = 0,1,Authenticate(/whitelist,da,4)
exten = 0,n,Set(CDR(userfield)=${CDR(userfield)}-PIN OK)
exten = 0,n,Set(CALLERID(ani)=${CDR(accountcode)})
exten = 0,n,Set(CALLERID(num)=${CDR(accountcode)})
exten = 0,n,Set(DB_RESULT=${DB(whitelist/${CDR(accountcode)})})
exten = 0,n,Goto(whitelist,1)
; Fax detected
exten = fax,1,Gosub(fax-rx,s,1)
exten = fax,n,Hangup()
exten = fax,n,Return()

[macro-call-screen]
; This macro executes when an internal extension answers a call from an
anonymous caller
; handled by check-private subroutine (Privacy Manager)
exten = s,1,Set(TIMEOUT(response)=5)
exten = s,n,Set(GLOBAL(${ARG2})=0)
exten = s,n,Background(priv-callpending,m,en,macro-call-screen)
;playback recording caller made, then delete temporary file.
exten = s,n,Background(${ARG1},m,en,macro-call-screen)
exten = s,n,System(rm ${ARG1}.gsm)
exten = s,n(repeat-options),Read(ACCEPT-CALL,followme/options,1)
exten = s,n,GotoIf($["${ACCEPT-CALL}" = ""] ?t,1)  ;timeout, no digit
pressed
exten = s,n,GotoIf($[${ACCEPT-CALL} = 1] ?call-accepted)
exten = s,n,GotoIf($[${ACCEPT-CALL} = 2] ?call-declined:repeat-options)
; If callee rejects the call they are thanked and the caller is passed onto
an IVR
; menu with more options, like leaving a voicemail
exten = s,n(call-declined),Playback(privacy-thankyou)
exten = s,n,Set(MACRO_RESULT=GOTO:${check-private^voicemail^1)
exten = s,n,MacroExit()
; If callee accepts the call then they are thanked and the macro exits,
which will
; automatically bridge the caller and callee together. We set the following
global to
; indicate that we accetped the call
exten = s,n(call-accepted),Playback(privacy-thankyou)
exten = s,n,Set(GLOBAL(${ARG2})=1)
exten = s,n,MacroExit()
; Handle timeout situation.
exten = t,1,Goto(s,call-declined)
; Press 1 to accept the call.
exten = 1,1,Goto(macro-call-screen,s,call-accepted)
; Press 2 to reject the call.
exten = 2,1,Goto(macro-call-screen,s,call-declined)

On Mon, Oct 3, 2011 at 5:24 PM, Fernando Fuentes <digitaldis...@gmail.com>wrote:

> I was wondering if anybody was using the blacklist option?
> I have generated a DB under the blacklist tab but I am not sure how to
> actually make the blacklist work.
> For some reason I thought that I could generate the list and they would get
> blocked base on that list without having to make any modifications to my
> conf files.
> I am only asking because calls are still coming in.
>
> Thank You!
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
> _______________________________________________
> Astlinux-users mailing list
> Astlinux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/astlinux-users
>
> Donations to support AstLinux are graciously accepted via PayPal to
> pay...@krisk.org.
>
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Astlinux-users mailing list
Astlinux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/astlinux-users

Donations to support AstLinux are graciously accepted via PayPal to 
pay...@krisk.org.

Reply via email to