我为我的来电实现了一个简单的黑名单。我遇到的问题是,当黑名单上的人打来电话时,我的手机不再响了(这部分很好),但黑名单上的电话不挂断(这就是问题所在)。
extensions.conf中的传入上下文:
exten => 12225551234,1,Zapateller(nocallerid)
same => n,GotoIf(${BLACKLIST()}?hangup)
same => n,Dial(SIP/myphone)
same => n(hangup),Hangup()
添加黑名单号码:
CLI> database put blacklist +14445554321 "Blacklisted for testing"
从黑名单14445554321呼叫12225551234…通过CLI界面看到:
== Using SIP RTP CoS mark 5
-- Executing [12225551234@from-sipProvider:1] GotoIf("SIP/sipProvider_did9-00000738", "1?hangup") in new stack
-- Goto (from-sipProvider,12225551234,5)
-- Executing [12225551234@from-sipProvider:5] Hangup("SIP/sipProvider_did9-00000738", "") in new stack
== Spawn extension (from-sipProvider, 12225551234, 5) exited non-zero on 'SIP/sipProvider_did9-00000738'
== Using SIP RTP CoS mark 5
-- Executing [12225551234@from-sipProvider:1] GotoIf("SIP/sipProvider_did10-00000739", "1?hangup") in new stack
-- Goto (from-sipProvider,12225551234,5)
-- Executing [12225551234@from-sipProvider:5] Hangup("SIP/sipProvider_did10-00000739", "") in new stack
== Spawn extension (from-sipProvider, 12225551234, 5) exited non-zero on 'SIP/sipProvider_did10-00000739'
== Using SIP RTP CoS mark 5
-- Executing [12225551234@from-sipProvider:1] GotoIf("SIP/sipProvider_did9-0000073a", "1?hangup") in new stack
-- Goto (from-sipProvider,12225551234,5)
-- Executing [12225551234@from-sipProvider:5] Hangup("SIP/sipProvider_did9-0000073a", "") in new stack
== Spawn extension (from-sipProvider, 12225551234, 5) exited non-zero on 'SIP/sipProvider_did9-0000073a'
直到被阻塞的调用方挂机为止。最后,大约50秒后,如果打电话的人没有挂断电话,他会听到铃声。我得挂掉他的电话,否则他不挂电话我就要被收费了。
挂电话前试着接一下。这是我使用的:
exten => 12225551234,1,Zapateller(nocallerid)
same => n,GotoIf(${BLACKLIST()}?badlist,s,1)
same => n,Dial(SIP/myphone)
same => n,Hangup()
[badlist]
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Playback(ss-noservice)
exten => s,n,Hangup