[asterisk-users] fax - sound/tone - dealing with SPAM

Doug Lytle support at drdos.info
Thu Apr 4 18:54:47 CDT 2013


Joseph wrote:
> Can you please share more details, is it done via dial plan? 

We use extension 2000.


You'll need to added the 'check_blacklist' sub-routine to the inbound 
parts of your dial plan.


-------------- next part --------------

[tele_torture]

exten => 2000,1,GotoIf($["${CALLERID(number)}" = "0"]?7:2)
exten => 2000,n,Gosub(todays_date,s,1)
exten => 2000,n,Gosub(tele_query,s,1)
exten => 2000,n,NoOP(${torture.calls})
exten => 2000,n,GosubIf($["${torture.calls}" = "1"]?tele_insert,s,1)
exten => 2000,n,GosubIf($["${torture.calls}" = "2"]?tele_blacklist,s,1)


;*Death to telemarketers
exten => 2000,n,Answer()
exten => 2000,n,Set(CDR(userfield)=Torture)
exten => 2000,n,SetMusicOnHold(conference)
exten => 2000,n,WaitMusicOnHold(30)
exten => 2000,n,Wait(1.5)
exten => 2000,n,Playback(pls-hold-while-try)
exten => 2000,n,Ringing()
exten => 2000,n,Wait(25)
exten => 2000,n,Goto,10

[tele_query]

exten => s,1,Set(torture.calls=0)
exten => s,n,MYSQL(Connect connid localhost username 'password' torture)
exten => s,n,GosubIf($["${MYSQL_STATUS}" = "-1"]?mysql_failed,s,6)
exten => s,n,MYSQL(Query resultid ${connid} SELECT phone \, calls \, name FROM Facility WHERE phone = "${CALLERID(number)}")
exten => s,n,MYSQL(Fetch fetchid ${resultid} torture.phone torture.calls torture.name)
exten => s,n,MYSQL(Disconnect ${connid})
exten => s,n,MYSQL(Clear ${resultid})
exten => s,n,Set(torture.calls=${IF($[ ${torture.calls} = 1]?2:1)})
exten => s,n,Return()

[tele_insert]

exten => s,1,MYSQL(Connect connid 192.168.104.122 username 'password' torture)
exten => s,n,GosubIf($["${MYSQL_STATUS}" = "-1"]?mysql_failed,s,6)
exten => s,n,MYSQL(Query resultid ${connid} INSERT INTO Facility set phone="${CALLERID(number)}" \, calls="${torture.calls}" \, name="${CALLERID(number)}" \, time_date="${TODAY}")
exten => s,n,MYSQL(Disconnect ${connid})

exten => s,n,System(/usr/local/bin/scripts/add_watchlist_email.sh operator at mydomain.com ${CALLERID(number)} ${TODAY})
exten => s,n,Return()

[tele_blacklist]

exten => s,1,MYSQL(Connect connid 192.168.104.122 username 'password' blacklisted)
exten => s,n,GosubIf($["${MYSQL_STATUS}" = "-1"]?mysql_failed,s,6)
exten => s,n,MYSQL(Query resultid ${connid} INSERT INTO Facility set phone="${CALLERID(number)}" \, flag="YES" \, note="Blacklisted by Tele-Torture - ${TODAY}")
exten => s,n,MYSQL(Disconnect ${connid})

exten => s,n,System(/usr/local/bin/scripts/add_blacklist_email.sh operator at mydomain.com ${CALLERID(number)} ${TODAY})
exten => s,n,Return()

[check_blacklist]

exten => s,1,GotoIf($["${CALLERID(num)}" = "" ]?2:3)
exten => s,n,Set(CALLERID(all)=Restricted <0>)
exten => s,n,MYSQL(Connect connid localhost username 'password' blacklisted)
exten => s,n,GosubIf($["${MYSQL_STATUS}" = "-1"]?mysql_failed,s,6)
exten => s,n,MYSQL(Query resultid ${connid} SELECT flag \, note FROM Facility WHERE phone = ${CALLERID(num)})
exten => s,n,MYSQL(Fetch fetchid ${resultid} results note)
exten => s,n,MYSQL(Disconnect ${connid})
exten => s,n,MYSQL(Clear ${resultid})
exten => s,n,Set(BLACKLISTED=${results})
exten => s,n,GotoIf($["${BLACKLISTED}" = "YES"]?blacklisted,s,1)
exten => s,n,NoOP(Caller not blacklisted)
exten => s,n,Return

[blacklisted]

exten => s,1,NoOP(Caller: ${CALLERID(num)} is on the black list)
exten => s,n,NoOP(NOTE: ${note})
exten => s,n,Set(CDR(userfield)=Blacklisted)
exten => s,n,Zapateller(answer)
exten => s,n,Hangup(2)


More information about the asterisk-users mailing list