forked from kamailio/kamailio
/
kamailio.cfg
458 lines (408 loc) · 15 KB
/
kamailio.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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
#!KAMAILIO
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_IPAUTH
#!define WITH_UAC
#!define WITH_USRLOCDB
#!define WITH_ACCDB
#!define WITH_DROUTE
#!define WITH_NAT
#!define WITH_DISPATCHER
#!define WITH_MULTIDOMAIN
#!define WITH_ANTIFLOOD
#!define WITH_LCR
#!define WITH_TLS
#!define WITH_WEBSOCKETS
#!define WITH_MSTEAMS
#!define WITH_TRANSNEXUS
#!define WITH_STIRSHAKEN
#!subst "!DMQ_REPLICATE_ENABLED!0!g"
#!substdef "!INTERNAL_IP_ADDR!68.183.126.77!g"
#!substdef "!INTERNAL_IP_NET!68.183.126.77/32!g"
#!substdef "!INTERNAL_IP6_ADDR!!g"
#!substdef "!INTERNAL_IP6_NET!!g"
#!substdef "!INTERNAL_FQDN!kam.test.dsiprouter.net!g"
#!substdef "!EXTERNAL_IP_ADDR!68.183.126.77!g"
#!substdef "!EXTERNAL_IP6_ADDR!!g"
#!substdef "!EXTERNAL_FQDN!kam.test.dsiprouter.net!g"
#!substdef "!UAC_REG_ADDR!68.183.126.77!g"
#!substdef "!SIP_PORT!5060!g"
#!substdef "!SIPS_PORT!5061!g"
#!substdef "!DMQ_PORT!5090!g"
#!substdef "!WSS_PORT!4443!g"
#!ifdef WITH_MYSQL
#!define DBURL "mysql://kamailio:kamailio@localhost:3306/kamailio"
#!define SQLCONN_KAM "kam=>mysql://kamailio:kamailio@localhost:3306/kamailio"
#!endif
#!ifdef WITH_MULTIDOMAIN
#!define MULTIDOMAIN 1
#!else
#!define MULTIDOMAIN 0
#!endif
#!define FLT_ACC 0
#!define FLT_ACCMISSED 1
#!define FLT_ACCFAILED 2
#!define FLT_DIALOG 3
#!define FLB_NATB 0
#!define FLB_NATSIPPING 1
#!define FLB_WS_DEVICE 2
debug = 2
log_stderror = false
memdbg = 5
memlog = 5
log_facility = LOG_LOCAL0
log_prefix_mode = 1
log_prefix = "[$cfg(name):$cfg(line):$cfg(route)] [$ci:$rm:$rs] "
fork = true
children = 1
max_while_loops = 10000
alias = "EXTERNAL_FQDN:SIP_PORT"
alias = "EXTERNAL_FQDN:SIPS_PORT"
alias = "EXTERNAL_FQDN:DMQ_PORT"
alias = "EXTERNAL_FQDN:WSS_PORT"
listen = udp:127.0.0.1:SIP_PORT
listen = tcp:127.0.0.1:SIP_PORT
listen = udp:INTERNAL_IP_ADDR:SIP_PORT
listen = tcp:INTERNAL_IP_ADDR:SIP_PORT
#!ifdef WITH_TLS
#!ifdef WITH_WEBSOCKETS
listen = tls:INTERNAL_IP_ADDR:WSS_PORT
#!endif
#!endif
port = SIP_PORT
#!ifdef WITH_TLS
enable_tls = true
tcp_accept_no_cl = true
tcp_rd_buf_size = 16384
listen = tls:INTERNAL_IP_ADDR:SIPS_PORT advertise "EXTERNAL_FQDN":SIPS_PORT
#!endif
tcp_connection_lifetime = 3605
server_signature = false
enable_sctp = 0
mhomed=0
#!ifdef WITH_PSTN
pstn.gw_ip = "" desc "PSTN GW Address"
pstn.gw_port = "" desc "PSTN GW Port"
#!endif
#!ifdef WITH_VOICEMAIL
voicemail.srv_ip = "" desc "VoiceMail IP Address"
voicemail.srv_port = "5060" desc "VoiceMail Port"
#!endif
mpath = "/usr/local/lib64/kamailio/modules/"
#!ifdef WITH_TLS
loadmodule "tls.so"
#!endif
#!ifdef WITH_MYSQL
loadmodule "db_mysql.so"
#!endif
loadmodule "kex.so"
loadmodule "corex.so"
loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "sl.so"
loadmodule "rr.so"
loadmodule "path.so"
loadmodule "pv.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "textops.so"
loadmodule "textopsx.so"
loadmodule "siputils.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "ctl.so"
loadmodule "cfg_rpc.so"
loadmodule "acc.so"
loadmodule "xhttp.so"
loadmodule "json.so"
loadmodule "jansson.so"
loadmodule "jsonrpcs.so"
loadmodule "http_async_client.so"
loadmodule "uuid.so"
loadmodule "ipops.so"
loadmodule "htable.so"
loadmodule "dialog.so"
loadmodule "rtimer.so"
loadmodule "sqlops.so"
#!ifdef WITH_AUTH
loadmodule "auth.so"
loadmodule "auth_db.so"
#!ifdef WITH_IPAUTH
loadmodule "permissions.so"
#!endif
#!ifdef WITH_UAC
loadmodule "uac.so"
loadmodule "uac_redirect.so"
#!endif
#!endif
#!ifdef WITH_ALIASDB
loadmodule "alias_db.so"
#!endif
#!ifdef WITH_SPEEDDIAL
loadmodule "speeddial.so"
#!endif
#!ifdef WITH_MULTIDOMAIN
loadmodule "domain.so"
#!endif
#!ifdef WITH_PRESENCE
loadmodule "presence.so"
loadmodule "presence_xml.so"
#!endif
#!ifdef WITH_NAT
loadmodule "nathelper.so"
#!endif
#!ifdef WITH_ANTIFLOOD
loadmodule "pike.so"
#!endif
#!ifdef WITH_XMLRPC
loadmodule "xmlrpc.so"
#!endif
#!ifdef WITH_DROUTE
loadmodule "drouting.so"
#!endif
#!ifdef WITH_DISPATCHER
loadmodule "keepalive.so"
loadmodule "dispatcher.so"
#!endif
#!ifdef WITH_WEBSOCKETS
loadmodule "websocket.so"
#!endif
#!ifdef WITH_STIRSHAKEN
loadmodule "stirshaken.so"
#!endif
# ----- db_mysql params -----
#!ifdef WITH_MYSQL
modparam("db_mysql", "auto_reconnect", 1)
modparam("db_mysql", "unsigned_type", 1)
#!endif
# ---- xlog global params ----
modparam("xlog", "buf_size", 8192)
modparam("xlog", "prefix", "")
# ---- htable global params ----
modparam("htable", "db_url", DBURL)
# ---- dispatcher params ----
#!ifdef WITH_DISPATCHER
modparam("dispatcher", "flags", 2)
modparam("dispatcher", "db_url", DBURL)
modparam("dispatcher", "table_name", "dispatcher")
modparam("dispatcher", "ds_probing_mode", 1) # 1 means to probe each gateway
modparam("dispatcher", "ds_ping_latency_stats", 1) # 1 means to provide latency stats
modparam("dispatcher", "ds_ping_method", "OPTIONS")
modparam("dispatcher", "ds_ping_interval", 30) # How often to ping destinations to check status
modparam("dispatcher", "xavp_dst", "dispatcher_dst") # Will contain selected destination info
modparam("dispatcher", "xavp_dst_mode", 0) # What attributes to set in the xavp
modparam("dispatcher", "xavp_ctx", "dispatcher_ctx") # Will contain current dispatcher context info
modparam("dispatcher", "xavp_ctx_mode", 0) # What attributes to set in the xavp
modparam("dispatcher", "reload_delta", 1) # how quickly (in seconds) a RPC reload is allowed
#!endif
# ----- jsonrpcs params -----
modparam("jsonrpcs", "pretty_format", 1)
modparam("jsonrpcs", "fifo_name", "/var/run/kamailio/kamailio_rpc.fifo")
modparam("jsonrpcs", "transport", 3)
#modparam#("jsonrpcs", "dgram_socket", "/var/run/kamailio/kamailio_rpc.sock")
# ----- ctl params -----
modparam("ctl", "binrpc", "unix:/var/run/kamailio/kamailio_ctl")
# ----- tm params -----
# auto-discard branches from previous serial forking leg
modparam("tm", "failure_reply_mode", 3)
# default retransmission timeout: 30sec
modparam("tm", "fr_timer", 30000)
# default invite retransmission timeout after 1xx: 60sec
modparam("tm", "fr_inv_timer", 60000)
# XAVP used to store contacts used by t_load_contacts()/t_next_contacts()
modparam("tm", "contacts_avp", "tm_contacts")
# Used to store contacts (if any) that it skipped, because they contained same +sip.instance
modparam("tm", "contact_flows_avp", "tm_contact_flows")
# consider branch failures for to_on_failure() routing as well
modparam("tm", "failure_exec_mode", 1)
# ----- rr params -----
# set next param to 1 to add value to ;lr param (helps with some UAs)
modparam("rr", "enable_full_lr", 0)
# append from tag to the RR (no need for this script)
modparam("rr", "append_fromtag", 0)
# ----- registrar params -----
modparam("registrar", "method_filtering", 1)
/* uncomment the next line to disable parallel forking via location */
# modparam("registrar", "append_branches", 0)
/* uncomment the next line not to allow more than 10 contacts per AOR */
#modparam("registrar", "max_contacts", 10)
# max value for expires of registrations
modparam("registrar", "max_expires", 0)
# set it to 1 to enable GRUU
modparam("registrar", "gruu_enabled", 0)
# ----- acc params -----
# what special events should be accounted?
modparam("acc", "early_media", 0)
modparam("acc", "report_ack", 0)
modparam("acc", "report_cancels", 0)
# by default ww do not adjust the direction 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", "log_flag", FLT_ACC)
modparam("acc", "log_facility", "LOG_LOCAL0")
modparam("acc", "log_missed_flag", FLT_ACCMISSED)
modparam("acc", "log_extra",
"src_user=$fU;src_domain=$fd;src_ip=$si;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;"
"calltype=$avp(calltype);src_gwgroupid=$avp(src_gwgroupid);dst_gwgroupid=$avp(dst_gwgroupid)")
modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)
# enhanced DB accounting
#!ifdef WITH_ACCDB
modparam("acc", "db_flag", FLT_ACC)
modparam("acc", "db_missed_flag", FLT_ACCMISSED)
modparam("acc", "db_url", DBURL)
modparam("acc", "db_extra",
"src_user=$fU;src_domain=$fd;src_ip=$si;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;"
"calltype=$avp(calltype);src_gwgroupid=$avp(src_gwgroupid);dst_gwgroupid=$avp(dst_gwgroupid)")
#!endif
# ----- usrloc params -----
/* enable DB persistency for location entries */
#!ifdef WITH_USRLOCDB
modparam("usrloc", "db_url", DBURL)
modparam("usrloc", "db_mode", 3)
modparam("usrloc", "use_domain", MULTIDOMAIN)
modparam("usrloc", "handle_lost_tcp", 1)
#!endif
# ----- auth_db params -----
#!ifdef WITH_AUTH
modparam("auth_db", "db_url", DBURL)
modparam("auth_db", "calculate_ha1", 1)
modparam("auth_db", "password_column", "password")
# We use the rpid field of the subscriber table to track the assigned gwgroup (type of endpoint or carrier)
modparam("auth_db", "load_credentials", "$avp(s:src_gwgroupid)=rpid;")
modparam("auth_db", "use_domain", MULTIDOMAIN)
# ----- permissions params -----
#!ifdef WITH_IPAUTH
modparam("permissions", "db_url", DBURL)
modparam("permissions", "db_mode", 1)
# how quickly (in seconds) a RPC reload is allowed
modparam("permissions", "reload_delta", 1)
#!endif
#!endif
# ----- alias_db params -----
#!ifdef WITH_ALIASDB
modparam("alias_db", "db_url", DBURL)
modparam("alias_db", "use_domain", MULTIDOMAIN)
#!endif
# ----- speeddial params -----
#!ifdef WITH_SPEEDDIAL
modparam("speeddial", "db_url", DBURL)
modparam("speeddial", "use_domain", MULTIDOMAIN)
#!endif
# ----- domain params -----
#!ifdef WITH_MULTIDOMAIN
modparam("domain", "db_url", DBURL)
modparam("domain", "register_myself", 1)
#!endif
#!ifdef WITH_PRESENCE
# ----- presence params -----
modparam("presence", "db_url", DBURL)
# ----- presence_xml params -----
modparam("presence_xml", "db_url", DBURL)
modparam("presence_xml", "force_active", 1)
#!endif
#!ifdef WITH_NAT
# ----- nathelper params -----
modparam("nathelper", "natping_interval", 60)
modparam("nathelper", "ping_nated_only", 1)
modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
modparam("nathelper", "sipping_from", "sip:pinger@UAC_REG_ADDR")
modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
modparam("usrloc", "nat_bflag", FLB_NATB)
#!endif
#!ifdef WITH_TLS
# ----- tls params -----
modparam("tls", "config", "/usr/local/etc/kamailio/tls.cfg")
#!endif
#!ifdef WITH_ANTIFLOOD
# ----- pike params -----
modparam("pike", "sampling_time_unit", 2)
modparam("pike", "reqs_density_per_unit", 50)
modparam("pike", "remove_latency", 30)
# ----- htable params -----
modparam("htable", "htable", "ipban=>size=8;autoexpire=300;dmqreplicate=DMQ_REPLICATE_ENABLED;")
#!endif
#!ifdef WITH_XMLRPC
# ----- xmlrpc params -----
modparam("xmlrpc", "route", "XMLRPC");
modparam("xmlrpc", "url_match", "^/RPC")
#!endif
#!ifdef WITH_UAC
# ----- uac params -----
modparam("uac", "restore_mode", "none")
modparam("uac", "reg_db_url", DBURL)
modparam("uac", "reg_db_table", "uacreg")
modparam("uac", "reg_timer_interval", 60)
modparam("uac", "reg_retry_interval", 120)
modparam("uac", "reg_keep_callid", 1)
modparam("uac", "reg_gc_interval", 30)
modparam("uac", "credential", "username:domain:password")
modparam("uac", "auth_realm_avp", "$avp(arealm)")
modparam("uac", "auth_username_avp", "$avp(auser)")
modparam("uac", "auth_password_avp", "$avp(apass)")
modparam("uac", "reg_contact_addr", "UAC_REG_ADDR:SIP_PORT")
#!endif
#!ifdef WITH_DROUTE
# ----- drouting params -----
modparam("drouting", "db_url", DBURL)
modparam("drouting", "ruri_avp", "$avp(dr_ruri)")
modparam("drouting", "attrs_avp", "$avp(dr_attrs)")
modparam("drouting", "use_domain", 0)
modparam("drouting", "force_dns", 0)
modparam("drouting", "sort_order", 0)
#!endif
# ----- sqlops params -----
# Kamailio Connection
modparam("sqlops", "sqlcon", SQLCONN_KAM)
# ----- dialog params -----
modparam("dialog", "db_url", DBURL)
modparam("dialog", "db_mode", 0)
modparam("dialog", "enable_stats", 1)
modparam("dialog", "hash_size", 4096)
modparam("dialog", "detect_spirals", 1)
modparam("dialog", "track_cseq_updates", 1)
# ----- http_async_client params -----
modparam("http_async_client", "workers", 1)
modparam("http_async_client", "connection_timeout", 500)
modparam("http_async_client", "hash_size", 2048)
#!ifdef WITH_TLS
modparam("http_async_client", "tls_client_cert", "/etc/dsiprouter/certs/dsiprouter-cert.pem")
modparam("http_async_client", "tls_client_key", "/etc/dsiprouter/certs/dsiprouter-key.pem")
modparam("http_async_client", "tls_ca_path", "/etc/dsiprouter/certs/")
#!endif
request_route {
xlog("L_INFO", "test1: -2,147,483,000\n");
xlog("L_INFO", "test2: 0\n");
xlog("L_INFO", "test3: 2,147,483,000\n");
xlog("L_INFO", "test4: 4,294,967,000\n");
$var(test1)=-2147483000; $vn(test1)=-2147483000; $avp(test1)=-2147483000; $shv(test1)=-2147483000;
xlog("L_INFO", "(local) var(test1)=$var(test1) vn(test1)=$vn(test1) avp(test1)=$avp(test1) shv(test1)=$shv(test1)\n");
$var(test2)=0; $vn(test2)=0; $avp(test2)=0; $shv(test2)=0;
xlog("L_INFO", "(local) var(test2)=$var(test2) vn(test2)=$vn(test2) avp(test2)=$avp(test2) shv(test2)=$shv(test2)\n");
$var(test3)=2147483000; $vn(test3)=2147483000; $avp(test3)=2147483000; $shv(test3)=2147483000;
xlog("L_INFO", "(local) var(test3)=$var(test3) vn(test3)=$vn(test3) avp(test3)=$avp(test3) shv(test3)=$shv(test3)\n");
$var(test4)=4294967000; $vn(test4)=4294967000; $avp(test4)=4294967000; $shv(test4)=4294967000;
xlog("L_INFO", "(local) var(test4)=$var(test4) vn(test4)=$vn(test4) avp(test4)=$avp(test4) shv(test4)=$shv(test4)\n");
xlog("L_INFO", "(signed) test1: -2,147,483,000\n");
xlog("L_INFO", "(signed) test2: 0\n");
xlog("L_INFO", "(signed) test3: 2,147,483,000\n");
xlog("L_INFO", "(unsigned) test4: 0\n");
xlog("L_INFO", "(unsigned) test5: 2,147,483,000\n");
xlog("L_INFO", "(unsigned) test6: 4,294,967,000\n");
sql_pvquery("kam", "select vali,vali,vali,vali from test where id=1 limit 1;", "$var(test1),$vn(test1),$avp(test1),$shv(test1)");
xlog("L_INFO", "(db) var(test1)=$var(test1) vn(test1)=$vn(test1) avp(test1)=$avp(test1) shv(test1)=$shv(test1)\n");
sql_pvquery("kam", "select vali,vali,vali,vali from test where id=2 limit 1;", "$var(test2),$vn(test2),$avp(test2),$shv(test2)");
xlog("L_INFO", "(db) var(test2)=$var(test2) vn(test2)=$vn(test2) avp(test2)=$avp(test2) shv(test2)=$shv(test2)\n");
sql_pvquery("kam", "select vali,vali,vali,vali from test where id=3 limit 1;", "$var(test3),$vn(test3),$avp(test3),$shv(test3)");
xlog("L_INFO", "(db) var(test3)=$var(test3) vn(test3)=$vn(test3) avp(test3)=$avp(test3) shv(test3)=$shv(test3)\n");
sql_pvquery("kam", "select valu,valu,valu,valu from test where id=4 limit 1;", "$var(test4),$vn(test4),$avp(test4),$shv(test4)");
xlog("L_INFO", "(db) var(test4)=$var(test4) vn(test4)=$vn(test4) avp(test4)=$avp(test4) shv(test4)=$shv(test4)\n");
sql_pvquery("kam", "select valu,valu,valu,valu from test where id=5 limit 1;", "$var(test5),$vn(test5),$avp(test5),$shv(test5)");
xlog("L_INFO", "(db) var(test5)=$var(test5) vn(test5)=$vn(test5) avp(test5)=$avp(test5) shv(test5)=$shv(test5)\n");
sql_pvquery("kam", "select valu,valu,valu,valu from test where id=6 limit 1;", "$var(test6),$vn(test6),$avp(test6),$shv(test6)");
xlog("L_INFO", "(db) var(test6)=$var(test6) vn(test6)=$vn(test6) avp(test6)=$avp(test6) shv(test6)=$shv(test6)\n");
exit;
}
event_route[xhttp:request] {
exit;
}