Files
weiyu/deploy/kamailio/kamailio-local.cfg
2025-10-21 14:55:08 +08:00

80 lines
1.7 KiB
INI

#!define WITH_NAT
#!substdef "!MY_PUBLIC_IP!124.220.58.234!g"
#!substdef "!DISPATCHER_LIST!/etc/kamailio/dispatcher.list!g"
listen=udp:0.0.0.0:5060 advertise MY_PUBLIC_IP:5060
alias="sip.weiyuai.cn"
mpath="/usr/lib/x86_64-linux-gnu/kamailio/modules/"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule "sanity.so"
loadmodule "textops.so"
loadmodule "siputils.so"
loadmodule "pv.so"
loadmodule "xlog.so"
loadmodule "dispatcher.so"
loadmodule "nathelper.so"
modparam("dispatcher", "list_file", "DISPATCHER_LIST")
modparam("dispatcher", "flags", 2)
modparam("dispatcher", "dst_avp", "$avp(dsdst)")
modparam("dispatcher", "cnt_avp", "$avp(dscnt)")
modparam("rr", "enable_full_lr", 1)
modparam("rr", "append_fromtag", 0)
modparam("tm", "fr_timer", 3000)
modparam("tm", "fr_inv_timer", 90000)
# NAT helper
modparam("nathelper", "received_avp", "$avp(rcv)"
)
route[DISPATCH] {
if(!ds_select_dst(1, 0)) {
send_reply(500, "No Upstream");
exit;
}
t_on_reply("NAT_REPLY");
t_relay();
exit;
}
onreply_route[NAT_REPLY] {
# Fix nat on replies
if(isflagset(FLT_NATS)) {
fix_nated_contact();
}
}
request_route {
if (!mf_process_maxfwd(10)) {
send_reply(483, "Too Many Hops");
exit;
}
if (!sanity_check("1511", "7")) {
send_reply(400, "Bad Request");
exit;
}
# NAT handling
force_rport();
if (nat_uac_test(19)) {
setflag(FLT_NATS);
fix_nated_contact();
}
if (is_method("OPTIONS") && ($ru == "sip:sip.weiyuai.cn" || $rU == "")) {
send_reply(200, "OK");
exit;
}
record_route();
route(DISPATCH);
}