Password Recovery

MSRPRelay on Kamailio

 

#!KAMAILIO
#
.....
#!substdef "!MY_IP_ADDR!x.x.x.x!g"
#!substdef "!MY_DOMAIN!example.com!g"
#!substdef "!MY_MSRP_PORT!2855!g"
#!substdef "!MY_MSRP_ADDR!tls:MY_IP_ADDR:MY_MSRP_PORT!g"
#!substdef "!MSRP_MIN_EXPIRES!1800!g"
#!substdef "!MSRP_MAX_EXPIRES!3600!g"

....
#!define WITH_MSRP


####### Global Parameters #########

.....
#!ifdef WITH_MSRP listen=MY_MSRP_ADDR #!endif tcp_connection_lifetime=3604 tcp_accept_no_cl=yes tcp_rd_buf_size=16384 .... mpath="/opt/kamailio/lib64/kamailio/modules_k/:/opt/kamailio/lib64/kamailio/modules/" #!endif loadmodule "db_mysql.so" loadmodule "tm.so" loadmodule "sl.so" loadmodule "rr.so" loadmodule "pv.so" loadmodule "maxfwd.so" loadmodule "usrloc.so" loadmodule "registrar.so" loadmodule "textops.so" loadmodule "siputils.so" loadmodule "xlog.so" loadmodule "sanity.so" loadmodule "ctl.so" loadmodule "auth.so" loadmodule "auth_db.so" loadmodule "kex.so" loadmodule "mi_rpc.so" loadmodule "corex.so"
#!ifdef WITH_TLS loadmodule "tls.so" #!endif #!ifdef WITH_MSRP loadmodule "msrp.so" loadmodule "htable.so" loadmodule "cfgutils.so" #!endif .... # ----------------- setting module-specific parameters --------------- ... #!ifdef WITH_MSRP # ----- htable params ----- modparam("htable", "htable", "msrp=>size=8;autoexpire=MSRP_MAX_EXPIRES;") #!endif ... #!ifdef WITH_MSRP event_route[msrp:frame-in] {
xdbg("============#[[$msrp(method)]]===========\n");
xdbg("============*[[$si:$sp]]\n");
xdbg("============ crthop: [$msrp(crthop)]\n");
xdbg("============ prevhop: [$msrp(prevhop)]\n");
xdbg("============ nexthop: [$msrp(nexthop)]\n");
xdbg("============ firsthop: [$msrp(firsthop)]\n");
xdbg("============ lasthop: [$msrp(lasthop)]\n");
xdbg("============ prevhops: [$msrp(prevhops)]\n");
xdbg("============ nexthops: [$msrp(nexthops)]\n");
xdbg("============ srcaddr: [$msrp(srcaddr)]\n");
xdbg("============ srcsock: [$msrp(srcsock)]\n");
xdbg("============ sessid: [$msrp(sessid)]\n");

msrp_reply_flags("1"); if (msrp_is_reply()) { msrp_relay(); } else if($msrp(method)=="AUTH") { if($msrp(nexthops)>0) { msrp_relay(); exit; }

# Kamailio is currently unable to build a RFC-compliant MSRP challenge or
# check a RFC-compliant authentication response. Skipping authentication altogether
# is also not RFC-compliant, but at least some progress is made.
# # if (!www_authenticate("MY_DOMAIN", "subscriber", # "$msrp(method)")) { # if (auth_get_www_authenticate("MY_DOMAIN", "1", # "$var(wauth)")) { # msrp_reply("401", "Unauthorized", # "$var(wauth)"); # } else { # msrp_reply("500", "Server Error"); # } # exit; # } if ($hdr(Expires) != $null) { $var(expires) = (int) $hdr(Expires); if ($var(expires) < MSRP_MIN_EXPIRES) { msrp_reply("423", "Interval Out-of-Bounds", "Min-Expires: MSRP_MIN_EXPIRES\r\n"); exit; } else if ($var(expires) > MSRP_MAX_EXPIRES) { msrp_reply("423", "Interval Out-of-Bounds", "Max-Expires: MSRP_MAX_EXPIRES\r\n"); exit; } } else { $var(expires) = MSRP_MAX_EXPIRES; } $var(cnt) = $var(cnt) + 1; pv_printf("$var(sessid)", "s.$(pp).$(var(cnt)).$(RANDOM)"); $sht(msrp=>$var(sessid)::srcaddr) = $msrp(srcaddr); $sht(msrp=>$var(sessid)::srcsock) = $msrp(srcsock); $shtex(msrp=>$var(sessid)) = $var(expires) + 5; # - Use-Path: the MSRP address for server + session id $var(hdrs) = "Use-Path: msrps://MY_IP_ADDR:MY_MSRP_PORT/" + $var(sessid) + ";tcp\r\n" + "Expires: " + $var(expires) + "\r\n"; msrp_reply("200", "OK", "$var(hdrs)"); } else if ($msrp(method)=="SEND" || $msrp(method)=="REPORT") { if ($msrp(nexthops)>1) { if ($msrp(method)!="REPORT") { msrp_reply("200", "OK"); } msrp_relay(); exit; } $var(sessid) = $msrp(sessid); if ($sht(msrp=>$var(sessid)::srcaddr) == $null) { # one more hop, but we don't have address in htable msrp_reply("481", "Session-does-not-exist"); exit; } else if ($msrp(method)!="REPORT") { msrp_reply("200", "OK"); } msrp_relay_flags("1"); msrp_set_dst("$sht(msrp=>$var(sessid)::srcaddr)", "$sht(msrp=>$var(sessid)::srcsock)"); msrp_relay(); } else { msrp_reply("501", "Request-method-not-understood"); } } #!endif