Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # $Id: opensips.cfg 9742 2013-02-05 10:24:48Z vladut-paiu $
- #
- # OpenSIPS residential configuration script
- # by OpenSIPS Solutions <team@opensips-solutions.com>
- #
- # This script was generated via "make menuconfig", from
- # the "Residential" scenario.
- # You can enable / disable more features / functionalities by
- # re-generating the scenario with different options.#
- #
- # Please refer to the Core CookBook at:
- # http://www.opensips.org/Resources/DocsCookbooks
- # for a explanation of possible statements, functions and parameters.
- #
- ###################################
- ####### Global Parameters #########
- ###################################
- debug=3
- log_stderror=no
- log_facility=LOG_LOCAL0
- fork=yes
- children=4
- /* uncomment the following lines to enable debugging */
- #debug=6
- #fork=no
- #log_stderror=yes
- /* uncomment the next line to enable the auto temporary blacklisting of
- not available destinations (default disabled) */
- #disable_dns_blacklist=no
- /* uncomment the next line to enable IPv6 lookup after IPv4 dns
- lookup failures (default disabled) */
- #dns_try_ipv6=yes
- /* comment the next line to enable the auto discovery of local aliases
- based on revers DNS on IPs */
- auto_aliases=no
- listen=udp:10.10.10.123:5060 # CUSTOMIZE ME
- disable_tcp=yes
- disable_tls=yes
- ################################
- ####### Modules Section ########
- ################################
- #set module path
- mpath="/usr/local/server/pbx//lib64/opensips/modules/"
- #### SIGNALING module
- loadmodule "signaling.so"
- #### StateLess module
- loadmodule "sl.so"
- #### Transaction Module
- loadmodule "tm.so"
- modparam("tm", "fr_timer", 5)
- modparam("tm", "fr_inv_timer", 30)
- modparam("tm", "restart_fr_on_each_reply", 0)
- modparam("tm", "onreply_avp_mode", 1)
- #### Record Route Module
- loadmodule "rr.so"
- /* do not append from tag to the RR (no need for this script) */
- modparam("rr", "append_fromtag", 0)
- #### MAX ForWarD module
- loadmodule "maxfwd.so"
- #### SIP MSG OPerationS module
- loadmodule "sipmsgops.so"
- #### FIFO Management Interface
- loadmodule "mi_fifo.so"
- modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
- modparam("mi_fifo", "fifo_mode", 0666)
- #### URI module
- loadmodule "uri.so"
- modparam("uri", "use_uri_table", 0)
- #### USeR LOCation module
- loadmodule "usrloc.so"
- modparam("usrloc", "nat_bflag", "NAT")
- modparam("usrloc", "db_mode", 0)
- #### REGISTRAR module
- loadmodule "registrar.so"
- modparam("registrar", "tcp_persistent_flag", "TCP_PERSISTENT")
- /* uncomment the next line not to allow more than 10 contacts per AOR */
- #modparam("registrar", "max_contacts", 10)
- #### ACCounting module
- loadmodule "acc.so"
- /* what special events should be accounted ? */
- modparam("acc", "early_media", 0)
- modparam("acc", "report_cancels", 0)
- /* by default we do not adjust the direct of the sequential requests.
- if you enable this parameter, be sure the enable "append_fromtag"
- in "rr" module */
- modparam("acc", "detect_direction", 0)
- modparam("acc", "failed_transaction_flag", "ACC_FAILED")
- /* account triggers (flags) */
- modparam("acc", "log_flag", "ACC_DO")
- modparam("acc", "log_missed_flag", "ACC_MISSED")
- #### MySQL module
- loadmodule "db_mysql.so"
- #### AUTH module
- loadmodule "auth.so"
- /*modparam("usrloc", "db_mode", 0); #THIS LINE MUST TO BE COMMENTED
- */
- modparam("usrloc", "db_mode", 2)
- modparam("usrloc", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
- #### AUTHDB module
- loadmodule "auth_db.so"
- /* uncomment the following lines if you want to enable the DB based authentication */
- modparam("auth_db", "calculate_ha1", 1)
- modparam("auth_db", "password_column", "password")
- modparam("auth_db", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
- modparam("auth_db", "load_credentials", "")
- #### DB Alias module
- #loadmodule "alias_db.so"
- #modparam("alias_db", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
- #### Domain module
- #loadmodule "domain.so"
- #modparam("domain", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
- #modparam("domain", "db_mode", 1) # Use caching
- #### XCAP module
- loadmodule "xcap.so"
- modparam("xcap", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
- #modparam("xcap", "xcap_table", "xcap")
- modparam("xcap", "integrated_xcap_server", 1)
- loadmodule "xcap_client.so"
- #### Presence module
- loadmodule "presence.so"
- loadmodule "presence_xml.so"
- modparam("presence", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
- modparam("presence", "server_address", "sip:10.10.10.123:5060")
- #modparam("presence_xml", "force_active", 1)
- /*Presence module table configuration.*/
- #modparam("presence", "presentity_table", "presentity")
- #modparam("presence", "active_watchers_table", "active_watchers")
- #modparam("presence", "watchers_table", "watchers")
- /*The period at which to clean the expired subscription dialogs.*/
- #modparam("presence", "clean_period", 100)
- /*The period at which to synchronize cached subscriber info with the database.*/
- #modparam("presence", "db_update_period", 100)
- /*The extra time to store a subscription/publication.*/
- #modparam("presence", "expires_offset", 10)
- /*The the maximum admissible expires value for SUBSCRIBE and PUBLISH messages.*/
- #modparam("presence", "max_expires_subscribe", 3600)
- #modparam("presence", "max_expires_publish", 3600)
- /*Setting this parameter enables a fallback to db mode of operation on cache miss event.*/
- modparam("presence", "fallback2db", 1)
- /*The size of the hash table to store subscription dialogs and publish records. This parameter will be used as the power of 2 when computing table size.*/
- #modparam("presence", "subs_htable_size", 11)
- #modparam("presence", "pres_htable_size", 11)
- /*The number of days to keep the record of a subscription in server database if the subscription is in pending or waiting state*/
- #modparam("presence", "waiting_subs_daysno", 10)
- /*If this parameter is set, when no published info is found for a user, the presence server will generate a dummy body with status 'closed' and use it when sending Notify, instead of notifying with no body.*/
- modparam("presence", "notify_offline_body", 1)
- #### Msilo module
- loadmodule "msilo.so"
- modparam("msilo", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
- #modparam("msilo", "db_table", "silo")
- #modparam("msilo", "sc_mid", "id")
- /*The body of the notification message. It can contain pseudo-variables.*/
- #modparam("msilo","contact_hdr","Contact: registrar@localhost:5060;msilo=yes\r\n")
- #modparam("msilo","content_type_hdr","Content-Type: text/plain\r\n")
- #modparam("msilo", "offline_message", "*** User $rU is offline!")
- /*Expire time of stored messages - seconds. When this time passed, the message is silently discarded from database.*/
- #modparam("msilo", "expire_time", 36000) # 36000 secs = 10 hrs
- ##############################
- ####### Routing Logic ########
- ##############################
- # main request routing logic
- route {
- # Preventing loops in routes ...
- if (! mf_process_maxfwd_header("10")) {
- sl_send_reply("483", "Too Many Hops");
- exit;
- }
- if (msg:len >= 2048 ) {
- sl_send_reply("513", "Message too big");
- exit;
- };
- # For processing sequence requests ...
- if (has_totag()) {
- # sequential request withing a dialog should
- # take the path determined by record-routing
- if (loose_route()) {
- if (is_method("BYE")) {
- setflag(ACC_DO); # do accounting ...
- setflag(ACC_FAILED); # ... even if the transaction fails
- } else if (is_method("INVITE")) {
- # even if in most of the cases is useless, do RR for
- # re-INVITEs alos, as some buggy clients do change route set
- # during the dialog.
- record_route();
- }
- # route it out to whatever destination was set by loose_route()
- # in $du (destination URI).
- route(relay);
- } else {
- if (is_method("SUBSCRIBE") && $rd == "10.10.10.123") {
- # in-dialog subscribe requests
- route(presence);
- exit;
- } else if ( is_method("ACK") ) {
- if ( t_check_trans() ) {
- # non loose-route, but stateful ACK; must be an ACK after
- # a 487 or e.g. 404 from upstream server
- t_relay();
- exit;
- } else {
- # ACK without matching transaction ->
- # ignore and discard
- exit;
- }
- }
- sl_send_reply("404","Not here");
- }
- exit;
- }
- # CANCEL processing
- # Only need to be routed to the destination where we already routed the INVITE ...
- if (is_method("CANCEL"))
- {
- if (t_check_trans())
- t_relay();
- exit;
- }
- # Determine if a specific request belongs to a transaction.
- # In this point of the script, the function is being used to stop the script if the request is a retransmission.
- t_check_trans();
- # Perform authentication in NON-REGISTER requests ...
- if ( !is_method("REGISTER") && from_uri==myself) {
- #if (!proxy_authorize("", "subscriber")) {
- # proxy_challenge("", "0");
- # exit;
- #}
- #if (!db_check_from()) {
- # sl_send_reply("403","Forbidden auth ID");
- # exit;
- #}
- # Prevent the credentials from relaying to the destination ...
- #consume_credentials();
- # caller authenticated ... woow
- }
- # Preloaded route checking
- if (loose_route()) {
- xlog("L_ERR", "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
- if (!is_method("ACK"))
- sl_send_reply("403","Preload Route denied");
- exit;
- }
- # Record routing
- if (!is_method("REGISTER|MESSAGE"))
- record_route();
- # account only INVITEs
- if (is_method("INVITE")) {
- setflag(ACC_DO); # do accounting
- }
- # If request is for some other domain, then relay it simply ...
- # Hence me is proxying this ...
- if (!uri==myself) {
- append_hf("P-hint: outbound\r\n");
- route(relay);
- }
- # requests for my domain
- if (is_method("PUBLISH|SUBSCRIBE"))
- {
- route(presence);
- # sl_send_reply("503", "Service Unavailable");
- # exit;
- }
- if (is_method("REGISTER"))
- {
- # authenticate the REGISTER requests (uncomment to enable auth)
- #if (!www_authorize("", "subscriber")) {
- # www_challenge("", "0");
- # exit;
- #}
- #if (!db_check_to()) {
- # sl_send_reply("403","Forbidden auth ID");
- # exit;
- #}
- #if ( 0 ) setflag(TCP_PERSISTENT);
- if (!save("location"))
- sl_reply_error();
- log("REGISTER received -> dumping messages with MSILO\n");
- # MSILO - dumping user's offline messages
- if (m_dump())
- log("MSILO: offline messages dumped - if they were\n");
- else
- log("MSILO: no offline messages dumped\n");
- exit;
- }
- if ($rU==NULL) {
- # request with no Username in RURI
- sl_send_reply("484","Address Incomplete");
- exit;
- }
- # apply DB based aliases (uncomment to enable)
- #alias_db_lookup("dbaliases");
- # do lookup with method filtering, and if destination is not found ...
- if (!lookup("location","m")) {
- if (! t_newtran()) {
- sl_reply_error();
- exit;
- };
- # we do not care about anything else but MESSAGEs from here now ...
- if (!method=="MESSAGE")
- {
- if (!t_reply("404", "Not found"))
- {
- sl_reply_error();
- }
- exit;
- };
- log("MESSAGE received -> storing using MSILO\n");
- # MSILO - storing as offline message
- if (m_store("$ru")) {
- log("MSILO: offline message stored\n");
- if (!t_reply("202", "Accepted")) {
- sl_reply_error();
- }
- } else {
- log("MSILO: offline message NOT stored\n");
- if (!t_reply("503", "Service Unavailable")) {
- sl_reply_error();
- }
- }
- exit;
- }
- # when routing via usrloc, log the missed calls also
- setflag(ACC_MISSED);
- route(relay);
- }
- route[relay] {
- # for INVITEs enable some additional helper routes
- if (is_method("INVITE")) {
- t_on_branch("per_branch_ops");
- t_on_reply("handle_nat");
- t_on_failure("missed_call");
- }
- if (!t_relay()) {
- send_reply("500", "Internal Error");
- }
- exit;
- }
- # Presence route
- route[presence] {
- if (!t_newtran()) {
- sl_reply_error();
- exit;
- };
- if(is_method("PUBLISH")) {
- if($hdr(Sender)!= NULL)
- handle_publish("$hdr(Sender)");
- else
- handle_publish();
- }
- else if( is_method("SUBSCRIBE")) {
- handle_subscribe();
- }
- exit;
- }
- branch_route[per_branch_ops] {
- xlog("new branch at $ru\n");
- }
- onreply_route[handle_nat] {
- xlog("incoming reply\n");
- }
- failure_route[missed_call] {
- if (is_method("MESSAGE"))
- {
- log(1,"MSILO:the downstream UA doesn't support MESSAGEs\n");
- # we have changed the R-URI with the contact address, ignore it now
- if (m_store("$ou")) {
- log("MSILO: offline message stored\n");
- t_reply("202", "Accepted");
- } else {
- log("MSILO: offline message NOT stored\n");
- t_reply("503", "Service Unavailable");
- };
- exit;
- };
- if (t_was_cancelled()) {
- exit;
- }
- # uncomment the following lines if you want to block client
- # redirect based on 3xx replies.
- ##if (t_check_status("3[0-9][0-9]")) {
- ##t_reply("404","Not found");
- ## exit;
- ##}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement