简体   繁体   English

Kamailio中的自定义SIP标头

[英]Custom SIP Header In Kamailio

I need to set a custom header in Kamailio 3.3.1 from a Lua script. 我需要从Lua脚本在Kamailio 3.3.1中设置自定义标头。 I can theoretically set one in the config script like this - 从理论上讲,我可以像这样在配置脚本中设置一个-

append_hf("X-MyHeader: myvalue\r\n");

but I cannot work out how to call it from a Lua script, which is my preferred place to do this from. 但是我不知道如何从Lua脚本中调用它,这是我首选的执行方法。 I have the following in my CFG file - 我的CFG文件中包含以下内容-

modparam("app_lua", "load", "/usr/local/etc/kamailio/lua/kamailio.lua")
modparam("app_lua", "register", "sl")
modparam("app_lua", "register", "rr")
modparam("app_lua", "register", "tm")

and my Lua script works fine as far as it goes. 而且我的Lua脚本可以正常运行。 Documentation seems to suggest that append_hf() is part of the textops module, but I can see no way to expose that to the Lua script. 文档似乎表明append_hf()是textops模块的一部分,但是我看不到将其公开给Lua脚本的方法。

Please can anyone help me understand this or maybe suggest an alternative way to achieve my goal? 请任何人可以帮助我理解这一点,或者建议其他方法来实现我的目标?

Done it. 完成了。

You need to use - 您需要使用-

sr.hdr.append("header: value\r\n");

I've spent 2 days looking for that. 我已经花了2天的时间寻找。 And 5 mins after posting I find it. 发布后5分钟,我发现了。 Here's the URL where i got the answer from - 这是我从中得到答案的网址-

http://www.kamailio.org/wiki/embeddedapi/3.2.x/lua http://www.kamailio.org/wiki/embeddedapi/3.2.x/lua

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM