freeswitch的mod_xml_curl模块动态获取configuration

这篇具有很好参考价值的文章主要介绍了freeswitch的mod_xml_curl模块动态获取configuration。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

freeswitch的mod_xml_curl模块动态获取configuration,技术-VOIP,freeswitch,voip,sip,linux

 

概述

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

mod_xml_curl模块支持从web服务获取xml配置,本文介绍如何动态获取acl配置。

环境

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

freeswitch:v1.6.20

GCC:4.8.5

web服务

mod_xml_curl模块依赖于web服务,需要自己创建一个web接口并动态的返回xml配置。

下面是python3.10实现的一个简单的web服务接口函数,从基类“BaseHTTPRequestHandler”继承并实现简单的返回逻辑。

    def fsDialplan(self):

        length = int(self.headers['content-length']) 

        datas = self.rfile.read(length)

        logging.info('/fs/dialplan request, data=%s' % urllib.parse.unquote(datas))

        respcode = '''<document type="freeswitch/xml">

<section name="dialplan" description="dialplan-url">

    <include>

        <context name="public">

            <extension name="test-url" continue="false">

                <condition field="${acl(${network_addr} list_out)}" expression="true"/>

                <condition field="destination_number" expression="^(\d+)$">

                    <action application="answer"/>

                    <action application="playback" data="/usr/local/freeswitch/sounds/dialplan-test-url.wav"/>

                </condition>

            </extension>

        </context>

    </include>

</section>

</document>

'''

        self.send_response(200)

        self.send_header('Content-Type', 'application;charset=utf-8')

        self.end_headers()

        self.wfile.write(respcode.encode('utf-8'))

        return

   

    def fsConfigAcl(self):

        length = int(self.headers['content-length']) 

        datas = self.rfile.read(length)

        # print('fsConfigAcl request, data=', datas.decode())

        logging.info('/fs/config/acl request, data=%s' % urllib.parse.unquote(datas))

        respcode = '''<document type="freeswitch/xml">

<section name="configuration" description="config-acl">

<configuration name="acl.conf" description="Network Lists">

  <network-lists>

    <list name="list_out" default="deny">

      <node type="allow" cidr="10.55.55.138/32"/>

    </list>

  </network-lists>

</configuration>

</section>

</document>

'''

        self.send_response(200)

        self.send_header('Content-Type', 'application;charset=utf-8')

        self.end_headers()

        self.wfile.write(respcode.encode('utf-8'))

        return

web服务响应消息格式注意事项,必须有“section”段,xml格式不能使用压缩格式,否则会解析错误。

fsDialplan函数的响应中增加了acl的条件判断。

fsConfigAcl函数响应添加“list_out”的acl规则。

配置

检查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文件。

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

<binding name="configuration">

<param name="gateway-url" value="http://10.9.0.27:8080/fs/config-acl" bindings="configuration"/>

</binding>

  </bindings>

</configuration>

测试

configuration动态配置需要刷新生效。

freeswitch@localhost.localdomain> reloadacl

+OK acl reloaded

2023-08-04 10:37:59.117939 [NOTICE] switch_utils.c:545 Adding 10.55.55.138/32 (allow) [] to list list_out

使用10011发起呼叫,日志如下。

2023-08-04 10:38:05.277908 [INFO] mod_dialplan_xml.c:637 Processing 10011 <10011>->13712345678 in context public

Dialplan: sofia/external/10011@10.55.55.138 parsing [public->test-url] continue=false

Dialplan: sofia/external/10011@10.55.55.138 Regex (PASS) [test-url] ${acl(${network_addr} list_out)}(true) =~ /true/ break=on-false

Dialplan: sofia/external/10011@10.55.55.138 Regex (PASS) [test-url] destination_number(13712345678) =~ /^(\d+)$/ break=on-false

Dialplan: sofia/external/10011@10.55.55.138 Action answer()

Dialplan: sofia/external/10011@10.55.55.138 Action playback(/usr/local/freeswitch/sounds/dialplan-test-url.wav)

呼叫结果符合预期。

总结

mod_xml_curl模块动态获取config数据,方便对批量的fs集中统一管理配置。

未解决问题。

configuration类型的配置数据动态刷新的边界在哪里,我们可以把哪些配置数据放在web服务统一管理。

如何解决web服务不可用的本地xml配置问题,本地xml配置与web动态配置不一致的问题。

空空如常

求真得真文章来源地址https://www.toymoban.com/news/detail-649337.html

