Asterisk Configuration for ARI

Overview

ARI有很多部分 - Asterisk服务请求的HTTP server,将channel的控制权交给连接的client的dialplan应用,在asterisk和外呼应用之间共享状态的websocket。这里提供asterisk的配置文件:对其修改以满足开发的要求。

此页面没有涵盖系统管理员可用的所有选项,但是它涵盖了为ARI配置asterisk的一些基础知识。

Asterisk Configuration Options for ARI

HTTP Server

asterisk中的HTTP server是通过http.conf配置的。请注意,这里并没有描述了http.conf中所有选项 - 相反,他它列出了ARI最有用的选项。

SectionParameterTypeDefaultDescription
general
enabledBooleanFalseEnable the HTTP server. The HTTP server in Asterisk is disabled by default. Unless it is enabled, ARI will not function!
bindaddrIP AddressThe IP address to bind the HTTP server to. This can either be an explicit local address, or 0.0.0.0 to bind to all available interfaces.
prefixStringA prefix to require for all requests. If specified, requests must begin with the specified prefix.
tlsenableBooleanFalseEnable HTTPS
tlsbindaddrIP Address/PortThe IP address and port to bind the HTTPS server to. This should be an IP address and port, e.g., 0.0.0.0:8089
tlscertfiePathThe full path to the certificate file to use. Asterisk only supports the .pem format.
tlsprivatekeyPathThe full path to the private key file. Asterisk only supports the .pem format. If this is not specified, the certificate specified in tlscertfile will be searched for the private key.

http.conf示例

[general]
enabled = yes
bindaddr = 0.0.0.0
bindport = 8088
TLS
强烈建议使用TLS加密HTTP信令,使用安全的websocket接收事件。这需要在http.conf配置TLS信息,从你的ARI应用创建安全的websocket/HTTP连接。

ARI Configuration

ARI users和properties通过ari.conf配置。请注意,这里并没有罗列所有的选项;此列表包含ARI中配置users的最有用的选项。有关完整说明,请参阅ARI configuration文档。

SectionParameterTypeDefaultDescription
general
enabledBooleanFalseEnable/disable ARI.
prettyBooleanNoFormat JSON responses and events in a human readable form. This makes the output easier to read, at the cost of some additional bytes.
allowed_originsStringA comma separated list of allowed origins for Cross-Origin Resource Sharing.
[user_name]
typeStringMust be user. Specifies that this configuration section defines a user for ARI.
read_onlyBooleanNoWhether or not the user can issue requests that alter the Asterisk system. If set to Yes, then only GET and OPTIONS HTTP requests will be serviced.
password_formatStringplainCan be either plain or crypt. When the password is plain, Asterisk will expect the user’s password to be in plain text in the password field. When set to crypt, Asterisk will use crypt(3) to decrypt the password. A crypted password can be generated using mkpasswd -m sha-512.
passwordStringThe password for the user.

ari.conf示例

[general]
enabled = yes
pretty = yes
allowed_origins = localhost:8088,http://ari.asterisk.org
 
[asterisk]
type = user
read_only = no
password = asterisk
 
; password_format may be set to plain (the default) or crypt. When set to crypt,
; crypt(3) is used to validate the password. A crypted password can be generated
; using mkpasswd -m sha-512.
;
[asterisk-supersecret]
type = user
read_only = no
password = $6$nqvAB8Bvs1dJ4V$8zCUygFXuXXp8EU3t2M8i.N8iCsY4WRchxe2AYgGOzHAQrmjIPif3DYrvdj5U2CilLLMChtmFyvFa3XHSxBlB/
password_format = crypt

Configuring the Dialplan for ARI

默认情况下,ARI不能asteirsk中的任意channel。channel可能在一个长期运行的dialplan应用;也可能由AGI控制;可能已经挂断。如果asteirsk没有以安全的方式将信道控制权交给ARI,那么ARI暴露的很多操作根本就不安全。
为了将channel交给ARI,asterisk使用名为Stasis的dialplan应用。Stasis 和asterisk的其他dialplan应用一样,除了安全的将控制权交给ARI应用之外不做任何事情。Stasis dialplan应用有两个参数:

  • channel移交的ARI应用的名称。在单个asterisk实例可以存在多个ARI应用,每个ARI应用只能操作他控制的channels。
  • 移交ARI时传递给ARI应用的参数

Example: Two ARI Applications

extension.conf中dialplan的片段,说明了两个ARI应用。第一个channel到ARI的"Intro-IVR"的ARI应用没有任何附加参数,第二个channel到ARI应用的"Super-Conference"带有一个参数:指定进入的会议室。

[default]
 
exten => ivr,1,NoOp()
 same =>     n,Stasis(Intro-IVR)
 same =>     n,Hangup()
 
exten => conference,1,NoOp()
 same =>            n,Stasis(Super-Conference,100)
 same =>            n,Hangup()

当channel进入Stasis应用时,asterisk将检查是否为该应用建立websocket连接。如果是,将channel移交给ARI控制,为websocekt订阅channel事件,并向websocket发送StasisStart事件,通知它channel已经进入应用。

websocket连接是必须的。
如果你没有为特定应用创建到asterisk的websocket连接,当一个channel进入应用的Stasis时,asterisk将立即从应用中获取channel并返给dialplan。This is to prevent channels from entering into an application before something is ready to handle them.
请注意,如果连接断开,asterisk将知道之前存在的连接,并允许channel进入(尽管你收到告警:事件丢失);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值