7. Astricon 2020 Fred Posner
What is Kamailio
●
SIP proxy server
●
SIP registrar server
●
SIP location server
●
SIP application server
●
SIP dispatcher server
●
SIP websocket server
17. Astricon 2020 Fred Posner
New Modules: Kafka / DLGS
●
Produces and sends
messages to a Kafka
server
●
Tracks dialogs in
stateless mode
18. Astricon 2020 Fred Posner
New Modules: MQTT / SECSIPID
●
Bidirectional
publish/subscribe
communication to a
MQTT Broker
●
STIR and SHAKEN IETF
extensions for SIP
(RFC8224, RFC 8588)
19. Astricon 2020 Fred Posner
New in 5.4
●
New modules: 5
●
Updated modules: 70
●
KEMI optimizations
●
Core updates
●
And mucho, mucho mas
30. Astricon 2020 Fred Posner
Blocking by User-Agent - $ua
if($ua =~ "friendly-scanner|sipcli|sipvicious|VaxSIPUserAgent") {
# silent drop for scanners - uncomment next line if want to reply
# sl_send_reply("200", "OK");
exit;
}
31. Astricon 2020 Fred Posner
Adding to HTABLE
if($sht(ipban=>$si)!=$null) {
# ip is already blocked
xdbg("request from blocked IP - $rm from $fu (IP:$si:$sp)n");
exit;
}
...
if($ua =~ "friendly-scanner|sipcli|sipvicious|VaxSIPUserAgent") {
$sht(ipban=>$si) = 1;
# silent drop for scanners - uncomment next line if want to reply
# sl_send_reply("200", "OK");
exit;
}
32. Astricon 2020 Fred Posner
Dispatching Requests
# Dispatch requests
route[DISPATCH] {
# round robin dispatching on gateways group '1'
if(!ds_select_dst("1", "4")) {
send_reply("404", "No destination");
exit;
}
xdbg("--- SCRIPT: going to <$ru> via <$du> (attrs: $xavp(_dsdst_=>attrs))n");
t_on_failure("RTF_DISPATCH");
route(RELAY);
exit;
}
33. Astricon 2020 Fred Posner
Dispatching Requests
# Try next destionations in failure route
failure_route[RTF_DISPATCH] {
if (t_is_canceled()) {
exit;
}
# next DST - only for 500 or local timeout
if (t_check_status("500")
or (t_branch_timeout() and !t_branch_replied())) {
if(ds_next_dst()) {
xdbg("--- SCRIPT: retrying to <$ru> via <$du> (attrs: $xavp(_dsdst_=>attrs))n");
t_on_failure("RTF_DISPATCH");
route(RELAY);
exit;
}
}
}
35. Astricon 2020 Fred Posner
Failure Routes FTW
●
Check for reply, CANCEL, status code
●
Can be set as needed
if (t_check_status("5[0-9][0-9]")){
# I do not like the 5xx responses,
# so I give another chance to "foobar.com",
# and I drop all the replies to make sure that
# they are not forwarded to the caller.
t_drop_replies();
rewritehostport("foobar.com");
append_branch();
t_relay();
}
36. Astricon 2020 Fred Posner
Fail / Reply / Branching / Serial
●
Status checks
●
CANCEL checks
●
Use your own logic to supply what to do
●
Great also for PSTN
37. Astricon 2020 Fred Posner
Thank You!
●
kamailio.org
●
Mail lists, IRC, Matrix
●
YouTube (kamailioworld)
●
@kamailio