|
1 ## |
|
2 ## opensips.cfg -- OpenSIPS server configuration |
|
3 ## |
|
4 |
|
5 # |
|
6 # GLOBAL CONFIGURATION PARAMETERS |
|
7 # |
|
8 |
|
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" |
|
21 |
|
22 # network configuration |
|
23 alias="sip.example.com" |
|
24 listen="127.0.0.1" |
|
25 port=5060 |
|
26 |
|
27 # |
|
28 # EXTENSION MODULE LOADING |
|
29 # |
|
30 |
|
31 #loadmodule "@l_prefix@/lib/opensips/modules/dbtext.so" |
|
32 |
|
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" |
|
40 |
|
41 #loadmodule "@l_prefix@/lib/opensips/modules/auth.so" |
|
42 #loadmodule "@l_prefix@/lib/opensips/modules/auth_db.so" |
|
43 |
|
44 #loadmodule "@l_prefix@/lib/opensips/modules/nathelper.so" |
|
45 |
|
46 # |
|
47 # EXTENSION MODULE CONFIGURATION |
|
48 # |
|
49 |
|
50 # module rr: |
|
51 modparam("rr", "enable_full_lr", 1) |
|
52 |
|
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") |
|
57 |
|
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") |
|
63 |
|
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") |
|
72 |
|
73 # |
|
74 # MAIN ROUTING LOGIC |
|
75 # |
|
76 |
|
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 }; |
|
88 |
|
89 #if (method == "INVITE" && uri != myself) { |
|
90 # sl_send_reply("403", "No relaying"); |
|
91 # exit; |
|
92 #}; |
|
93 |
|
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 #}; |
|
112 |
|
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 }; |
|
120 |
|
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 }; |
|
128 |
|
129 if (uri != myself) { |
|
130 # mark routing logic in request |
|
131 append_hf("P-hint: outbound\r\n"); |
|
132 route(1); |
|
133 }; |
|
134 |
|
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 }; |
|
148 |
|
149 lookup("aliases"); |
|
150 if (uri != myself) { |
|
151 append_hf("P-hint: outbound alias\r\n"); |
|
152 route(1); |
|
153 }; |
|
154 |
|
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 }; |
|
162 |
|
163 route(1); |
|
164 } |
|
165 |
|
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 }; |
|
172 |
|
173 # NAT: if client or server know to be behind a NAT, enable relay |
|
174 #if (isflagset(6)) { |
|
175 # force_rtp_proxy(); |
|
176 #}; |
|
177 |
|
178 # NAT: processing of replies; apply to all transactions |
|
179 #t_on_reply("1"); |
|
180 |
|
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 } |
|
186 |
|
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 #} |
|
198 |