opensips/opensips.cfg

Wed, 21 Sep 2011 14:02:13 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 21 Sep 2011 14:02:13 +0200
changeset 376
8f552d1cd671
child 377
67e813202d53
permissions
-rw-r--r--

Import package vendor original specs for necessary manipulations.

     1 ##
     2 ##  opensips.cfg -- OpenSIPS server configuration
     3 ##
     5 #
     6 #   GLOBAL CONFIGURATION PARAMETERS
     7 #
     9 #   process configuration
    10 debug=1
    11 log_stderror=no
    12 fork=yes
    13 check_via=no
    14 dns=no
    15 rev_dns=no
    16 children=4
    17 user="@l_rusr@"
    18 group="@l_rgrp@"
    19 fifo="@l_prefix@/var/opensips/opensips.fifo"
    20 workdir="@l_prefix@/var/opensips"
    22 #   network configuration
    23 alias="sip.example.com"
    24 listen="127.0.0.1"
    25 port=5060
    27 #
    28 #   EXTENSION MODULE LOADING
    29 #
    31 #loadmodule "@l_prefix@/lib/opensips/modules/dbtext.so"
    33 loadmodule "@l_prefix@/lib/opensips/modules/sl.so"
    34 loadmodule "@l_prefix@/lib/opensips/modules/tm.so"
    35 loadmodule "@l_prefix@/lib/opensips/modules/rr.so"
    36 loadmodule "@l_prefix@/lib/opensips/modules/maxfwd.so"
    37 loadmodule "@l_prefix@/lib/opensips/modules/usrloc.so"
    38 loadmodule "@l_prefix@/lib/opensips/modules/registrar.so"
    39 loadmodule "@l_prefix@/lib/opensips/modules/textops.so"
    41 #loadmodule "@l_prefix@/lib/opensips/modules/auth.so"
    42 #loadmodule "@l_prefix@/lib/opensips/modules/auth_db.so"
    44 #loadmodule "@l_prefix@/lib/opensips/modules/nathelper.so"
    46 #
    47 #   EXTENSION MODULE CONFIGURATION
    48 #
    50 #   module rr:
    51 modparam("rr", "enable_full_lr", 1)
    53 #   module usrloc:
    54 modparam("usrloc", "db_mode", 0)
    55 #modparam("usrloc", "db_mode", 2)
    56 #modparam("usrloc|auth_db", "db_url", "dbtext://@l_prefix@/var/opensips/db")
    58 #   module auth:
    59 #modparam("auth_db", "calculate_ha1", 1)
    60 #modparam("auth_db", "password_column", "password")
    61 #modparam("auth_db", "user_column", "username")
    62 #modparam("auth_db", "domain_column", "domain")
    64 #   module nathelper:
    65 #modparam("registrar", "nat_flag", 6)
    66 #modparam("nathelper", "natping_interval", 30)
    67 #modparam("nathelper", "ping_nated_only", 1)
    68 #modparam("nathelper", "rtpproxy_sock", "unix:@l_prefix@/var/opensips/opensips_rtpproxy.sock")
    69 #modparam("nathelper", "rtpproxy_disable", 0)
    70 #modparam("nathelper", "rtpproxy_disable_tout", 20)
    71 #modparam("nathelper", "sipping_from", "sip:pinger@sip.example.com")
    73 #
    74 #   MAIN ROUTING LOGIC
    75 #
    77 route{
    78     #   initial sanity checks -- messages with
    79     #   max_forwards==0, or excessively long requests
    80     if (!mf_process_maxfwd_header("10")) {
    81         sl_send_reply("483", "Too Many Hops");
    82         exit;
    83     };
    84     if (msg:len >= max_len) {
    85         sl_send_reply("513", "Message too big");
    86         exit;
    87     };
    89     #if (method == "INVITE" && uri != myself) {
    90     #    sl_send_reply("403", "No relaying");
    91     #    exit;
    92     #};
    94     #   NAT: special handling for NAT'ed clients; first, NAT test is
    95     #   executed: it looks for via!=received and RFC1918 addresses in
    96     #   Contact (may fail if line-folding is used); also, the received
    97     #   test should, if completed, should check all vias for presence of
    98     #   received.
    99     #if (nat_uac_test("3")) {
   100     #    #   allow RR-ed requests, as these may indicate that NAT-enabled
   101     #    #   aproxy takes care of it; unless it is REGISTER
   102     #    if (method == "REGISTER" || ! search("^Record-Route:")) {
   103     #        log("LOG: Someone trying to register from private IP, rewriting\n");
   104     #        fix_nated_contact(); # rewrite contact with source IP of signalling
   105     #        if (method == "INVITE") {
   106     #            fix_nated_sdp("1"); # add direction=active to SDP
   107     #        };
   108     #        force_rport(); # add rport parameter to topmost Via
   109     #        setflag(6);    # mark as NAT'ed
   110     #    };
   111     #};
   113     #   we record-route all messages -- to make sure that
   114     #   subsequent messages will go through our proxy; that's
   115     #   particularly good if upstream and downstream entities
   116     #   use different transport protocol
   117     if (method != "REGISTER") {
   118         record_route();
   119     };
   121     #   subsequent messages withing a dialog should take the
   122     #   path determined by record-routing
   123     if (loose_route()) {
   124         #   mark routing logic in request
   125         append_hf("P-hint: rr-enforced\r\n"); 
   126         route(1);
   127     };
   129     if (uri != myself) {
   130         #   mark routing logic in request
   131         append_hf("P-hint: outbound\r\n"); 
   132         route(1);
   133     };
   135     #   if the request is for other domain use USRLOC
   136     #   (in case, it does not work, use the following command
   137     #   with proper names and addresses in it)
   138     if (uri == myself) {
   139         if (method == "REGISTER") {
   140             #   uncomment this if you want to use digest authentication
   141             #if (!www_authorize("sip.example.com", "subscriber")) {
   142             #    www_challenge("sip.example.com", "0");
   143             #    exit;
   144             #};
   145             save("location");
   146             exit;
   147         };
   149         lookup("aliases");
   150         if (uri != myself) {
   151             append_hf("P-hint: outbound alias\r\n"); 
   152             route(1);
   153         };
   155         #   native SIP destinations are handled using our USRLOC DB
   156         if (!lookup("location")) {
   157             sl_send_reply("404", "Not Found");
   158             exit;
   159         };
   160         append_hf("P-hint: usrloc applied\r\n"); 
   161     };
   163     route(1);
   164 }
   166 route[1] {
   167     #   disable RFC1918 peers
   168     if (uri =~ "[@:](192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.)" && !search("^Route:")) {
   169         sl_send_reply("479", "We don't forward to RFC 1918 IPv4 addresses");
   170         exit;
   171     };
   173     #   NAT: if client or server know to be behind a NAT, enable relay
   174     #if (isflagset(6)) {
   175     #    force_rtp_proxy();
   176     #};
   178     #   NAT: processing of replies; apply to all transactions
   179     #t_on_reply("1");
   181     #   send it out now; use stateful forwarding as it works reliably even for UDP2TCP
   182     if (!t_relay()) {
   183         sl_reply_error();
   184     };
   185 }
   187 #onreply_route[1] {
   188     #   NAT: is it a NAT'ed transaction ?
   189     #   otherwise, is it a transaction behind a NAT and we did not
   190     #   know at time of request processing ? (RFC1918 contacts)
   191     #if (isflagset(6) && status =~ "(183)|2[0-9][0-9]") {
   192     #    fix_nated_contact();
   193     #    force_rtp_proxy();
   194     #} else if (nat_uac_test("1")) {
   195     #    fix_nated_contact();
   196     #};
   197 #}

mercurial