FreeSWITCH mod_curl 和 mod_xml_rpc 测试

编辑 /usr/local/freeswitch/conf/autoload_configs/xml_rpc.conf.xml

<configuration name="xml_rpc.conf" description="XML RPC">

<settings>

<param name="http-port" value="8889"/>

<param name="commands-to-log" value=".*"/>

</settings>

</configuration>

fs_cli -x 'load mod_xml_rpc'

fs_cli -x 'load mod_curl'

fs_cli -x 'curl http://127.0.0.1:8889/xmlapi/status'

哈哈,结果不错


api 要带参数怎么弄?

fs_cli -x 'curl http://127.0.0.1:8889/xmlapi/uuid_kill?735cc8f4-758a-4efd-b110-c0840e721ce8'

-ERR No such channel!

2025-06-13 16:19:35.493126 98.43% [DEBUG] mod_curl.c:209 method: get, url: http://127.0.0.1:8889/xmlapi/uuid_kill?735cc8f4-758a-4efd-b110-c0840e721ce8, content-type: (null)

2025-06-13 16:19:35.513144 98.43% [INFO] mod_xml_rpc.c:1088 Executed HTTP request command: [uuid_kill 735cc8f4-758a-4efd-b110-c0840e721ce8].


带 http 头要怎么弄?

fs_cli -x "curl http://127.0.0.1:8889/xmlapi/uuid_kill?735cc8f4-758a-4efd-b110-c0840e721ce8 append_headers 'k1:v111' append_headers 'k2:v222'"

抓包, 用 wireshark 看,如下

GET /xmlapi/uuid_kill?735cc8f4-758a-4efd-b110-c0840e721ce8 HTTP/1.1

Host: 127.0.0.1:8889

User-Agent: freeswitch-curl/1.0

Accept: */*

k1:v111

k2:v222


增加 basic 认证

<configuration name="xml_rpc.conf" description="XML RPC">

<settings>

<param name="http-port" value="8889"/>

<param name="auth-realm" value="freeswitch"/>

<param name="auth-user" value="freeswitch"/>

<param name="auth-pass" value="works"/>

<param name="commands-to-log" value=".*"/>

</settings>

</configuration>

按 mod_curl 文档

fs_cli -x 'curl http://freeswitch:work@127.0.0.1:8889/xmlapi/status'

但实际上,得到 401,不灵

下面是文档片段

If you want to pass basic authentication credentials then do this:

local auth_url = "http://username:password@mysecure_web_service.com"

local response = api:execute("curl", auth_url)

是不是我的做法有问题?

相关推荐
冷凝雨3 小时前
逻辑分析仪隔离模块 —— 基于π121M31
通信·逻辑分析仪·解码器·数字·隔离模块·隔离芯片·高压隔离
无名3872 天前
Debian12 源码编译 FreeSWITCH 1.10.12
通信
无名3874 天前
关于 VRF
网络·通信
LeeYLong4 天前
浅谈无线AP/路由未来发展趋势
wifi·路由器·通信·射频
liulilittle6 天前
OPENPPP2 网络驱动模式
开发语言·网络·c++·网络协议·信息与通信·通信
liulilittle6 天前
俄罗斯访问欧洲国际线路优化
开发语言·网络·信息与通信·ip·通信·俄罗斯·莫斯科
xixixi777777 天前
量子通信是当前信息安全和通信领域最前沿、最具变革性的技术之一
安全·信息安全·量子计算·通信·量子通信·密钥·传输
栗子叶7 天前
网页接收服务端消息的几种方式
前端·websocket·http·通信
liulilittle7 天前
rinetd 端口转发工具技术原理
linux·服务器·网络·c++·端口·通信·转发
无名3878 天前
我碰到的 Kamailio trunk_auth 问题
通信