从Asterisk模式中排除扩展名h

时间:2016-03-03 09:51:46

标签: asterisk

在我的Asterisk 12.4.0的拨号方案中,我想接受数字和字符串扩展,所以我使用这样的东西:

[trunks]
exten => _[*#0-9a-z]!,1,Verbose(Incoming call)
exten => _[*#0-9a-z]!,n,Verbose(Incoming call - other processing 0)
exten => _[*#0-9a-z]!,n,Verbose(Incoming call - other processing 1)
exten => _[*#0-9a-z]!,n,Verbose(Incoming call - other processing 2)
exten => _[*#0-9a-z]!,n,Verbose(Incoming call - other processing 3)
exten => h,1,NoOp()
exten => t,1,Hangup()
exten => i,1,Hangup()
exten => s,1,Hangup()

不幸的是,有一种机制提到here(标题为“小心模式匹配”的红色框)导致扩展名h(在Hangup上自动调用)也执行 来电 - 其他处理0-3。

拨打123时输出星号-rvvv为:

  == Using SIP RTP CoS mark 5
    -- Executing [123@trunks:1] Verbose("SIP/trunk_audio2redil-00000008", "Incoming call") in new stack
Incoming call
    -- Executing [123@trunks:2] Verbose("SIP/trunk_audio2redil-00000008", "Incoming call - other processing 0") in new stack
Incoming call - other processing 0
    -- Executing [123@trunks:3] Verbose("SIP/trunk_audio2redil-00000008", "Incoming call - other processing 1") in new stack
Incoming call - other processing 1
    -- Executing [123@trunks:4] Verbose("SIP/trunk_audio2redil-00000008", "Incoming call - other processing 2") in new stack
Incoming call - other processing 2
    -- Executing [123@trunks:5] Verbose("SIP/trunk_audio2redil-00000008", "Incoming call - other processing 3") in new stack
Incoming call - other processing 3
    -- Auto fallthrough, channel 'SIP/trunk_audio2redil-00000008' status is 'UNKNOWN'
    -- Executing [h@trunks:1] NoOp("SIP/trunk_audio2redil-00000008", "") in new stack
    -- Executing [h@trunks:2] Verbose("SIP/trunk_audio2redil-00000008", "Incoming call - other processing 0") in new stack
Incoming call - other processing 0
    -- Executing [h@trunks:3] Verbose("SIP/trunk_audio2redil-00000008", "Incoming call - other processing 1") in new stack
Incoming call - other processing 1
    -- Executing [h@trunks:4] Verbose("SIP/trunk_audio2redil-00000008", "Incoming call - other processing 2") in new stack
Incoming call - other processing 2
    -- Executing [h@trunks:5] Verbose("SIP/trunk_audio2redil-00000008", "Incoming call - other processing 3") in new stack
Incoming call - other processing 3

我希望处理后停止

-- Executing [h@trunks:1] NoOp("SIP/trunk_audio2redil-00000008", "") in new stack

但我不知道该怎么做。

我的想法如何实现:

  • 要禁用“fallthrough”机制,但我不知道如何以及是否可能。
  • 修改模式,使其匹配所有数字(包括单位数字)和所有超过1的字符串。再次,我不知道如何执行此操作。

2 个答案:

答案 0 :(得分:0)

简单方法

exten => _[*#0-9a-g,j-r,u-z]!,1,Verbose(Incoming call)

上下文方式(匹配优先级):

[trunks]
include=>trunks_pattern
exten => h,1,NoOp()
exten => t,1,Hangup()
exten => i,1,Hangup()
exten => s,1,Hangup()
[trunks_pattern]
exten => _[*#0-9a-z]!,1,Verbose(Incoming call)
exten => _[*#0-9a-z]!,n,Verbose(Incoming call - other processing 0)
exten => _[*#0-9a-z]!,n,Verbose(Incoming call - other processing 1)
exten => _[*#0-9a-z]!,n,Verbose(Incoming call - other processing 2)
exten => _[*#0-9a-z]!,n,Verbose(Incoming call - other processing 3)

最后基于:只有在此上下文中不匹配且包含的确切顺序时才会匹配包含的上下文。

也会像这样工作

exten => _.,1,Verbose(incoming call)
exten => h,1,Verbose(hangup)

应该,但要处理所有当前的星号版本。

答案 1 :(得分:0)

我发现了另一种类似于arheops建议的“上下文方式”的方法:

[trunks]
exten => _[*#0-9a-z]!,1,Verbose(Incoming call)
exten => _[*#0-9a-z]!,n,Verbose(Incoming call - other processing 0)
exten => _[*#0-9a-z]!,n,Verbose(Incoming call - other processing 1)
exten => _[*#0-9a-z]!,n,Verbose(Incoming call - other processing 2)
exten => _[*#0-9a-z]!,n,Verbose(Incoming call - other processing 3)

exten => h,1,Goto(hangup,h,1)
exten => t,1,Hangup()
exten => i,1,Hangup()
exten => s,1,Hangup()

[hangup]
exten => h,1,NoOp()