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)

是不是我的做法有问题?

相关推荐
SunkingYang3 天前
MFC进程间消息通信深度解析:SendMessage、PostMessage与SendNotifyMessage的底层实现与实战指南
c++·mfc·共享内存·通信·postmessage·sendmessage·进程间
xixixi777774 天前
猫池:黑产的“手机农场”与攻防最前线
安全·通信·反诈·运营商·监管·猫池·黑产
SunkingYang4 天前
QT程序如何将事件和消息发送给MFC程序,MFC程序如何接收消息和事件
qt·mfc·消息·事件·通信·通讯·传递
灵感菇_5 天前
Android ContentProvider全面解析
android·通信·四大组件·contentprovider
无名3876 天前
rtpengine-recording(8) 手册页
通信
无名3879 天前
FreeSWITCH limit 中文手册
通信
xixixi7777711 天前
系统性地解析——边缘计算(从定义与驱动力、核心架构、关键技术特征、与云计算的范式对比、典型应用场景以及挑战与趋势等方面)
安全·架构·云计算·边缘计算·信息与通信·通信·反诈
xixixi7777713 天前
从宏观架构、核心技术、战术对抗、治理挑战和未来趋势五个层面,系统性地剖析“短信反诈骗”
安全·架构·安全架构·通信·反诈·短信反诈
无名38714 天前
Kamailio usrloc 细节测试
通信
xixixi7777715 天前
App反诈骗:一场面向移动生态的深度安全战争(接上文短信反诈)
安全·信息与通信·通信·电话反诈