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数据,动态控制呼叫流程。

空空如常

求真得真

相关推荐
夕除1 天前
spring boot 14
xml·spring boot·redis
一拳一个娘娘腔2 天前
【SRC漏洞挖掘系列】第09期:XXE与反序列化 —— 当XML和Java开始“吃”代码
xml·java·安全·web安全·github
Cx330❀2 天前
【Linux网络】从以太网碰撞到 Socket 套接字与网络字节序的深度解析
xml·linux·运维·服务器·开发语言·网络·c++
缘于自然84 天前
高通modem如何确认device_config.xml的使用路径
xml·modem·mbn·mcfg
丑八怪大丑9 天前
XML_Tomcat_HTTP
xml·http·tomcat
largecode9 天前
企业名称能在来电显示吗?号码显示公司名服务打通多终端展示
android·xml·ios·iphone·xcode·webview·phonegap
只可远观11 天前
Android XML命令式和Jetpack Compose声明式UI
android·xml
鹏晨互联11 天前
《深入理解 Compose 中的 matchParentSize 与 fillMaxSize —— 从 XML 到 Compose 的对比解析》
xml
小短腿的代码世界12 天前
Qt SVG渲染管线全解析:从XML解析到像素绘制的完整架构设计与性能优化实战
xml·qt·性能优化
HMS工业网络12 天前
技术干货:EtherCAT设备ESI(XML)文件中的CompleteAccess关键字有什么作用
xml·运维·服务器