# ----------- global configuration parameters ------------------------ debug=3 # debug level (cmd line: -dddddddddd) #log_facility=LOG_LOCAL7 fork=yes log_stderror=no # (cmd line: -E) /* Uncomment these lines to enter debugging mode debug=7 # debug level (cmd line: -dddddddddd) fork=no log_stderror=yes */ #debug=3 check_via=no # (cmd. line: -v) dns=no # (cmd. line: -r) rev_dns=no # (cmd. line: -R) #port=5060 #children=4 fifo="/tmp/ser_fifo" alias="mydomain.com" # blind test ? #syn_branch=no # ------------------ module loading ---------------------------------- # Uncomment this if you want to use SQL database loadmodule "/usr/local/lib/ser/modules/mysql.so" loadmodule "/usr/local/lib/ser/modules/sl.so" loadmodule "/usr/local/lib/ser/modules/tm.so" loadmodule "/usr/local/lib/ser/modules/vm.so" loadmodule "/usr/local/lib/ser/modules/rr.so" loadmodule "/usr/local/lib/ser/modules/maxfwd.so" loadmodule "/usr/local/lib/ser/modules/usrloc.so" loadmodule "/usr/local/lib/ser/modules/registrar.so" loadmodule "/usr/local/lib/ser/modules/acc.so" loadmodule "/usr/local/lib/ser/modules/msilo.so" loadmodule "/usr/local/lib/ser/modules/domain.so" loadmodule "/usr/local/lib/ser/modules/nathelper.so" loadmodule "/usr/local/lib/ser/modules/group.so" # Uncomment this if you want digest authentication # mysql.so must be loaded ! loadmodule "/usr/local/lib/ser/modules/auth.so" loadmodule "/usr/local/lib/ser/modules/auth_db.so" # answering machine loadmodule "/usr/local/lib/ser/modules/xlog.so" # ----------------- setting module-specific parameters --------------- # --domain module-- modparam("usrloc", "db_url", "mysql://ser:heslo@localhost/ser") modparam("domain", "db_mode", 1) modparam("domain", "domain_table", "domain") modparam("domain", "domain_col", "domain") # --vm params-- modparam("voicemail", "db_url", "mysql://ser:heslo@localhost/ser") # --group authorization modparam("group", "db_url", "mysql://ser:heslo@localhost/ser") modparam("group", "table", "grp") modparam("group", "user_column", "username") modparam("group", "group_column", "grp") # --acc params-- modparam("acc", "log_level", 1) modparam("acc", "log_flag", 1) modparam("acc", "log_missed_flag", 2) modparam("acc", "log_fmt", "fimos") modparam("acc", "db_url", "mysql://ser:heslo@localhost/ser") modparam("acc", "db_missed_flag", 2) modparam("acc", "db_flag", 1) # -- usrloc params -- #modparam("usrloc", "db_mode", 0) # Uncomment this if you want to use SQL database # for persistent storage and comment the previous line modparam("usrloc", "db_mode", 2) # -- auth params -- # Uncomment if you are using auth module # modparam("auth_db", "calculate_ha1", yes) # # If you set "calculate_ha1" parameter to yes (which true in this config), # uncomment also the following parameter) # modparam("auth_db", "password_column", "password") # -- rr params -- # add value to ;lr param to make some broken UAs happy modparam("rr", "enable_full_lr", 1) modparam("tm", "fr_timer", 10) modparam("tm", "fr_inv_timer", 35) modparam("tm", "wt_timer", 1) # ------------------------- request routing logic ------------------- route { if(method=="INVITE" || method=="BYE") setflag(1); if (!mf_process_maxfwd_header("10")) { log("LOG: Too many hops\n"); sl_send_reply("483", "Alas Too Many Hops"); break; }; if ( msg:len > max_len ) { sl_send_reply("513", "Message too big"); break; }; record_route(); if (loose_route()) { t_relay(); break; }; if (!uri==myself) { t_relay(); break; }; if (uri==myself | uri=~"^sip:.*@mydomain.com" | uri=~"^sip:.*@202.63.111.18" ) { if (method == "REGISTER") { if (!www_authorize("", "subscriber")) { www_challenge("", "0"); break; }; save("aliases"); save("location"); sl_reply_error(); }; if(uri=~"^sip:999@(mydomain\.com|XXX\.XXX\.XXX\.XX)"){ #log(1,"411/911 expression match"); log(1,"asterisk voice dial4 match"); route(3); break; }; if (uri=~"^sip:0091[0-9].*@.*") { sl_send_reply("500", "prefix 522 blocked"); break; }; if (uri=~"^sip:01191[0-9].*@.*") { sl_send_reply("500", "prefix 522 blocked"); break; }; if (uri=~"^sip:1[0-9].*@.*" | uri=~"^sip:01[0-9].*@.*") { if (!is_user_in("From", "ld")) { sl_send_reply("403", "Payment required"); break; }; setflag(1); rewritehostport("Provider ip:5060"); if (!t_relay()) { sl_reply_error(); }; break; }; }; if (is_user_in("Request-URI", "voicemail")) { setflag(4); }; # native SIP destinations are handled using our USRLOC DB if (!lookup("location")) { # handle user which was not found route(4); break; }; # if user is on-line and is in voicemail group, enable redirection if (method == "INVITE" || method=="BYE" || method=="ACK" && isflagset(4)) { setflag(1); t_on_failure("1"); }; t_relay(); } # ------------- handling of unavailable user ------------------ route[3]{ log(1,"route[3]:no user location: foward to voicemail"); rewritehostport("myvoicemailserverip:5090"); t_relay(); } route[4] { # non-Voip -- just send "off-line" if (!(method == "INVITE" || method == "ACK" || method == "CANCEL")) { sl_send_reply("404", "Not Found"); break; }; # not voicemail subscriber if (!isflagset(4)) { sl_send_reply("404", "Not Found and no voicemail turned on"); break; }; # forward to voicemail now rewritehostport("myvoicemailserverip:5090"); t_relay_to_udp("myvoicemailserverip", "5090"); } # if forwarding downstream did not succeed, try voicemail running failure_route[1] { revert_uri(); rewritehostport("myvoicemailserverip:5090"); append_branch(); t_relay_to_udp("myvoicemailserverip", "5090"); }