到了这里,关于freeswitch的mod_xml_curl模块动态获取configuration的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 顶顶通呼叫中心中间件自动外呼来电转人工显示被叫号码而不是显示路由条件 :一步步配置(mod_cti基于FreeSWITCH)

    介绍 顶顶通呼叫中心中间件自动外呼来电转人工显示被叫号码而不是显示自动外呼的路由条件,可以是默认的被叫号码也可以改为显示指定的号码 一、显示默认被叫 1、配置拨号方案 打开ccadmin-》点击拨号方案-》找到进入排队-》配置跟图中一样的通道变量。 修改了拨号方案

    2024年01月18日
    浏览(42)
  • 骑砍2霸主MOD开发(8)-action_sets.xml骨骼动画

    一.action_sets.xml      1.文件目录:ModulesNativeModuleDataaction_sets.xml      2.action_set(骨骼动画animation) = action1 + action2 +action3      3.通过在action_set中配置skeleton,人,马匹,牛,羊等骨架 二.使用编辑器修改动作 三.骨架骨骼骨骼动画      1.骨架skeleton         Skeleton skel = Mission.Main

    2024年04月27日
    浏览(29)
  • 解决 go mod tidy 加载模块超时

    如果go mod tidy 加载模块超时 解决方法 修改GOPROXY: 查看go环境相关信息:

    2024年02月11日
    浏览(34)
  • 【FreeSwitch开发实践】media bug获取通话语音流

    🏠 博客主页:小小马车夫的主页 🍅 所属专栏:FreeSwitch开发实践 🥝 专栏介绍:主要介绍博主在实际项目中使用FreeSwitch开发外呼类项目的一些经验心得,主要涉及FreeSwitch的基本安装编译、基本配置、ESL、WSS、录音、自定义模块、media bug、语音播放、MRCP及对接AI机器人等内

    2024年02月04日
    浏览(34)
  • go mod tidy总是安装最新依赖,如何查找哪个模块导致某个包安装最新依赖,提供一个小工具

    安装: go install github.com/jan-bar/interesting/findModVer@latest 执行: findModVer d:myproject 结果如下图所示: 根据结果可以找到哪个依赖导致 google.golang.org/grpc v1.45.0 使用了这个版本,这样每次执行 go mod tidy 会自动修改该模块到 v1.45.0 版本。我看了下 github.com/spf13/viper v1.11.0 就是用的 go

    2024年02月08日
    浏览(54)
  • Apache HTTP Server <2.4.56 mod_proxy_uwsgi 模块存在请求走私漏洞(CVE-2023-27522)

    Apache HTTP Server 是一个Web服务器软件。 该项目受影响版本存在请求走私漏洞。由于mod_proxy_uwsgi.c 中uwsgi_response方法对于源响应头缺少检查,当apache启用mod_proxy_uwsgi后,攻击者可利用过长的源响应头等迫使应转发到客户端的响应被截断或拆分,进而可能造成会话劫持等危害。 漏

    2024年02月09日
    浏览(49)
  • shell脚本获取curl POST命令返回的http状态码

     在shell脚本中判断curl 发的post命令执行返回的http状态码,从而判断POST命令执行成功还是失败 有两种方法 status_code=`curl -s -o /dev/null -w \\\"%{http_code}\\\" -X POST \\\"http://xxx\\\"` 注意上述命令两边的符号 ``,是键盘上数字1左边的字符 status_code=$(curl -s -o /dev/null -w \\\"%{http_code}\\\" -X POST \\\"http://xxx

    2024年02月12日
    浏览(38)
  • Python入门:常用模块—xml模块

    xml是实现不同语言或程序之间进行数据交换的协议,跟json差不多,但json使用起来更简单 data      country name = \\\"Liechtenstein\\\"          rank updated = \\\"yes\\\" 2 / rank          year updated = \\\"yes\\\" 2010 / year          gdppc 141100 / gdppc          neighbor direction = \\\"E\\\"   name = \\\"Austria\\\"  

    2024年02月19日
    浏览(35)
  • 通过curl访问k8s集群获取证书或token的方式

    K8S安全控制框架主要由下面3个阶段进行控制,每一个阶段都支持插件方式,通过API Server配置来启用插件。 1. Authentication(认证) 2. Authorization(授权) 3. Admission Control(准入控制) 客户端(kubectl或curl等)要想访问K8s集群API Server,一般需要证书、Token或者用户名+密码。如果

    2024年01月24日
    浏览(41)
  • ArcGIS切片服务获取切片方案xml文件(conf.xml)

    在使用ArcGIS进行影像、地形等切片时,往往需要保持一致的切片方案才能够更好的加载地图服务。 本文介绍如何获取已经发布好的ArcGIS服务的切片方案xml文件。 当然切片xml文件还可以通过工具 Generate Tile Cache Tiling Scheme 生成,具体操作可参考相关文档,本文不做说明。 示例

    2023年04月20日
    浏览(41)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包