-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbasic.cfg
382 lines (303 loc) · 9.85 KB
/
basic.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
include_file "vars.cfg"
#-------------------- Modules Section -----------------------------------------#
loadmodule "kex.so"
loadmodule "corex.so"
#-------- Loading Mod TM ------------------------------------------------------#
loadmodule "tm.so"
modparam("tm", "fr_timer", 10000)
modparam("tm", "fr_inv_timer", 180000)
modparam("tm", "disable_6xx_block", 1)
loadmodule "tmx.so"
modparam("tmx", "precheck_trans", 1)
#-------- Loading Mod SL ---------------------------------------------#
loadmodule "sl.so"
#-------- Loading Mod RR ---------------------------------------------#
loadmodule "rr.so"
modparam("rr", "append_fromtag", 0)
modparam("rr", "enable_full_lr", 1)
#-------- Loading Mod PV ---------------------------------------------#
loadmodule "pv.so"
modparam("pv", "varset", "defaultChannels=i:2")
modparam("pv", "varset", "max_attempts=i:2")
#-------- Loading Mod AVPOPS -----------------------------------------#
loadmodule "avpops.so"
#-------- Loading Mod JANNSON AND MONGODB ----------------------------#
loadmodule "jansson.so"
loadmodule "db_mongodb.so"
loadmodule "ndb_mongodb.so"
modparam("ndb_mongodb", "server", MONGOPATH)
#-------- Loading Mod MAXFWD -----------------------------------------#
loadmodule "maxfwd.so"
#-------- Loading Mod USRLOC -----------------------------------------#
loadmodule "usrloc.so"
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "db_url", DBURL)
modparam("usrloc", "use_domain", 1)
modparam("usrloc", "matching_mode", 0)
modparam("usrloc", "desc_time_order", 1)
modparam("usrloc", "nat_bflag", FLB_NATB)
modparam("usrloc", "db_insert_null", 1)
#-------- Loading Mod REGISTRAR -------------------------------------#
loadmodule "registrar.so"
modparam("registrar", "received_avp", "")
modparam("registrar", "received_param", "rcv")
modparam("registrar", "outbound_mode", 0)
#-------- Loading Mod AUTH -----------------------------------------#
loadmodule "auth.so"
modparam("auth", "use_domain", 1)
modparam("auth", "nonce_count", 1)
modparam("auth", "qop", "auth")
#-------- Loading Mod DIALOG ---------------------------------------#
loadmodule "dialog.so"
modparam("dialog", "db_url", DBURL)
modparam("dialog", "enable_stats", 1)
modparam("dialog", "dlg_match_mode", 1)
modparam("dialog", "db_mode", 1)
modparam("dialog", "db_update_period", 45)
modparam("dialog", "profiles_with_value", "endptChannels;custChannels;didChannels;")
modparam("dialog", "dlg_flag", 4)
#-------- Loading Mod NATHELPER ------------------------------------#
loadmodule "nathelper.so"
loadmodule "nat_traversal.so"
modparam("nat_traversal", "keepalive_interval", 25)
modparam("nat_traversal", "keepalive_from", "sip:[email protected]")
modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
#-------- Loading Mod IPOPS -----------------------------------------#
loadmodule "ipops.so"
#-------- Loading Mod UAC -------------------------------------------#
loadmodule "uac.so"
modparam("uac","restore_mode","none")
modparam("uac","credential","username:domain:password")
modparam("uac","auth_realm_avp","$avp(realm)")
modparam("uac","auth_username_avp","$avp(siptrunk_username)")
modparam("uac","auth_password_avp","$avp(siptrunk_password)")
#-------- Loading Mod REDIS -----------------------------------------#
loadmodule "ndb_redis.so"
modparam("ndb_redis", "server", REDIS)
#-------- Loading Mod RTPPROXY -------------------------------------#
loadmodule "rtpengine.so"
modparam("rtpengine", "rtpengine_sock", RTPENGINE)
#-------- Loading Mod XLOG XHTTP SIPUTILS AND SANITY ---------------#
loadmodule "textops.so"
loadmodule "sdpops.so"
loadmodule "debugger.so"
loadmodule "siputils.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "xhttp.so"
loadmodule "jsonrpcs.so"
modparam("jsonrpcs", "transport", 1)
#----------------------- Loading Module HASH TABLE ----------------------------#
loadmodule "htable.so"
modparam("htable", "htable", "rtpProxy=>size=8;autoexpire=300;")
# ----- Loading Mod ACC ----------------------------------------------#
loadmodule "acc.so"
modparam("acc", "early_media", 0)
modparam("acc", "report_ack", 0)
modparam("acc", "report_cancels", 0)
modparam("acc", "detect_direction", 0)
modparam("acc", "db_insert_mode", 2)
modparam("acc", "cdr_enable", 0)
modparam("acc", "db_url", DBURL)
modparam("acc", "cdrs_table", "sessions")
modparam("acc", "db_flag", FLT_ACC)
modparam("acc", "db_missed_flag", FLT_ACCMISSED)
modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)
modparam("acc", "db_table_missed_calls", "failed_sessions")
modparam("acc", "time_mode", 1)
modparam("acc", "cdr_start_on_confirmed", 1)
modparam("acc", "cdr_extra","rtpProxy=$dlg_var(rtpProxy);attempt=$dlg_var(call_attempts);src_ip=$dlg_var(src_ip);calling_num=$dlg_var(caller_id);called_number=$dlg_var(called_number);sipCode=$dlg_var(sip_code);sipReason=$dlg_var(sip_reason)")
modparam("acc", "db_extra","rtpProxy=$dlg_var(rtpProxy);attempt=$dlg_var(call_attempts);src_ip=$dlg_var(src_ip);calling_num=$dlg_var(caller_id);called_number=$dlg_var(called_number);sipCode=$dlg_var(sip_code);sipReason=$dlg_var(sip_reason)")
# ----- Loading EXEC ----------------------------------------------#
loadmodule "exec.so"
modparam("exec", "time_to_kill", 20)
#---------------------- Routing Logic --------------------------------------#
route {
# per request initial checks
route(REQINIT);
# NAT detection
route(NATDETECT);
# CANCEL processing
if (is_method("CANCEL")) {
if (t_check_trans()){
route(RELAY);
}
exit;
}
#handle retransmissions
if (!is_method("ACK")) {
if(t_precheck_trans()) {
t_check_trans();
exit;
}
t_check_trans();
}
# handle requests within SIP dialogs
route(WITHINDLG);
### only initial requests (no To tag)
# handle retransmissions
if(t_precheck_trans()) {
t_check_trans();
exit;
}
t_check_trans();
# handle registrations
if (is_method("REGISTER")){
sl_send_reply("404","Not Handled Here");
}
remove_hf("Route");
if (is_method("INVITE")) {
record_route();
}
# account only INVITEs
if (is_method("INVITE")) {
route(call_source);
}
if ($rU==$null) {
# request with no Username in RURI
sl_send_reply("484","Address Incomplete");
exit;
}
}
route[REQINIT] {
if($ua =~ "(friendly-scanner|sipvicious|sipcli|VaxSIPUserAgent|voxalot|MizuPhone|Ozeki|tramb2017|voip|hello)") {
# silent drop for scanners
xlog("L_INFO","Blocking scanners and pushing IPs to iptables");
exec_avp("iptables -A INPUT -s $si -j DROP");
sl_send_reply("403", "Forbidden");
exit;
}
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483","Too Many Hops");
exit;
}
if(is_method("OPTIONS") && uri==myself && $rU==$null) {
sl_send_reply("200","Keepalive");
exit;
}
if(!sanity_check("1511", "7")) {
xlog("Malformed SIP message from $si:$sp\n");
exit;
}
}
route[WITHINDLG] {
if (!has_totag()) return;
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
route(DLGURI);
if (is_method("BYE")) {
route(rtp_engine);
xlog("L_INFO","BYE in LR ; handling RTP Engine");
} else if ( is_method("ACK") ) {
route(NATMANAGE);
} else if ( is_method("NOTIFY") ) {
# Add Record-Route for in-dialog NOTIFY as per RFC 6665.
record_route();
}
route(RELAY);
exit;
}
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
# no loose-route, but stateful ACK;
# must be an ACK after a 487
# or e.g. 404 from upstream server
route(RELAY);
exit;
} else {
# ACK without matching transaction ... ignore and discard
exit;
}
}
sl_send_reply("404","Not here");
exit;
}
route[DLGURI] {
if(!isdsturiset()) {
handle_ruri_alias();
}
return;
}
branch_route[MANAGE_BRANCH] {
xdbg("new branch [$T_branch_idx] to $ru\n");
route(NATMANAGE);
}
onreply_route[MANAGE_REPLY] {
xdbg("incoming reply\n");
if(status=~"[12][0-9][0-9]") {
route(NATMANAGE);
}
}
failure_route[MANAGE_FAILURE] {
route(NATMANAGE);
if (t_is_canceled()) exit;
}
route[NATDETECT] {
force_rport();
if (nat_uac_test("19")) {
if (is_method("REGISTER")) {
fix_nated_register();
} else {
if(is_first_hop()) {
set_contact_alias();
}
}
setflag(FLT_NATS);
}
return;
}
route[NATMANAGE] {
if (is_request()) {
if(has_totag()) {
if(check_route_param("nat=yes")) {
setbflag(FLB_NATB);
}
}
}
if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB))) return;
if (is_request()) {
if (!has_totag()) {
if(t_is_branch_route()) {
add_rr_param(";nat=yes");
}
}
}
if (is_reply()) {
if(isbflagset(FLB_NATB)) {
if(is_first_hop())
set_contact_alias();
}
}
return;
}
event_route[core:worker-one-init]{
exec_avp("cat /usr/local/kamailio/etc/kamailio/scripts/scripts.txt | redis-cli --pipe");
xlog("L_INFO","***** Kamailio : InboundSIP Project has started ****");
}
route[RELAY] {
if (is_method("INVITE|BYE|SUBSCRIBE|UPDATE")) {
if(!t_is_set("branch_route")) t_on_branch("MANAGE_BRANCH");
}
if (is_method("INVITE|SUBSCRIBE|UPDATE")) {
if(!t_is_set("onreply_route")) t_on_reply("MANAGE_REPLY");
}
if (is_method("INVITE")) {
if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE");
}
if (!t_relay()) {
sl_reply_error();
}
exit;
}
event_route[xhttp:request] {
xlog("L_INFO","http request ");
if ($hu =~ "^/RPC") {
xlog("L_INFO","http request /RPC");
jsonrpc_dispatch();
} else {
xlog("L_INFO","http request ");
xhttp_reply("200", "OK", "text/html","<html><body>Wrong URL $hu</body></html>");
}
return;
}