Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!define DBURL "postgres://kamailio:secret_password@localhost:5433/kamailio"
- loadmodule "pv.so"
- loadmodule "ctl.so"
- loadmodule "xlog.so"
- loadmodule "jsonrpcs.so"
- loadmodule "tm.so"
- loadmodule "textops.so"
- loadmodule "sl.so"
- loadmodule "usrloc.so"
- loadmodule "registrar.so"
- loadmodule "auth.so"
- loadmodule "db_postgres.so"
- loadmodule "auth_db.so"
- loadmodule "siputils.so"
- loadmodule "nathelper.so"
- loadmodule "rr.so"
- #loadmodule "tmx.so"
- loadmodule "rtpengine.so"
- loadmodule "htable.so"
- #############[Подключение к БД]###########
- modparam("auth_db", "db_url", DBURL); # указываем URL для подключения, берем его из ранее созданной директивы DBURL
- modparam("auth_db", "load_credentials", "$avp(pass)=password")
- modparam("htable", "htable", "auth=>size=10;autoexpire=1800;")
- modparam("htable", "htable", "ipban=>size=10;autoexpire=60;initval=0;")
- modparam("rtpengine", "rtpengine_sock", "udp:127.0.0.1:2223")
- request_route {
- route(REQINIT);
- if (is_method("CANCEL")) {
- if (t_check_trans()) {
- route(RELAY);
- }
- exit;
- }
- if (is_method("INVITE") || is_method("REGISTER")) {
- route(NAT);
- }
- if (is_method("REGISTER")) {
- route(AUTH);
- }
- route(DIALOG);
- }
- route[REQINIT] {
- if($sht(ipban=>$si) > 5) {
- exit;
- }
- force_rport;
- }
- route[AUTH] {
- if (sht_match_name("auth", "eq", "$Au")) {
- if (!pv_auth_check("$fd", "$sht(auth=>$Au)", "0", "1")) {
- auth_challenge("$fd", "1");
- $sht(ipban=>$si) = $sht(ipban=>$si) + 1;
- exit;
- }
- consume_credentials();
- $sht(ipban=>$si) = $null;
- if (is_method("REGISTER")) {
- save("location");
- exit;
- }
- } else {
- if (!auth_check("$fd", "subscriber", "1")) {
- auth_challenge("$fd", "1");
- $sht(ipban=>$si) = $sht(ipban=>$si) + 1;
- exit;
- }
- $sht(auth=>$Au) = $avp(pass);
- $sht(ipban=>$si) = $null;
- consume_credentials();
- if (is_method("REGISTER")) {
- save("location");
- exit;
- }
- }
- }
- route[NAT] {
- if (nat_uac_test("19")) {
- if (is_method("REGISTER")) {
- set_contact_alias();
- } else {
- if(is_first_hop()) {
- set_contact_alias();
- }
- }
- }
- return;
- }
- route[DIALOG] {
- if (is_method("INVITE")) {
- route(AUTH);
- if (!lookup("location")) {
- sl_send_reply("403", "Forbidden");
- exit;
- }
- handle_ruri_alias();
- record_route();
- route(RELAY);
- }
- if (has_totag()) {
- if (loose_route()) {
- handle_ruri_alias();
- route(RELAY);
- }
- }
- if (is_method("ACK")) {
- if ( t_check_trans() ) {
- route(RELAY);
- exit;
- } else {
- exit;
- }
- }
- }
- route[RELAY] {
- if (has_body("application/sdp")) {
- rtpengine_manage("replace-session-connection replace-origin ICE=remove direction=internal direction=external");
- }
- t_on_reply("REPLY");
- t_relay();
- }
- onreply_route[REPLY] {
- route(NAT);
- if (has_body("application/sdp")) {
- rtpengine_manage("replace-session-connection replace-origin ICE=remove direction=internal direction=external");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement