?
概述
freeswitch是一款簡(jiǎn)單好用的VOIP開源軟交換平臺(tái)。
隨著fs服務(wù)的增多,每一臺(tái)fs都需要在后臺(tái)單獨(dú)配置,耗時(shí)耗力,心力憔悴。
如果有一個(gè)集中管理配置的配置中心,統(tǒng)一管理所有fs的配置,并可以實(shí)現(xiàn)動(dòng)態(tài)的修改配置就好了。
于是就發(fā)現(xiàn)了mod_xml_curl模塊。
環(huán)境
centos:CentOS? release 7.0 (Final)或以上版本
freeswitch:v1.10.7
GCC:4.8.5
模塊介紹
mod_xml_curl模塊默認(rèn)不編譯安裝。
進(jìn)入“freeswitch/src/mod/xml_int/mod_xml_curl”目錄,執(zhí)行如下命令
sudo make install
檢查模塊安裝情況。
cd /usr/local/freeswitch/mod
ll
-rwxr-xr-x. 1 root root? 104456 Jul 28 10:47 mod_xml_curl.so
-rwxr-xr-x. 1 root root??? 1316 Jul 28 10:47 mod_xml_curl.la
檢查conf/autoload_configs/modules.conf.xml文件,mod_xml_curl模塊要放在配置的頂部。
??? <load module="mod_console"/>
<load module="mod_logfile"/>
<load module="mod_xml_curl"/>
檢查conf/autoload_configs/xml_curl.conf.xml文件。
mod_xml_curl模塊的主要使用場(chǎng)景。
運(yùn)行多個(gè)FreeSWITCH實(shí)例而不必維護(hù)多個(gè)服務(wù)器配置。
集中的配置管理。
從連接到數(shù)據(jù)庫(kù)的web應(yīng)用程序動(dòng)態(tài)填充配置。
提供了一種自動(dòng)化FreeSWITCH配置部署的簡(jiǎn)單方法(例如,托管VoIP平臺(tái))。
mod_xml_curl的工作原理與典型的API一樣,向web應(yīng)用程序發(fā)送POST請(qǐng)求,獲取XML格式的響應(yīng)消息并刷新本地配置。
mod_xml_curl從web接口獲取到有效響應(yīng)則直接加載配置,如果收到無效響應(yīng)或404則嘗試從本地磁盤查找配置文件。
mod_xml_curl模塊可以分為4個(gè)不同的綁定章節(jié),基本可以覆蓋全部的xml配置項(xiàng)。
configuration,配置項(xiàng),比如mod_sofia的配置。
directory,用戶鑒權(quán)目錄。
dialplan,撥號(hào)計(jì)劃。
phrases,語音短語管理。
測(cè)試
修改conf/autoload_configs/xml_curl.conf.xml文件。
<configuration name="xml_curl.conf" description="cURL XML Gateway">
? <bindings>
??? <binding name="dialplan">
????? <param name="gateway-url" value="http://10.55.55.137:8080/fs/dialplan" bindings="dialplan"/>
??? </binding>
? </bindings>
</configuration>
啟動(dòng)fs,檢查啟動(dòng)日志,如下。
…
2023-07-28 11:56:24.029966 [NOTICE] mod_xml_curl.c:543 Binding [dialplan] XML Fetch Function [http://10.55.55.137:8080/fs/dialplan] [dialplan]
2023-07-28 11:56:24.029979 [ERR] mod_xml_curl.c:459 Binding has no url!
2023-07-28 11:56:24.029994 [CONSOLE] switch_loadable_module.c:1540 Successfully Loaded [mod_xml_curl]
2023-07-28 11:56:24.030003 [NOTICE] switch_loadable_module.c:338 Adding API Function 'xml_curl'
…
發(fā)起呼叫,使用10011呼叫13712345678,日志如下。
2023-07-28 15:22:15.918548 [INFO] mod_dialplan_xml.c:637 Processing 10011 <10011>->13712345678 in context public
2023-07-28 15:22:15.918548 [ERR] mod_xml_curl.c:315 Received HTTP error 403 trying to fetch http://10.55.55.137:8080/fs/dialplan
data: [hostname=localhost.localdomain§ion=dialplan&tag_name=&key_name=&key_value=&Event-Name=REQUEST_PARAMS&Core-UUID=54544416-2d17-11ee-87f0-0d9ab89b9404&FreeSWITCH-Hostname=localhost.localdomain…
Dialplan: sofia/external/10011@10.55.55.138 parsing [public->test] continue=false
Dialplan: sofia/external/10011@10.55.55.138 Regex (PASS) [test] destination_number(13712345678) =~ /^(\d+)$/ break=on-false
Dialplan: sofia/external/10011@10.55.55.138 Action answer()
從日志可以看出,呼叫流程中,首先使用“mod_xml_curl”模塊獲取“http://10.55.55.137:8080/fs/dialplan”的值,獲取失敗則使用本地dialplan繼續(xù)呼叫流程。
總結(jié)
mod_xml_curl模塊功能較復(fù)雜,涉及流程較多,同時(shí)需要web服務(wù)器提供數(shù)據(jù)接口配合。
后續(xù)嘗試使用接口返回dialplan數(shù)據(jù),動(dòng)態(tài)控制呼叫流程。
空空如常文章來源:http://www.zghlxwxcb.cn/news/detail-616136.html
求真得真文章來源地址http://www.zghlxwxcb.cn/news/detail-616136.html
到了這里,關(guān)于freeswitch的mod_xml_curl模塊的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!