我最近遇到一个问题,就是在海外国家的白天和晚上的所有时间接听电话。我试图按国家/地区代码将整个国家/地区列入黑名单。谷歌搜索后,我提出了以下解决方案,但不要认为它正在工作......因为我尝试替换我自己的区号,但这不起作用。
编码看起来是否正确?
另外,我并不完全理解[+]?1?
部分,并希望细分。
仅供参考,我确实有一个按编号设置的黑名单,所以我知道[blacklisted]
上下文部分有效。
extentions.conf:
;; same => n,Set(regx=^[+]?1?(215|609)[0-9]{7}$) ;; my test
same => n,Set(regx=^[+]?1?(252|96|27)[0-9]{9}$)
same => n,GotoIf($[${REGEX(“${regx}” ${CALLERID(num)})} = 1]?blacklisted,s,1)
[blacklisted]
exten => s,1,Answer
exten => s,n,Hangup
我想阻止的数字示例:
+252616251444
+252616531860
+27612238445
+96893327281
我要阻止的测试号码为1-609-123-4567
。
这是我的extension.conf:
[from-Provider]
exten => _X.,1,Set(CALLERID(num)=${CALLERID(num):1})
exten => 17025551234,1,Zapateller(nocallerid)
exten => _XX./_+252X.,n,Goto(blacklisted,s,1)
exten => _XX./_+1609X.,n,Goto(blacklisted,s,1)
same => n,GotoIf(${BLACKLIST()}?blacklisted,s,1)
same => n,Dial(SIP/home&IAX2/droid&SIP/office)
same => n,Hangup()
[blacklisted]
exten => s,1,Answer
exten => s,n,Hangup
这是应该通过的电话的结果。它被阻止并吐出此输出,直到调用者挂断。
CLI输出:
== Using SIP RTP CoS mark 5
-- Executing [17025551234@from-Provider:1] Zapateller("SIP/Provider_did10-00000080", "nocallerid") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did10-00000080' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234@from-Provider:1] Zapateller("SIP/Provider_did9-00000081", "nocallerid") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-00000081' status is 'UNKNOWN'
...
-- Executing [17025551234@from-Provider:1] Zapateller("SIP/Provider_did9-00000088", "nocallerid") in new stack
== Spawn extension (from-Provider, 17025551234, 1) exited non-zero on 'SIP/Provider_did9-00000088'
编辑(添加了针对callerid的noop)
我用你的字母替换了你的拨号方案。问题是没有电话通过。
我想我看到了我的问题。我需要包含exten => 17025551234,1,Zapateller(nocallerid)
,因为那是我的DID。我不知道放在哪里。
这是CLI输出。无论是应该通过还是应该被阻止的呼叫都是一样的......
== Using SIP RTP CoS mark 5
-- Executing [17025551234@from-Provider:1] Set("SIP/Provider_did10-000000ec", "CALLERID(num)=16175551234") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did10-000000ec' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234@from-Provider:1] Set("SIP/Provider_did9-000000ed", "CALLERID(num)=16175551234") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-000000ed' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234@from-Provider:1] Set("SIP/Provider_did9-000000ee", "CALLERID(num)=16175551234") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-000000ee' status is 'UNKNOWN'
EDIT(extensions.conf):
[globals]
[default]
exten => 1001,1,Progress()
exten => 1001,n,Answer()
exten => 1001,n,Playback(hello-world)
exten => 1001,n,Hangup()
[internal]
exten => 100,1,Dial(SIP/home)
same => n,Hangup()
exten => home,1,Dial(SIP/home)
same => n,Hangup()
exten => 103,1,Dial(SIP/office)
same => n,Hangup()
include => default
include => iax2
[iax2]
exten => 10,1,Dial(SIP/home)
same => n,Hangup()
exten => 11,1,Dial(IAX2/droid)
same => n,Hangup()
exten => 12,1,Dial(SIP/home&IAX2/droid)
same => n,Hangup()
exten => 20,1,Dial(IAX2/clive)
same => n,Hangup()
include => default
[from-Provider]
exten => _X.,1,Set(CALLERID(num)=${CALLERID(num):1})
exten => 17025551234,1,Zapateller(nocallerid)
same => n,Noop(CALLERID=${CALLERID(all)})
same => n,GotoIf(${BLACKLIST()}?blacklisted,s,1)
same => n,Dial(SIP/home&IAX2/droid&SIP/office)
same => n,Hangup()
exten => 442035551234,1,Zapateller(nocallerid)
same => n,Set(regx=^[+]?1?(252|96|27)[0-9]{9}$)
same => n,GotoIf($[${REGEX("${regx}" ${CALLERID(num)})} = 1]?blacklisted,s,1)
same => n,GotoIf(${BLACKLIST()}?blacklisted,s,1)
same => n,Dial(SIP/home&IAX2/droid&SIP/office)
same => n,Hangup()
[blacklisted]
exten => s,1,Answer
exten => s,n,Hangup
我有两个DID。一个在美国17025551234
,一个在英国442035551234
。我没有干线。
编辑(使用ESYSCODER上下文输出CLI)
我已完全按照您发布的内容替换了整个[from-Provider]上下文。然后,我从不应拒绝的号码17025551234
拨打了我的DID号码17025550000
(显然我正在更改隐私问题的号码)。
CLI输出如下:
com1*CLI>
-- Executing [17025551234@from-Provider:1] Set("SIP/Provider_did9-00000012", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-00000012' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234@from-Provider:1] Set("SIP/Provider_did10-00000013", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did10-00000013' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234@from-Provider:1] Set("SIP/Provider_did10-00000014", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did10-00000014' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234@from-Provider:1] Set("SIP/Provider_did9-00000015", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-00000015' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234@from-Provider:1] Set("SIP/Provider_did9-00000016", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-00000016' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234@from-Provider:1] Set("SIP/Provider_did10-00000017", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did10-00000017' status is 'UNKNOWN'
com1*CLI>
让我感到困惑的是,我必须拥有exten => 17025551234,1,Zapateller(nocallerid)
行才能让DID 17025551234
接听。哪个应该适合您建议的拨号方案/上下文。或者我错过了什么。当我的DID号码响铃时,还有另一种方法可以回答吗?对不起,如果我在这里很厚......我可能会错过一个简单的观点。
编辑(优先级更改)
通过以下上下文,来电者会收到一条消息:“您拨打的号码不在服务中”...
[from-didforsale]
exten => _XX./_1609123456X,1,Goto(blacklisted,s,1)
exten => _XX.,n,GotoIf(${BLACKLIST()}?blacklisted,s,1)
exten => _XX.,n,Noop(CALLERID=${CALLERID(all)})
exten => _XX.,n,Dial(SIP/home&IAX2/droid&SIP/office)
exten => _XX.,n,Hangup()
这是CLI输出:
== Using SIP RTP CoS mark 5
[Nov 24 09:08:13] NOTICE[2957]: chan_sip.c:23613 handle_request_invite: Call from 'didforsale_did9' (209.216.15.70:5060) to extension '13022323111' rejected because extension not found in context 'from-didforsale'.
我在注释掉;;exten => _XX./_1609123456X,1,Goto(blacklisted,s,1)
不是拨号方案序列:
1. get caller ID
2. pick up incoming DID extension (I may have the wrong terminology)
3. check caller ID for blacklist
?
答案 0 :(得分:2)
您可以匹配来电者ID执行以下操作:
exten => s/_+252X.,n,Goto(blacklisted,s,1)
exten => s/_+1609X.,n,Goto(blacklisted,s,1)
或
exten => _XX./_+252X.,n,Goto(blacklisted,s,1)
exten => _XX./_+1609X.,n,Goto(blacklisted,s,1)
有关模式匹配的更多信息: https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching
修改强>
阻止1-609-123-456X
的示例,其中X
是任意数字:
[from-Provider]
exten => _XX.,1,Set(CALLERID(num)=${CALLERID(num):1})
exten => _XX./_1609123456X,n,Goto(blacklisted,s,1)
exten => _XX.,n,GotoIf(${BLACKLIST()}?blacklisted,s,1)
exten => _XX.,n,Noop(CALLERID=${CALLERID(all)})
exten => _XX.,n,Dial(SIP/home&IAX2/droid&SIP/office)
exten => _XX.,n,Hangup()
[blacklisted]
exten => s,1,Answer
exten => s,n,Hangup
您还可以添加其他模式,例如:
_252X.
(对于以252
_96X.
(对于以96
如果这不起作用,请添加整个CLI日志。 Noop会告诉我们您的PBX中的呼叫者看起来像什么。
编辑2:
这两行应具有优先级1
。
[from-didforsale]
exten => _XX./_1609123456X,1,Goto(blacklisted,s,1)
exten => _XX.,1,GotoIf(${BLACKLIST()}?blacklisted,s,1)
exten => _XX.,n,Noop(CALLERID=${CALLERID(all)})
exten => _XX.,n,Dial(SIP/home&IAX2/droid&SIP/office)
exten => _XX.,n,Hangup()