All pastes #784180 Raw Edit

openser.cfg

public text v1 · immutable
·published 2007-11-19 16:13 UTC
rendered paste body
#
# $Id: openser.cfg 1676 2007-02-21 13:16:34Z bogdan_iancu $
#
# simple quick-start config script
# Please refer to the Core CookBook at http://www.openser.org/dokuwiki/doku.php
# for a explanation of possible statements, functions and parameters.
#

# ----------- global configuration parameters ------------------------

debug=7            # debug level (cmd line: -dddddddddd)
fork=no
log_stderror=yes    # (cmd line: -E)
children=4

# Uncomment these lines to enter debugging mode
#fork=no
#log_stderror=yes
#
listen="10.10.3.190"
port=5060

# uncomment the following lines for TLS support
#disable_tls = 0
#listen = tls:your_IP:5061
#tls_verify_server = 1
#tls_verify_client = 1
#tls_require_client_certificate = 0
#tls_method = TLSv1
#tls_certificate = "/usr/local/etc/openser/tls/user/user-cert.pem"
#tls_private_key = "/usr/local/etc/openser/tls/user/user-privkey.pem"
#tls_ca_list = "/usr/local/etc/openser/tls/user/user-calist.pem"

# ------------------ module loading ----------------------------------

#set module path
mpath="/usr/local/lib/openser/modules/"

# Uncomment this if you want to use SQL database
loadmodule "mysql.so"

loadmodule "xlog.so"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "textops.so"
loadmodule "mi_fifo.so"
loadmodule "uri_db.so"
loadmodule "auth.so"
loadmodule "auth_radius.so"
# Uncomment this if you want digest authentication
# mysql.so must be loaded !
#loadmodule "auth.so"
#loadmodule "auth_db.so"

# ----------------- setting module-specific parameters ---------------

#tm timeout for voicemail params
modparam("tm", "fr_timer", 25)
modparam("tm", "fr_inv_timer", 25)
modparam("tm", "noisy_ctimer", 1)

# -- mi_fifo params --

modparam("mi_fifo", "fifo_name", "/tmp/openser_fifo")

# -- 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 --

modparam("auth_radius", "radius_config","/usr/local/etc/radiusclient-ng/radiusclient.conf")
modparam("auth_radius", "service_type", 15)



# 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)

# -------------------------  request routing logic -------------------

# main routing logic
#Routing Script
route {
 #check for old messages: could mean a problem with the DNS entries or some other loop-causer...
 if (!mf_process_maxfwd_header("10"))
 {
   xlog("L_WARN", "WARNING: Too many hops\n");
   sl_send_reply("483", "Too many hops, forward count exceeded limit\n");
   return;
 };
  
 #check for extremely large messages; we don't need a sip dos attack
 if (msg:len >= 2048)
 {
   xlog("L_WARN", "WARNING: Message too large, >= 2048 bytes\n");
   sl_send_reply("513", "Message too large, exceeded limit\n");
   return;
 };
  
 #record everything besides registers and acks
 if(method!="REGISTER" && method!="ACK")
 {
  setflag(1);
 }; 
  
 #do not send to voicemail if BYE or CANCEL 
 #is used to end call before user pickup or timeout
 if(method=="CANCEL" || method=="BYE")
 {
  setflag(10);
 };
 
 #grant route if route headers already present
 if (loose_route()) 
 {  
   route(1);
   return;
 };
  
 #Always require authentication, which could result in a PSTN, ie $$$
 if (method=="REGISTER")
 {
   if(!radius_www_authorize("caerj.proderj.rj.gov.br"))
   {
    www_challenge("caerj.proderj.rj.gov.br", "0");
    return;
   }
   else
   {
    #Save into user database, used below when checking if user is available
    xlog("L_INFO", "REGISTER: User Authenticated Correctly\n");
    save("location");
    return;
   };
 };
  
 if (method=="INVITE")
 {
  if (uri=~"sip:011[0-9]+@.*")
  {
   #authorize if a call is going to PSTN 
   # if(!proxy_authorize("caerj.proderj.rj.gov.br", "subscriber"))
   #  {
   #   proxy_challenge("caerj.proderj.rj.gov.br", "0");
   #  return;
   #  };
 
   xlog("L_INFO", "CALL: Call to international number\n");
   rewritehostport("127.0.0.1:5070");
  }
  else if(uri=~"sip:\*86@.*")
  {
   #authorize if a call is going to PSTN 
   #if(!proxy_authorize("domain.net", "subscriber"))
   #{
   # proxy_challenge("domain.net", "0");
   # return;
   #};
 
   xlog("L_INFO", "CALL: Call to check voicemail\n");
   rewritehostport("127.0.0.1:5070");
  }
  else
  {
   if (does_uri_exist())
   {
    #Call is to sip client, so do nothing but route
    xlog("L_INFO", "CALL: Sip client\n");
    if (!lookup("location")) 
    {
     sl_send_reply("404", "Not Found");
     log(1, "ERROR: User Not Found\n");
     return;
    };
   }
   else
   {
    #authorize if a call is going to PSTN 
    #if(!proxy_authorize("domain.net", "subscriber"))
    #{
    # proxy_challenge("domain.net", "0");
    # return;
    #};
 
    #Call destination is PSTN, so send it to the gateway (Net.com)
    xlog("L_INFO", "CALL: PSTN gateway\n");
    rewritehostport("127.0.0.1:5070");
   };
  };
   
  #Make sure that all subsequent requests go through us;
  record_route();
 }
 else
 {
  if (does_uri_exist())
  {
   #Call is to sip client, so do nothing but route
   xlog("L_INFO", "CALL: Sip client\n");
   if (!lookup("location")) 
   {
    sl_send_reply("404", "Not Found");
    log(1, "ERROR: User Not Found\n");
    return;
   };
  }
  else
  {
   #Call destination is PSTN, so send it to the gateway (Net.com)
   xlog("L_INFO", "CALL: PSTN gateway\n");
   rewritehostport("127.0.0.1:5070");
  };
  record_route();
 };
 
 #ALL PROCESSING IS DONE, SO ROUTE
 route(1);
}


route[1]
{
#send the call outward

 if(method=="INVITE" && !isflagset(10))
 {
  t_on_failure("2");
 };
 
 if (!t_relay()) 
 {
  xlog("L_WARN", "ERROR: t_relay failed");
  sl_reply_error();
 };

}

failure_route[2]
{
 if(!t_was_cancelled())
 {
  revert_uri();
  rewritehostport("127.0.0.1:5070");
  append_branch();
  #PREVENT SOME CRAZY VOICEMAIL LOOP
  xlog("L_INFO", "INFO: CALL TO VOICEMAIL");
  setflag(10);
  route(1);
 }
}