├── .github
└── workflows
│ └── codeql-analysis.yml
├── .gitignore
├── Barebone_SIPServer
├── README.md
└── kamailio.cfg
├── Loadbalancer_SIP_proxy
├── README.md
├── dispatcher.list
└── kamailio.cfg
├── Lua_Nat_handle
├── README.md
├── kamailio_helpers
│ ├── reply.lua
│ ├── security.lua
│ └── traffic.lua
├── kamailio_nathandle.cfg
└── kamailionat.lua
├── Lua_Registrar_permission_auth
├── README.md
├── kamailio-basic-kemi-lua.lua
└── kamailio.cfg
├── Lua_RtpEngine_daisyChaining
├── README.md
├── dbtext
│ ├── dispatcher.list
│ ├── rtpengine
│ └── version
├── kamailio_lua.cfg
├── main.lua
├── main_2.lua
├── rtpengine.conf
├── rtpengine1.conf
├── rtpengine2.conf
└── sipp_uac_rtpecho.xml
├── Lua_Rtpengine_MOS
├── README.md
├── dbtext
│ ├── dispatcher.list
│ ├── rtpengine
│ └── version
├── kamailio_lua.cfg
├── main.lua
├── rtpengine.conf
├── sample_media_files
│ └── dtmf_rtcp_100_a.pcap
├── uac_rtcp.xml
├── uac_rtcp2.xml
└── uas_optonalACK.xml
├── Lua_dbsqlite
└── README.md
├── Lua_kamailio_short
├── README.md
├── kamailio.cfg
└── kamailio.lua
├── Lua_load_balancer
├── README.md
├── kamailio.cfg
└── loadbalancer.lua
├── Lua_sbc_with_auth
├── Kamailio_auth.cfg
├── README.md
├── kamailio_auth.lua
└── sipp_auth_uas.xml
├── Lua_sbc_with_auth_encryption
└── README.md
├── Lua_stateful_dialog_rtpengine
├── Kamailio_lua.cfg
├── README.md
├── dbtext
│ ├── dispatcher.list
│ ├── rtpengine
│ └── version
├── main.lua
└── rtpengine.conf
├── Private_Ids
└── README.md
├── README.md
├── REGISTER handle
├── README.md
└── kamailio_register_handle.cfg
├── RTPEngine_media_proxy
├── .DS_Store
├── README.md
├── dbtext
│ └── rtpengine
├── kamailio_rtpengine.cfg
├── rtpengine.conf
├── rtpengine_sample.conf
└── rtpengine_systemmd
│ ├── README.md
│ └── rtpengine.service
├── RTPProxy
├── README.md
├── kamailio-basic.cfg
└── kamailio.cfg
├── Relay_with_flags
├── README.md
├── kamailio_relay_with_auth.cfg
└── kamailio_relay_with_flagsset.cfg
├── TLSonly
├── README.md
├── openssl_sclient.md
├── tls.cfg
└── tls_kamailio.cfg
├── Topology_hiding
├── README.md
└── kamailio_topology_hiding.cfg
├── accounting
├── kamailio-advanced.cfg
└── kamailo_account.cfg
├── carrier
└── kamailio_carrierroute.cfg
├── early_media_handle
└── README.md
├── edge_proxy
├── README.md
├── kamailio.cfg
└── vars.xml
├── evapi_async_callcontrol
├── README.md
├── kamailio.cfg
├── kanapi.js
├── package-lock.json
└── package.json
├── forking
├── README.md
├── kamailio_parallel_forking.cfg
└── kamailio_serial_forking.cfg
├── jsonrpc_remoteprocesscalls
├── README.md
└── jsonrpc_kamailio.cfg
├── kamcmd_debug.md
├── kamctl_debug.md
├── mos_cdr_accmodule
├── .DS_Store
├── README.md
├── kamailio.cfg
├── kamailio_enhanced_reg_persistance.cfg
├── sipp_rtcp.xml
├── tls.cfg
├── uas_39890_errors.log
├── uas_41909_errors.log
└── uas_42961_errors.log
├── mos_rtpstats_rtpengine
├── README.md
├── al1.pcap
├── g711a.pcap
├── g711pcma.pcap
├── kamailio.cfg
├── rtp_example.raw
├── rtpengine_output.txt
└── sipp_rtcp.xml
├── mysql_user_stoarge
├── README.md
├── kamailio_mysql.cfg
└── kamctlrc
├── nat
├── README.md
└── kamailio_nat.cfg
├── psql_location_storage
├── README.md
├── kamailio_psql.cfg
└── postgress.md
├── psql_webrtc_rtpengine
├── README.md
├── psql_webrtc_rtpengine.cfg
├── psql_webrtc_rtpengine_2.cfg
├── rtpengine.conf
├── rtpengine.logs
├── rtpengine_webrtctowebrtc.logs
├── tls.cfg
├── tls.logs
└── tls_default.cfg
├── psql_webrtc_rtpproxy
├── README.md
└── psql_webrtc_ws_kamailio.cfg
├── record_routing
├── README.md
└── kamailio_record_route.cfg
├── redis_db
├── README.md
├── db_redis
│ ├── acc
│ └── location
└── kamailio_redis.cfg
├── register and userlocation
└── kamailio_register_userloc.cfg
├── rtpengine_bridge_on_fail
├── README.md
├── bridge_on_fail.cfg
└── jssipdemo
│ ├── cert.pem
│ ├── index.html
│ └── key.pem
├── sipcapture_siptrace_hep
├── README.md
├── sipcapture_capturenode.cfg
└── siptrace_tracenode.cfg
├── sipp
├── README.md
├── uas_407_200_reinvote_407.xml
├── uas_delay_200.xml
├── uas_receive_reINVITE_rejects503.xml
├── uas_receive_reINVITE_rejects_sends_BYE.xml
├── uas_send_BYE.xml
├── uas_send_CANCEL.xml
├── uas_send_UPDATE.xml
├── uas_send_reINVITE.xml
├── uas_send_reINVITE_changecodecs_send_BYE.xml
├── uas_send_reINVITE_receive_BYE.xml
└── uas_send_reINVITE_send_BYE.xml
├── sipsak_debug.md
├── siptrace_homer_heplifyserver
├── .DS_Store
├── DOCKER.md
├── HEPlify_server.md
├── README.md
├── heplify-server.toml
├── homer-app-ui.md
├── mariadb.md
├── siptrace_capturenode_kamailio.cfg
└── siptrace_with_rtpengine_kamailio.cfg
├── stateful_dialog_handle
└── README.md
├── stateful_transaction_handle
├── README.md
└── kamailio_statefull_transaction.cfg
├── webrtc_to_sip_ipv4_ipv6_with_rtpengine
├── README.md
├── tls.cfg
└── webrtc_to_sip_kamailio.cfg
├── webrtc_to_sip_with_rtpengine
├── README.md
├── tls.cfg
├── webrtc_to_webrtc.cfg
└── webtc_to_sip2.cfg
├── webrtc_to_webrtc_RTPengine
├── README.md
└── webrtc_ws_rtpengine_kamailio.cfg
└── webrtc_to_webrtc_ws
├── README.md
├── kamailio_wss_registrar.cfg
└── websocket_tls_webrtc_kamailio.cfg
/.github/workflows/codeql-analysis.yml:
--------------------------------------------------------------------------------
1 | # For most projects, this workflow file will not need changing; you simply need
2 | # to commit it to your repository.
3 | #
4 | # You may wish to alter this file to override the set of languages analyzed,
5 | # or to provide custom queries or build logic.
6 | #
7 | # ******** NOTE ********
8 | # We have attempted to detect the languages in your repository. Please check
9 | # the `language` matrix defined below to confirm you have the correct set of
10 | # supported CodeQL languages.
11 | #
12 | name: "CodeQL"
13 |
14 | on:
15 | push:
16 | branches: [ master ]
17 | pull_request:
18 | # The branches below must be a subset of the branches above
19 | branches: [ master ]
20 | schedule:
21 | - cron: '28 19 * * 2'
22 |
23 | jobs:
24 | analyze:
25 | name: Analyze
26 | runs-on: ubuntu-latest
27 | permissions:
28 | actions: read
29 | contents: read
30 | security-events: write
31 |
32 | strategy:
33 | fail-fast: false
34 | matrix:
35 | language: [ 'javascript' ]
36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37 | # Learn more about CodeQL language support at https://git.io/codeql-language-support
38 |
39 | steps:
40 | - name: Checkout repository
41 | uses: actions/checkout@v2
42 |
43 | # Initializes the CodeQL tools for scanning.
44 | - name: Initialize CodeQL
45 | uses: github/codeql-action/init@v1
46 | with:
47 | languages: ${{ matrix.language }}
48 | # If you wish to specify custom queries, you can do so here or in a config file.
49 | # By default, queries listed here will override any specified in a config file.
50 | # Prefix the list here with "+" to use these queries and those in the config file.
51 | # queries: ./path/to/local/query, your-org/your-repo/queries@main
52 |
53 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54 | # If this step fails, then you should remove it and run the build manually (see below)
55 | - name: Autobuild
56 | uses: github/codeql-action/autobuild@v1
57 |
58 | # ℹ️ Command-line programs to run using the OS shell.
59 | # 📚 https://git.io/JvXDl
60 |
61 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62 | # and modify them (or add more) to build your code if your project
63 | # uses a compiled language
64 |
65 | #- run: |
66 | # make bootstrap
67 | # make release
68 |
69 | - name: Perform CodeQL Analysis
70 | uses: github/codeql-action/analyze@v1
71 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .DS_Store
3 |
--------------------------------------------------------------------------------
/Barebone_SIPServer/README.md:
--------------------------------------------------------------------------------
1 | # BareBone SIP Server
--------------------------------------------------------------------------------
/Loadbalancer_SIP_proxy/dispatcher.list:
--------------------------------------------------------------------------------
1 | dispatcher.list
2 |
3 | ...
4 | #
5 | # dispatcher destination sets (groups)
6 | #
7 |
8 | # line format
9 | # setid(int) destination(sip uri) flags(int,opt) priority(int,opt) attributes(str,opt)
10 |
11 | # proxies
12 | 2 sip:127.0.0.1:5080;transport=tcp 0 10 class=4;prefix=448;strip=2
13 | 2 sip:127.0.0.1:5082;px=vx 0 5 duid=abc;socket=udp:x.x.x.x:5060;pipe=p10
14 |
15 | # gateways
16 | 1 sip:127.0.0.1:7070 0 0 duid=xyz;maxload=20
17 | 1 sip:127.0.0.1:7072 0 5
18 | 1 sip:127.0.0.1:7074
--------------------------------------------------------------------------------
/Lua_Nat_handle/README.md:
--------------------------------------------------------------------------------
1 | # Kamailio Lua Call routing Script to Handle NAT
2 |
3 | Run with kamailio cfg
4 | ```bash
5 | kamailio -f kamailio_nathandle.cfg -Ee
6 | ```
7 |
8 | To see existing running instances of kamailio
9 | ```bash
10 | ps -ef | grep kamailio
11 | ```
12 |
13 | Killing existing instance of kamailio
14 | ```bash
15 | pkill kamailio
16 | ```
17 |
18 | To read more about Lua scripts for call routing on kamailip sip server
19 | [Lua script for kamailio record Routing](https://telecom.altanai.com/2018/05/08/lua-scripts-for-kamailio-routing/)
20 |
21 | Adding route params for nating
22 | ```
23 | if KSR.rr.check_route_param("nat=yes") > 0 then
24 | KSR.setbflag(FLB_NATB);
25 | end
26 | ```
27 |
28 | ## KSR function used :
29 |
30 | KSR.x.exit() to trigger the stop of executing the script
31 | KSR.drop() is only marking the SIP message for drop, but doesn't stop the execution of the script
32 |
33 |
--------------------------------------------------------------------------------
/Lua_Nat_handle/kamailio_helpers/reply.lua:
--------------------------------------------------------------------------------
1 | core = require "kamailio.core"
2 |
3 | local reply = {}
4 |
5 | function reply.stateless(cause, reason)
6 | if cause == nil then
7 | KSR.err("Can't send stateless response w/o cause!")
8 | return false
9 | end
10 | reason = reason or "Unknown"
11 | KSR.sl.sl_send_reply(cause, reason)
12 | end
13 |
14 | function reply.stateful(cause, reason)
15 | if cause == nil then
16 | KSR.err("Can't send stateless response w/o cause!")
17 | return false
18 | end
19 | reason = reason or "Unknown"
20 | KSR.tm.t_reply(cause, reason)
21 | end
22 |
23 | function reply.with_stateless_error_and_exit()
24 | KSR.sl.sl_reply_error()
25 | core.exit()
26 | end
27 |
28 | function reply.with_stateless_200_and_exit()
29 | reply.stateless(200, "OK")
30 | core.exit()
31 | end
32 |
33 | function reply.with_stateless_403_and_exit()
34 | reply.stateless(403, "Forbidden")
35 | core.exit()
36 | end
37 |
38 | function reply.with_stateless_404_and_exit()
39 | reply.stateless(404, "Not Here")
40 | core.exit()
41 | end
42 |
43 | function reply.with_stateless_405_and_exit()
44 | reply.stateless(405, "Method Not Allowed")
45 | core.exit()
46 | end
47 |
48 | function reply.with_stateless_484_and_exit()
49 | reply.stateless(484, "Address Incomplete")
50 | core.exit()
51 | end
52 |
53 | function reply.with_stateful_404_and_exit()
54 | reply.stateful(404, "Not Found")
55 | core.exit()
56 | end
57 |
58 |
59 |
60 | return reply
--------------------------------------------------------------------------------
/Lua_Nat_handle/kamailio_helpers/security.lua:
--------------------------------------------------------------------------------
1 | -- Security related functions
2 |
3 | local security = {}
4 |
5 | -- Getter/Setter, don't test
6 |
7 | function security.is_allowed_by_permissions()
8 | return KSR.permissions.allow_source_address(1)>0
9 | end
10 |
11 | function security.is_ip_banned()
12 | return not KSR.pv.is_null("$sht(ipban=>$si)")
13 | end
14 |
15 | function security.pike_above_limit()
16 | return KSR.pike.pike_check_req() < 0
17 | end
18 |
19 | function security.ban_ip()
20 | KSR.pv.seti("$sht(ipban=>$si)", 1)
21 | end
22 |
23 | function security.is_not_authenticated()
24 | return KSR.auth_db.auth_check(KSR.pv.get("$fd"), "subscriber", 1) < 0
25 | end
26 |
27 | function security.send_auth_challenge()
28 | KSR.auth.auth_challenge(KSR.pv.get("$fd"), 0)
29 | end
30 |
31 | function security.remove_credentials()
32 | KSR.auth.consume_credentials()
33 | end
34 |
35 | -- Testworthy methods here
36 |
37 | return security
--------------------------------------------------------------------------------
/Lua_Nat_handle/kamailio_helpers/traffic.lua:
--------------------------------------------------------------------------------
1 | --- Traffic related functions
2 | local traffic = {
3 | }
4 |
5 | -- Getter/Setter, don't test
6 |
7 | function traffic.is_request_from_local()
8 | return KSR.is_myself(KSR.pv.get("$si"))
9 | end
10 |
11 | -- Testworthy methods here
12 |
13 | return traffic
14 |
--------------------------------------------------------------------------------
/Lua_Nat_handle/kamailio_nathandle.cfg:
--------------------------------------------------------------------------------
1 | #!KAMAILIO
2 |
3 |
4 | ####### Defined Values #########
5 |
6 | #!substdef "!MY_IP_ADDR!127.0.0.1!g"
7 | #!substdef "!MY_EXTERNAL_IP!172.16.19.237!g"
8 | #!substdef "!MY_UDP_PORT!5060!g"
9 | #!substdef "!MY_TCP_PORT!8080!g"
10 | #!substdef "!MY_UDP_ADDR!udp:MY_IP_ADDR:MY_UDP_PORT!g"
11 | #!substdef "!MY_TCP_ADDR!tcp:MY_IP_ADDR:MY_TCP_PORT!g"
12 |
13 | # Routing File
14 | #!define ROUTE_LUA "/Users/altanaibisht/kamilioexamples/Lua_load_balancer/kamailionat.lua"
15 |
16 | ####### Global Parameters #########
17 |
18 | ## LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR
19 | #!ifdef WITH_DEBUG
20 | debug = 4
21 | log_stderror = yes
22 | #!else
23 | debug = 2
24 | log_stderror = no
25 | #!endif
26 | memdbg = 5
27 | memlog = 5
28 |
29 | # log setting
30 | log_facility = LOG_LOCAL0
31 |
32 | children = 4
33 | async_workers=8
34 |
35 | #listen = MY_UDP_ADDR advertise MY_EXTERNAL_IP:MY_UDP_PORT
36 | #listening for the xmlrpc
37 | listen = MY_UDP_ADDR
38 | listen = MY_TCP_ADDR
39 |
40 | server_header="Server: SampleServer"
41 | sip_warning=0
42 |
43 | ####### Modules Section ########
44 | #!ifdef WITH_SRCPATH
45 | mpath = "modules/"
46 | #!else
47 | mpath = "/usr/local/lib64/kamailio/modules/"
48 | #!endif
49 | # ------------------ module loading ----------------------------------
50 | loadmodule "tm.so"
51 | loadmodule "rr.so"
52 | loadmodule "pv.so"
53 | loadmodule "tmx.so"
54 | loadmodule "sl.so"
55 | loadmodule "maxfwd.so"
56 | loadmodule "nathelper.so"
57 | loadmodule "textops.so"
58 | loadmodule "siputils.so"
59 | loadmodule "xlog.so"
60 | loadmodule "path.so"
61 | loadmodule "jsonrpcs.so"
62 | loadmodule "app_lua.so"
63 | loadmodule "json.so"
64 | loadmodule "cfg_rpc.so"
65 | loadmodule "xmlrpc.so"
66 | # loadmodule "ctl.so"
67 | loadmodule "dialog.so"
68 |
69 | # ----------------- setting module-specific parameters ---------------
70 |
71 | # ----- rr params -----
72 | # set next param to 1 to add value to ;lr param (helps with some UAs)
73 | modparam("rr", "enable_full_lr", 0)
74 | # do not append from tag to the RR (no need for this script)
75 | modparam("rr", "append_fromtag", 1)
76 |
77 | # ----- nathelper params ----
78 | modparam("nathelper", "received_avp", "$avp(s:rcv)")
79 |
80 | # ----- ctl ------
81 | # modparam("ctl", "binrpc", "tcp:MY_IP_ADDR:2046")
82 |
83 | # ----- app_lua params ----
84 | modparam("app_lua", "reload", 1)
85 | modparam("app_lua", "load", ROUTE_LUA)
86 |
87 | # ---- dialog params ----
88 | modparam("dialog", "enable_stats", 1)
89 | modparam("dialog", "dlg_flag", 4)
90 | modparam("dialog", "dlg_match_mode", 1)
91 | modparam("dialog", "event_callback", "ksr_dialog_event")
92 |
93 | # ----- tm params -----
94 | # auto-discard branches from previous serial forking leg
95 | modparam("tm", "failure_reply_mode", 3)
96 | modparam("tm", "fr_timer", 10000)
97 | modparam("tm", "fr_inv_timer", 120000)
98 | modparam("tm", "restart_fr_on_each_reply", 1)
99 | modparam("tm", "pass_provisional_replies", 1)
100 | modparam("tm", "contacts_avp", "tm_contacts");
101 | modparam("tm", "contact_flows_avp", "tm_contact_flows");
102 |
103 | cfgengine "lua"
104 |
--------------------------------------------------------------------------------
/Lua_Nat_handle/kamailionat.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- Created by IntelliJ IDEA.
3 | -- User: altanai ( @altanai )
4 | -- Date: 2019-11-14
5 | -- KamailioExmaples
6 | --
7 |
8 | kamailio = require "kamailio"
9 |
10 | -- global variables corresponding to defined values (e.g., flags) in kamailio.cfg
11 | FLT_ACC = 1
12 | FLT_ACCMISSED = 2
13 | FLT_ACCFAILED = 3
14 | FLT_NATS = 5
15 |
16 | FLB_NATB = 6
17 | FLB_NATSIPPING = 7
18 |
19 | -- SIP request routing
20 | -- equivalent of request_route{}
21 | function ksr_request_route()
22 | kamailio.process_request()
23 | return 1
24 | end
25 |
26 | -- wrapper around tm relay function
27 | function ksr_route_relay()
28 | -- enable additional event routes for forwarded requests
29 | -- - serial forking, RTP relaying handling, a.s.o.
30 | if string.find("INVITE,BYE,SUBSCRIBE,UPDATE", KSR.pv.get("$rm")) then
31 | if KSR.tm.t_is_set("branch_route") < 0 then
32 | KSR.tm.t_on_branch("ksr_branch_manage");
33 | end
34 | end
35 | if string.find("INVITE,SUBSCRIBE,UPDATE", KSR.pv.get("$rm")) then
36 | if KSR.tm.t_is_set("onreply_route") < 0 then
37 | KSR.tm.t_on_reply("ksr_onreply_manage");
38 | end
39 | end
40 |
41 | if KSR.pv.get("$rm") == "INVITE" then
42 | if KSR.tm.t_is_set("failure_route") < 0 then
43 | KSR.tm.t_on_failure("ksr_failure_manage");
44 | end
45 | end
46 |
47 | if KSR.tm.t_relay() < 0 then
48 | KSR.sl.sl_reply_error();
49 | end
50 | KSR.x.exit();
51 | end
52 |
53 | -- RTPProxy control
54 | function ksr_route_natmanage()
55 | if KSR.siputils.is_request() > 0 then
56 | if KSR.siputils.has_totag() > 0 then
57 | if KSR.rr.check_route_param("nat=yes") > 0 then
58 | KSR.setbflag(FLB_NATB);
59 | end
60 | end
61 | end
62 | if (not (KSR.isflagset(FLT_NATS) or KSR.isbflagset(FLB_NATB))) then
63 | return 1;
64 | end
65 |
66 | KSR.rtpproxy.rtpproxy_manage("co");
67 |
68 | if KSR.siputils.is_request() > 0 then
69 | if not KSR.siputils.has_totag() then
70 | if KSR.tmx.t_is_branch_route() > 0 then
71 | KSR.rr.add_rr_param(";nat=yes");
72 | end
73 | end
74 | end
75 | if KSR.siputils.is_reply() > 0 then
76 | if KSR.isbflagset(FLB_NATB) then
77 | KSR.nathelper.set_contact_alias();
78 | end
79 | end
80 | return 1;
81 | end
82 |
83 | -- URI update for dialog requests
84 | function ksr_route_dlguri()
85 | if not KSR.isdsturiset() then
86 | KSR.nathelper.handle_ruri_alias();
87 | end
88 | return 1;
89 | end
90 |
91 | -- Manage outgoing branches
92 | -- equivalent of branch_route[...]{}
93 | function ksr_branch_manage()
94 | KSR.dbg("new branch [" .. KSR.pv.get("$T_branch_idx") .. "] to " .. KSR.pv.get("$ru") .. "\n");
95 | ksr_route_natmanage();
96 | return 1;
97 | end
98 |
99 | -- Manage incoming replies
100 | -- equivalent of onreply_route[...]{}
101 | function ksr_onreply_manage()
102 | KSR.dbg("incoming reply\n");
103 | local scode = KSR.pv.get("$rs");
104 | if scode > 100 and scode < 299 then
105 | ksr_route_natmanage();
106 | end
107 | return 1;
108 | end
109 |
110 | -- Manage failure routing cases
111 | -- equivalent of failure_route[...]{}
112 | function ksr_failure_manage()
113 | ksr_route_natmanage();
114 |
115 | if KSR.tm.t_is_canceled() > 0 then
116 | return 1;
117 | end
118 | return 1;
119 | end
120 |
121 | -- SIP response handling
122 | -- equivalent of reply_route{}
123 | function ksr_reply_route()
124 | KSR.info("===== response - from kamailio lua script\n");
125 | return 1;
126 | end
127 |
--------------------------------------------------------------------------------
/Lua_RtpEngine_daisyChaining/dbtext/dispatcher.list:
--------------------------------------------------------------------------------
1 | 1 sip:34.234.125.109 0 0 0
--------------------------------------------------------------------------------
/Lua_RtpEngine_daisyChaining/dbtext/rtpengine:
--------------------------------------------------------------------------------
1 | id(int,auto) setid(int) url(string) weight(int) disabled(int) stamp(int)
2 | 1:1:udp\:127.0.0.1\:2222:1:0:0
3 | 2:2:udp\:18.213.51.150\:2222:1:0:0
4 |
--------------------------------------------------------------------------------
/Lua_RtpEngine_daisyChaining/dbtext/version:
--------------------------------------------------------------------------------
1 | table_name(string) table_version(int)
2 | version:1
3 | rtpengine:1
4 | rtpengine,1
--------------------------------------------------------------------------------
/Lua_RtpEngine_daisyChaining/rtpengine.conf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/altanai/kamailioexamples/6bdde0a6a0a43edb4c7395ce3a615b23705ad270/Lua_RtpEngine_daisyChaining/rtpengine.conf
--------------------------------------------------------------------------------
/Lua_RtpEngine_daisyChaining/rtpengine1.conf:
--------------------------------------------------------------------------------
1 | [rtpengine]
2 |
3 | table = 0
4 | # no-fallback = false
5 | ### for userspace forwarding only:
6 | # table = -1
7 |
8 | ### a single interface:
9 | # interface = 123.234.345.456
10 | ### separate multiple interfaces with semicolons:
11 | # interface = internal/12.23.34.45;external/23.34.45.54
12 | ### for different advertised address:
13 | # interface = 12.23.34.45!23.34.45.56
14 |
15 |
16 |
17 | listen-ng = 127.0.0.1:2223
18 | # listen-tcp = 25060
19 | # listen-udp = 12222
20 |
21 | timeout = 60
22 | silent-timeout = 3600
23 | tos = 184
24 | #control-tos = 184
25 | # delete-delay = 30
26 | # final-timeout = 10800
27 |
28 | # foreground = false
29 | # pidfile = /run/ngcp-rtpengine-daemon.pid
30 | # num-threads = 16
31 |
32 | port-min = 30000
33 | port-max = 40000
34 | # max-sessions = 5000
35 |
36 | # recording-dir = /var/spool/rtpengine
37 | # recording-method = proc
38 | # recording-format = raw
39 |
40 | # redis = 127.0.0.1:6379/5
41 | # redis-write = password@12.23.34.45:6379/42
42 | # redis-num-threads = 8
43 | # no-redis-required = false
44 | # redis-expires = 86400
45 | # redis-allowed-errors = -1
46 | # redis-disable-time = 10
47 | # redis-cmd-timeout = 0
48 | # redis-connect-timeout = 1000
49 |
50 | # b2b-url = http://127.0.0.1:8090/
51 | # xmlrpc-format = 0
52 |
53 | # log-level = 6
54 | # log-stderr = false
55 | # log-facility = daemon
56 | # log-facility-cdr = local0
57 | # log-facility-rtcp = local1
58 |
59 | # graphite = 127.0.0.1:9006
60 | # graphite-interval = 60
61 | # graphite-prefix = foobar.
62 |
63 | # homer = 123.234.345.456:65432
64 | # homer-protocol = udp
65 | # homer-id = 2001
66 |
67 | # sip-source = false
68 | # dtls-passive = false
69 |
70 | [rtpengine-testing]
71 | table = -1
72 | interface = 10.15.20.121
73 | listen-ng = 2223
74 | foreground = true
75 | log-stderr = true
76 | log-level = 7
--------------------------------------------------------------------------------
/Lua_RtpEngine_daisyChaining/rtpengine2.conf:
--------------------------------------------------------------------------------
1 | [rtpengine]
2 |
3 | table = 0
4 | # no-fallback = false
5 | ### for userspace forwarding only:
6 | # table = -1
7 |
8 | ### a single interface:
9 | # interface = 123.234.345.456
10 | ### separate multiple interfaces with semicolons:
11 | # interface = internal/12.23.34.45;external/23.34.45.54
12 | ### for different advertised address:
13 | # interface = 12.23.34.45!23.34.45.56
14 |
15 |
16 |
17 | listen-ng = 127.0.0.1:2223
18 | # listen-tcp = 25060
19 | # listen-udp = 12222
20 |
21 | timeout = 60
22 | silent-timeout = 3600
23 | tos = 184
24 | #control-tos = 184
25 | # delete-delay = 30
26 | # final-timeout = 10800
27 |
28 | # foreground = false
29 | # pidfile = /run/ngcp-rtpengine-daemon.pid
30 | # num-threads = 16
31 |
32 | port-min = 30000
33 | port-max = 40000
34 | # max-sessions = 5000
35 |
36 | # recording-dir = /var/spool/rtpengine
37 | # recording-method = proc
38 | # recording-format = raw
39 |
40 | # redis = 127.0.0.1:6379/5
41 | # redis-write = password@12.23.34.45:6379/42
42 | # redis-num-threads = 8
43 | # no-redis-required = false
44 | # redis-expires = 86400
45 | # redis-allowed-errors = -1
46 | # redis-disable-time = 10
47 | # redis-cmd-timeout = 0
48 | # redis-connect-timeout = 1000
49 |
50 | # b2b-url = http://127.0.0.1:8090/
51 | # xmlrpc-format = 0
52 |
53 | # log-level = 6
54 | # log-stderr = false
55 | # log-facility = daemon
56 | # log-facility-cdr = local0
57 | # log-facility-rtcp = local1
58 |
59 | # graphite = 127.0.0.1:9006
60 | # graphite-interval = 60
61 | # graphite-prefix = foobar.
62 |
63 | # homer = 123.234.345.456:65432
64 | # homer-protocol = udp
65 | # homer-id = 2001
66 |
67 | # sip-source = false
68 | # dtls-passive = false
69 |
70 | [rtpengine-testing]
71 | table = -1
72 | interface = 10.15.20.121
73 | listen-ng = 2223
74 | foreground = true
75 | log-stderr = true
76 | log-level = 7
--------------------------------------------------------------------------------
/Lua_RtpEngine_daisyChaining/sipp_uac_rtpecho.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | ;tag=[call_number]
13 | To: sut
14 | Call-ID: [call_id]
15 | CSeq: 1 INVITE
16 | Contact: sip:sipp@[local_ip]:[local_port]
17 | Max-Forwards: 70
18 | Subject: Performance Test
19 | Content-Type: application/sdp
20 | Content-Length: [len]
21 |
22 | v=0
23 | o=zt 53655765 2353687637 IN IP[local_ip_type] [local_ip]
24 | s=-
25 | c=IN IP[media_ip_type] [media_ip]
26 | t=0 0
27 | m=audio [media_port] RTP/AVPF 0
28 | a=rtpmap:0 PCMU/8000
29 |
30 | ]]>
31 |
32 |
33 |
34 |
35 |
39 |
40 |
41 |
43 |
44 |
45 |
49 |
50 | ;tag=[call_number]
55 | To: sut [peer_tag_param]
56 | Call-ID: [call_id]
57 | CSeq: 1 ACK
58 | Contact: sip:sipp@[local_ip]:[local_port]
59 | Max-Forwards: 70
60 | Subject: Performance Test
61 | Content-Length: 0
62 |
63 | ]]>
64 |
65 |
69 |
70 |
73 |
74 | ;tag=[call_number]
79 | To: sut [peer_tag_param]
80 | Call-ID: [call_id] CSeq: 2 BYE
81 | Contact: sip:sipp@[local_ip]:[local_port]
82 | Max-Forwards: 70
83 | Subject: Performance Test
84 | Content-Length: 0
85 |
86 | ]]>
87 |
88 |
89 |
92 |
93 |
96 |
97 |
--------------------------------------------------------------------------------
/Lua_Rtpengine_MOS/dbtext/dispatcher.list:
--------------------------------------------------------------------------------
1 | 1 sip:192.168.1.109 0 0 0
--------------------------------------------------------------------------------
/Lua_Rtpengine_MOS/dbtext/rtpengine:
--------------------------------------------------------------------------------
1 | id(int,auto) setid(int) url(string) weight(int) disabled(int) stamp(int)
2 | 1:1:udp\:192.168.1.109\:2222:1:0:0
3 | 2:1:udp\:192.168.1.109\:2222:1:0:0
--------------------------------------------------------------------------------
/Lua_Rtpengine_MOS/dbtext/version:
--------------------------------------------------------------------------------
1 | table_name(string) table_version(int)
2 | version:1
3 | rtpengine:1
4 | rtpengine,1
--------------------------------------------------------------------------------
/Lua_Rtpengine_MOS/rtpengine.conf:
--------------------------------------------------------------------------------
1 | [rtpengine]
2 | no-fallback=true
3 | log-format=parsable
4 | port-min=10000
5 | port-max=30000
6 | log-level=6
7 | log-facility=local0
8 | log-facility-cdr=local1
9 | log-facility-rtcp=local2
10 | max-sessions=3000
11 | timeout=60
12 | silent-timeout=3600
13 | offer-timeout=300
14 | delete-delay=0
15 | recording-dir=/var/spool/rtpengine/
16 | recording-method=pcap
17 | recording-format=eth
18 | no-redis-required=true
19 | redis=127.0.0.1:6379/0
20 | redis-num-threads=8
21 | redis-expires=86400
22 | redis-allowed-errors=-1
23 | redis-disable-time=10
24 | redis-cmd-timeout=0
25 | redis-connect-timeout=1000
26 | jitter-buffer=10
27 | jb-clock-drift=false
28 | xmlrpc-format=2
29 | b2b-url=http://%%:8080/XMLRPC
30 | interface=internal/;external/!
31 | listen-ng=:2222
32 | listen-cli=:2224
33 | num-threads=4
34 |
--------------------------------------------------------------------------------
/Lua_Rtpengine_MOS/sample_media_files/dtmf_rtcp_100_a.pcap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/altanai/kamailioexamples/6bdde0a6a0a43edb4c7395ce3a615b23705ad270/Lua_Rtpengine_MOS/sample_media_files/dtmf_rtcp_100_a.pcap
--------------------------------------------------------------------------------
/Lua_Rtpengine_MOS/uac_rtcp.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | ;tag=[call_number]
12 | To: sut
13 | Call-ID: [call_id]
14 | CSeq: 1 INVITE
15 | Contact: sip:sipp@[local_ip]:[local_port]
16 | Max-Forwards: 70
17 | Subject: Performance Test
18 | User-Agent: mos_calculator
19 | Content-Type: application/sdp
20 | Content-Length: [len]
21 |
22 | v=0
23 | o=zt 53655765 2353687637 IN IP[local_ip_type] [local_ip]
24 | s=-
25 | c=IN IP[media_ip_type] [media_ip]
26 | a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics
27 | t=0 0
28 | m=audio [media_port] RTP/AVPF 0
29 | a=rtpmap:0 PCMU/8000
30 |
31 | ]]>
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | ;tag=[call_number]
55 | To: sut [peer_tag_param]
56 | Call-ID: [call_id]
57 | CSeq: 1 ACK
58 | Contact: sip:sipp@[local_ip]:[local_port]
59 | Max-Forwards: 70
60 | User-Agent: mos_calculator
61 | Content-Length: 0
62 |
63 | ]]>
64 |
65 |
66 |
67 |
68 |
69 |
70 | ;tag=[call_number]
75 | To: sut [peer_tag_param]
76 | Call-ID: [call_id]
77 | CSeq: 2 BYE
78 | Contact: sip:sipp@[local_ip]:[local_port]
79 | Max-Forwards: 70
80 | User-Agent: mos_calculator
81 | Content-Length: 0
82 |
83 | ]]>
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/Lua_Rtpengine_MOS/uac_rtcp2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | ;tag=[call_number]
13 | To: sut
14 | Call-ID: [call_id]
15 | CSeq: 1 INVITE
16 | Contact: sip:sipp@[local_ip]:[local_port]
17 | Max-Forwards: 70
18 | Subject: Performance Test
19 | Content-Type: application/sdp
20 | Content-Length: [len]
21 |
22 | v=0
23 | o=zt 53655765 2353687637 IN IP[local_ip_type] [local_ip]
24 | s=-
25 | c=IN IP[media_ip_type] [media_ip]
26 | t=0 0
27 | m=audio [media_port] RTP/AVPF 0
28 | a=rtpmap:0 PCMU/8000
29 |
30 | ]]>
31 |
32 |
33 |
34 |
35 |
39 |
40 |
41 |
43 |
44 |
45 |
46 |
50 |
51 | ;tag=[call_number]
56 | To: sut [peer_tag_param]
57 | Call-ID: [call_id]
58 | CSeq: 1 ACK
59 | Contact: sip:sipp@[local_ip]:[local_port]
60 | Max-Forwards: 70
61 | Subject: Performance Test
62 | Content-Length: 0
63 |
64 | ]]>
65 |
66 |
70 |
71 |
74 |
75 | ;tag=[call_number]
80 | To: sut [peer_tag_param]
81 | Call-ID: [call_id] CSeq: 2 BYE
82 | Contact: sip:sipp@[local_ip]:[local_port]
83 | Max-Forwards: 70
84 | Subject: Performance Test
85 | Content-Length: 0
86 |
87 | ]]>
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | ;tag=[call_number]
101 | To: sut [peer_tag_param]
102 | Call-ID: [call_id]
103 | CSeq: 2 BYE
104 | Contact: sip:sipp@[local_ip]:[local_port]
105 | Max-Forwards: 70
106 | User-Agent: mos_calculator
107 | Content-Length: 0
108 |
109 | ]]>
110 |
111 |
112 |
115 |
116 |
119 |
120 |
--------------------------------------------------------------------------------
/Lua_Rtpengine_MOS/uas_optonalACK.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
18 | Content-Length: 0
19 | ]]>
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
41 | Content-Length: 0
42 | ]]>
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Lua_dbsqlite/README.md:
--------------------------------------------------------------------------------
1 | # DB SQLite Database for Kamailio
2 |
3 | By default, an SQLite session uses the in-memory database, therefore, all changes will be gone when the session ends.
4 |
5 |
6 | ## Installation
7 | ```bash
8 | cd kamailio_sourcecode/src/modules/db_sqlite
9 | make && make install
10 | ```
11 |
12 | and also install SQLlite3 server
13 | ```bash
14 | apt install sqlite3
15 | ```
16 |
17 | To open the cmd console write sqlite3
18 | ```bash
19 | # sqlite3
20 | SQLite version 3.22.0 2018-01-22 18:45:57
21 | Enter ".help" for usage hints.
22 | Connected to a transient in-memory database.
23 | Use ".open FILENAME" to reopen on a persistent database.
24 | sqlite> .database
25 | main:
26 | ```
27 |
28 | ## Using sqlite
29 |
30 | To open a database file, you use the .open FILENAME command.
31 |
32 |
33 | ### using kamdbctl
34 |
35 | kamdbctl is a script to maintain the database needed by some Kamalio modules.
36 |
37 | without specifying a database engine
38 | ```bash
39 | kamdbctl
40 | ERROR: database engine not specified, please setup one in the config script
41 | ```
42 |
43 | Update kamctlrc withe engine such as BENGINE=SQLITE
44 |
45 | find kamctlrc
46 | ```bash
47 | sudo find / -name kamctlrc
48 | ```
49 |
50 | My kamctlrc is at location /usr/local/etc/kamailio/kamctlrc
51 | ```bash
52 | ## the SIP domain
53 | # SIP_DOMAIN=kamailio.org
54 |
55 | ## chrooted directory
56 | # CHROOT_DIR="/path/to/chrooted/directory"
57 |
58 | ## database type: MYSQL, PGSQL, ORACLE, DB_BERKELEY, DBTEXT, or SQLITE
59 | ## by default none is loaded
60 | ##
61 | ## If you want to setup a database with kamdbctl, you must at least specify
62 | ## this parameter.
63 | # DBENGINE=MYSQL
64 | DBENGINE=SQLITE
65 | ## database host
66 | # DBHOST=localhost
67 |
68 | ## database port
69 | # DBPORT=3306
70 |
71 | ## database name (for ORACLE this is TNS name)
72 | # DBNAME=kamailio
73 |
74 | ## database path used by dbtext, db_berkeley or sqlite
75 | # DB_PATH="/usr/local/etc/kamailio/dbtext"
76 |
77 | ## database read/write user
78 | # DBRWUSER="kamailio"
79 |
80 | ## password for database read/write user
81 | # DBRWPW="kamailiorw"
82 |
83 | ## database read only user
84 | # DBROUSER="kamailioro"
85 |
86 | ```
87 |
88 | create tables
89 | ```bash
90 | > kamdbctl create kamailio.db
91 | INFO: creating database kamailio.db ...
92 | INFO: Core Kamailio tables succesfully created.
93 | Install presence related tables? (y/n): y
94 | INFO: creating presence tables into kamailio.db ...
95 | INFO: Presence tables succesfully created.
96 | Install tables for imc cpl siptrace domainpolicy carrierroute
97 | drouting userblacklist htable purple uac pipelimit mtree sca mohqueue
98 | rtpproxy rtpengine? (y/n): y
99 | INFO: creating extra tables into kamailio.db ...
100 | INFO: Extra tables succesfully created.
101 |
102 | ```
103 | Then give the location of create DB to kamailio config such as
104 | ```bash
105 | /usr/local/sbin/kamailio.db
106 | ```
107 |
108 | ## Debugging
109 |
110 | **Issue1** db not opened
111 | ```bash
112 | 0(17314) ERROR: db_sqlite [dbase.c:79]: db_sqlite_new_connection(): failed to open sqlite database '/etc/kamailio/kamailio.db'
113 | ```
114 | **Solution** ensure that sqlite is installed
115 | ```bash
116 | apt install sqlite3
117 | ```
118 |
119 | **Issue 2** could not load the script kamdbctl.sqlite
120 | ```bash
121 | -e \E[37;31mERROR: could not load the script in /usr/local/lib64/kamailio//kamctl/kamdbctl.sqlite for database engine SQLITE
122 | -e \E[37;31mERROR: database engine not loaded - tried 'SQLITE'
123 | ```
--------------------------------------------------------------------------------
/Lua_kamailio_short/kamailio.cfg:
--------------------------------------------------------------------------------
1 | #!KAMAILIO
2 |
3 |
4 | debug=3
5 | log_stderror=yes
6 | fork=yes
7 | children=2
8 |
9 | memdbg=5
10 | memlog=5
11 |
12 | auto_aliases=no
13 |
14 | listen=udp::5060
15 |
16 | mpath = "/usr/local/lib64/kamailio/modules/"
17 |
18 | loadmodule "kex.so"
19 | loadmodule "tm.so"
20 | loadmodule "tmx.so"
21 | loadmodule "sl.so"
22 | loadmodule "pv.so"
23 | loadmodule "maxfwd.so"
24 | loadmodule "textops.so"
25 | loadmodule "xlog.so"
26 | loadmodule "ctl.so"
27 | loadmodule "debugger.so"
28 | loadmodule "app_lua.so"
29 |
30 | # ----------------- setting module-specific parameters ---------------
31 |
32 | # ----- tm params -----
33 | # auto-discard branches from previous serial forking leg
34 | modparam("tm", "failure_reply_mode", 3)
35 | # default retransmission timeout: 30sec
36 | modparam("tm", "fr_timer", 30000)
37 | # default invite retransmission timeout after 1xx: 120sec
38 | modparam("tm", "fr_inv_timer", 120000)
39 |
40 | # ----- debugger params -----
41 | modparam("debugger", "cfgtrace", 1)
42 |
43 | ####### Routing Logic ########
44 |
45 | modparam("app_lua", "load", "/etc/kamailio/kamailio.lua")
46 | modparam("app_lua", "register", "maxfwd")
47 | modparam("app_lua", "register", "sl")
48 |
49 | cfgengine "lua"
--------------------------------------------------------------------------------
/Lua_kamailio_short/kamailio.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- Created by IntelliJ IDEA.
3 | -- User: altanai ( @altanai )
4 | -- Date: 2019-11-14
5 | -- KamailioExmaples
6 | --
7 | -- Kamailio - equivalent of routing blocks in Lua
8 | -- KSR - the new dynamic object exporting Kamailio functions
9 | -- sr - the old static object exporting Kamailio functions
10 | --
11 | -- SIP request routing
12 | -- equivalent of request_route{}
13 | function ksr_request_route()
14 | KSR.info("===== request - from kamailio lua script\n");
15 |
16 | if sr.maxfwd.process_maxfwd(10) < 0 then
17 | KSR.sl.send_reply(483, "Too Many Hops");
18 | return;
19 | end
20 |
21 | -- KSR.sl.sreply(200, "OK Lua");
22 | sr.pv.sets("$du", "sip:127.0.0.1:5080")
23 |
24 | KSR.info("set branch , replay , failure blocks \n");
25 | KSR.tm.t_on_branch("ksr_branch_route_one");
26 | KSR.tm.t_on_reply("ksr_onreply_route_one");
27 | KSR.tm.t_on_failure("ksr_failure_route_one");
28 |
29 | KSR.info("relay \n");
30 | if KSR.tm.t_relay() < 0 then
31 | KSR.sl.send_reply(500, "Server error")
32 | end
33 | end
34 |
35 | -- SIP response routing
36 | -- equivalent of reply_route{}
37 | function ksr_reply_route()
38 | KSR.info("===== response - from kamailio lua script\n");
39 | end
40 |
41 | -- branch route callback
42 | -- equivalent of a branch_route{}
43 | function ksr_branch_route_one()
44 | KSR.info("===== branch route - from kamailio lua script\n");
45 | end
46 |
47 | -- onreply route callback
48 | -- equivalent of an onreply_route{}
49 | function ksr_onreply_route_one()
50 | KSR.info("===== onreply route - from kamailio lua script\n");
51 | end
52 |
53 | -- failure route callback
54 | -- equivalent of a failure_route{}
55 | function ksr_failure_route_one()
56 | KSR.info("===== failure route - from kamailio lua script\n");
57 | end
58 |
--------------------------------------------------------------------------------
/Lua_load_balancer/README.md:
--------------------------------------------------------------------------------
1 | # Kamailio as Load balancer
2 |
3 | Uses dipatch module with dbtext to stateless proxy sip traffic to sip servers
4 | Use dbtext to stpres destinations
5 |
6 | Read More on employing kamailio as SIP call Load balancer here :
7 | https://telecom.altanai.com/2014/11/12/telephony-solutions-with-kamailio/
8 |
9 | > Among other features it offers load balancing with many distribution algorithms and failover support ,
10 | >flexible least cost routing , routing failover and replication for High Availability (HA).
11 |
12 | ## security against DOS ( denial of service ) attacks
13 |
14 | sample pike module in action
15 | ```
16 | INFO: