freeswitch的mod_xml_curl模块

概述

freeswitch是一款简单好用的VOIP开源软交换平台。

随着fs服务的增多,每一台fs都需要在后台单独配置,耗时耗力,心力憔悴。

如果有一个集中管理配置的配置中心,统一管理所有fs的配置,并可以实现动态的修改配置就好了。

于是就发现了mod_xml_curl模块。

环境

centos:CentOS release 7.0 (Final)或以上版本

freeswitch:v1.10.7

GCC:4.8.5

模块介绍

mod_xml_curl模块默认不编译安装。

进入"freeswitch/src/mod/xml_int/mod_xml_curl"目录,执行如下命令

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模块的主要使用场景。

运行多个FreeSWITCH实例而不必维护多个服务器配置。

集中的配置管理。

从连接到数据库的web应用程序动态填充配置。

提供了一种自动化FreeSWITCH配置部署的简单方法(例如,托管VoIP平台)。

mod_xml_curl的工作原理与典型的API一样,向web应用程序发送POST请求,获取XML格式的响应消息并刷新本地配置。

mod_xml_curl从web接口获取到有效响应则直接加载配置,如果收到无效响应或404则尝试从本地磁盘查找配置文件。

mod_xml_curl模块可以分为4个不同的绑定章节,基本可以覆盖全部的xml配置项。

configuration,配置项,比如mod_sofia的配置。

directory,用户鉴权目录。

dialplan,拨号计划。

phrases,语音短语管理。

测试

修改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>

启动fs,检查启动日志,如下。

...

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'

...

发起呼叫,使用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&section=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继续呼叫流程。

总结

mod_xml_curl模块功能较复杂,涉及流程较多,同时需要web服务器提供数据接口配合。

后续尝试使用接口返回dialplan数据,动态控制呼叫流程。

空空如常

求真得真

相关推荐
小鸡吃米…8 小时前
Python - XML 处理
xml·开发语言·python·开源
老歌老听老掉牙13 小时前
Vericut 5轴机床MCH文件解析与构建指南
xml·python·vericut
ii_best17 小时前
「安卓开发辅助工具按键精灵」xml全分辨率插件jsd插件脚本教程
android·xml·开发语言·编辑器·安卓
总会落叶17 小时前
MyBatis XML映射配置与日志系统全解析
xml·tomcat·mybatis
drebander18 小时前
macOS 下优雅管理 Maven:多版本切换 + settings.xml 自动切换(zsh-only 实战)
xml·maven
好学且牛逼的马2 天前
原生 JDBC + DbUtils + MyBatis 同场景 Demo(C3P0 数据源 XML 配置版)
xml·mybatis
代码栈上的思考2 天前
MyBatis XML的方式来实现
xml·java·mybatis
Mr.Pascal2 天前
深度解读一下 springcloud 的 pom.xml 用到的标签
xml·spring boot·spring cloud
爱吃土豆的马铃薯ㅤㅤㅤㅤㅤㅤㅤㅤㅤ2 天前
日志打印配置:logback-spring.xml配置;info和error完全区分了,并且按时间拆分了
xml·spring·logback
Android技术之家3 天前
实测:Jetpack Compose 替代 XML 布局,3 步实现高性能界面迁移
xml