Browse code

examples: moved to misc directory

Daniel-Constantin Mierla authored on 07/12/2016 13:56:54
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,227 +0,0 @@
1
-#
2
-# $Id$
3
-#
4
-# simple quick-start config script including nathelper support
5
-
6
-# This default script includes nathelper support. To make it work
7
-# you will also have to install Maxim's RTP proxy. The proxy is enforced
8
-# if one of the parties is behind a NAT.
9
-#
10
-# If you have an endpoing in the public internet which is known to
11
-# support symmetric RTP (Cisco PSTN gateway or voicemail, for example),
12
-# then you don't have to force RTP proxy. If you don't want to enforce
13
-# RTP proxy for some destinations than simply use t_relay() instead of
14
-# route(1)
15
-#
16
-# Sections marked with !! Nathelper contain modifications for nathelper
17
-#
18
-# NOTE !! This config is EXPERIMENTAL !
19
-#
20
-# ----------- global configuration parameters ------------------------
21
-
22
-debug=3         # debug level (cmd line: -dddddddddd)
23
-fork=yes
24
-log_stderror=no	# (cmd line: -E)
25
-
26
-/* Uncomment these lines to enter debugging mode 
27
-fork=no
28
-log_stderror=yes
29
-*/
30
-
31
-check_via=no	# (cmd. line: -v)
32
-dns=no           # (cmd. line: -r)
33
-rev_dns=no      # (cmd. line: -R)
34
-port=5060
35
-children=4
36
-fifo="/tmp/sip-router_fifo"
37
-
38
-# ------------------ module loading ----------------------------------
39
-
40
-# Uncomment this if you want to use SQL database
41
-#loadmodule "/usr/local/lib/sip-router/modules/mysql.so"
42
-
43
-loadmodule "/usr/local/lib/sip-router/modules/sl.so"
44
-loadmodule "/usr/local/lib/sip-router/modules/tm.so"
45
-loadmodule "/usr/local/lib/sip-router/modules/rr.so"
46
-loadmodule "/usr/local/lib/sip-router/modules/maxfwd.so"
47
-loadmodule "/usr/local/lib/sip-router/modules/usrloc.so"
48
-loadmodule "/usr/local/lib/sip-router/modules/registrar.so"
49
-loadmodule "/usr/local/lib/sip-router/modules/textops.so"
50
-
51
-# Uncomment this if you want digest authentication
52
-# mysql.so must be loaded !
53
-#loadmodule "/usr/local/lib/sip-router/modules/auth.so"
54
-#loadmodule "/usr/local/lib/sip-router/modules/auth_db.so"
55
-
56
-# !! Nathelper
57
-loadmodule "/usr/local/lib/sip-router/modules/nathelper.so"
58
-
59
-# ----------------- setting module-specific parameters ---------------
60
-
61
-# -- usrloc params --
62
-
63
-modparam("usrloc", "db_mode",   0)
64
-
65
-# Uncomment this if you want to use SQL database 
66
-# for persistent storage and comment the previous line
67
-#modparam("usrloc", "db_mode", 2)
68
-
69
-# -- auth params --
70
-# Uncomment if you are using auth module
71
-#
72
-#modparam("auth_db", "calculate_ha1", yes)
73
-#
74
-# If you set "calculate_ha1" parameter to yes (which true in this config), 
75
-# uncomment also the following parameter)
76
-#
77
-#modparam("auth_db", "plain_password_column", "password")
78
-
79
-# -- rr params --
80
-# add value to ;lr param to make some broken UAs happy
81
-modparam("rr", "enable_full_lr", 1)
82
-
83
-# !! Nathelper
84
-modparam("registrar", "nat_flag", 6)
85
-modparam("nathelper", "natping_interval", 30) # Ping interval 30 s
86
-modparam("nathelper", "ping_nated_only", 1)   # Ping only clients behind NAT
87
-
88
-# -------------------------  request routing logic -------------------
89
-
90
-# main routing logic
91
-
92
-route{
93
-
94
-	# initial sanity checks -- messages with
95
-	# max_forwards==0, or excessively long requests
96
-	if (!mf_process_maxfwd_header("10")) {
97
-		sl_send_reply("483","Too Many Hops");
98
-		break;
99
-	};
100
-	if (msg:len >=  max_len ) {
101
-		sl_send_reply("513", "Message too big");
102
-		break;
103
-	};
104
-
105
-        # !! Nathelper
106
-	# Special handling for NATed clients; first, NAT test is
107
-	# executed: it looks for via!=received and RFC1918 addresses
108
-	# in Contact (may fail if line-folding is used); also,
109
-	# the received test should, if completed, should check all
110
-	# vias for rpesence of received
111
-	if (nat_uac_test("3")) {
112
-		# Allow RR-ed requests, as these may indicate that
113
-		# a NAT-enabled proxy takes care of it; unless it is
114
-		# a REGISTER
115
-
116
-		if (method == "REGISTER" || ! search("^Record-Route:")) {
117
-		    log("LOG: Someone trying to register from private IP, rewriting\n");
118
-
119
-		    # This will work only for user agents that support symmetric
120
-		    # communication. We tested quite many of them and majority is
121
-		    # smart enough to be symmetric. In some phones it takes a configuration
122
-		    # option. With Cisco 7960, it is called NAT_Enable=Yes, with kphone it is
123
-		    # called "symmetric media" and "symmetric signalling".
124
-
125
-		    fix_nated_contact(); # Rewrite contact with source IP of signalling
126
-		    if (method == "INVITE") {
127
-		        fix_nated_sdp("1"); # Add direction=active to SDP
128
-		    };
129
-		    force_rport(); # Add rport parameter to topmost Via
130
-		    setflag(6);    # Mark as NATed
131
-		};
132
-	};
133
-
134
-	# we record-route all messages -- to make sure that
135
-	# subsequent messages will go through our proxy; that's
136
-	# particularly good if upstream and downstream entities
137
-	# use different transport protocol
138
-	if (!method=="REGISTER") record_route();	
139
-
140
-	# subsequent messages withing a dialog should take the
141
-	# path determined by record-routing
142
-	if (loose_route()) {
143
-		# mark routing logic in request
144
-		append_hf("P-hint: rr-enforced\r\n"); 
145
-		route(1);
146
-		break;
147
-	};
148
-
149
-	if (!uri==myself) {
150
-		# mark routing logic in request
151
-		append_hf("P-hint: outbound\r\n"); 
152
-		route(1);
153
-		break;
154
-	};
155
-
156
-	# if the request is for other domain use UsrLoc
157
-	# (in case, it does not work, use the following command
158
-	# with proper names and addresses in it)
159
-	if (uri==myself) {
160
-
161
-		if (method=="REGISTER") {
162
-
163
-# Uncomment this if you want to use digest authentication
164
-#			if (!www_authorize("iptel.org", "subscriber")) {
165
-#				www_challenge("iptel.org", "0");
166
-#				break;
167
-#			};
168
-
169
-			save("location");
170
-			break;
171
-		};
172
-
173
-		lookup("aliases");
174
-		if (!uri==myself) {
175
-			append_hf("P-hint: outbound alias\r\n"); 
176
-			route(1);
177
-			break;
178
-		};
179
-
180
-		# native SIP destinations are handled using our USRLOC DB
181
-		if (!lookup("location")) {
182
-			sl_send_reply("404", "Not Found");
183
-			break;
184
-		};
185
-	};
186
-	append_hf("P-hint: usrloc applied\r\n"); 
187
-	route(1);
188
-}
189
-
190
-route[1] 
191
-{
192
-	# !! Nathelper
193
-	if (uri=~"[@:](192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.)" && !search("^Route:")){
194
-	    sl_send_reply("479", "We don't forward to private IP addresses");
195
-	    break;
196
-        };
197
-	
198
-	# if client or server know to be behind a NAT, enable relay
199
-	if (isflagset(6)) {
200
-	    force_rtp_proxy();
201
-	};
202
-
203
-	# NAT processing of replies; apply to all transactions (for example,
204
-	# re-INVITEs from public to private UA are hard to identify as
205
-	# NATed at the moment of request processing); look at replies
206
-	t_on_reply("1");
207
-
208
-	# send it out now; use stateful forwarding as it works reliably
209
-	# even for UDP2TCP
210
-	if (!t_relay()) {
211
-		sl_reply_error();
212
-	};
213
-}
214
-
215
-# !! Nathelper
216
-onreply_route[1] {
217
-    # NATed transaction ?
218
-    if (isflagset(6) && status =~ "(183)|2[0-9][0-9]") {
219
-        fix_nated_contact();
220
-	force_rtp_proxy();
221
-    # otherwise, is it a transaction behind a NAT and we did not
222
-    # know at time of request processing ? (RFC1918 contacts)
223
-    } else if (nat_uac_test("1")) {
224
-        fix_nated_contact();
225
-    };
226
-}
227
-
Browse code

etc: cleaned up folder, moving unused files to examples

Daniel-Constantin Mierla authored on 14/03/2014 18:59:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,227 @@
1
+#
2
+# $Id$
3
+#
4
+# simple quick-start config script including nathelper support
5
+
6
+# This default script includes nathelper support. To make it work
7
+# you will also have to install Maxim's RTP proxy. The proxy is enforced
8
+# if one of the parties is behind a NAT.
9
+#
10
+# If you have an endpoing in the public internet which is known to
11
+# support symmetric RTP (Cisco PSTN gateway or voicemail, for example),
12
+# then you don't have to force RTP proxy. If you don't want to enforce
13
+# RTP proxy for some destinations than simply use t_relay() instead of
14
+# route(1)
15
+#
16
+# Sections marked with !! Nathelper contain modifications for nathelper
17
+#
18
+# NOTE !! This config is EXPERIMENTAL !
19
+#
20
+# ----------- global configuration parameters ------------------------
21
+
22
+debug=3         # debug level (cmd line: -dddddddddd)
23
+fork=yes
24
+log_stderror=no	# (cmd line: -E)
25
+
26
+/* Uncomment these lines to enter debugging mode 
27
+fork=no
28
+log_stderror=yes
29
+*/
30
+
31
+check_via=no	# (cmd. line: -v)
32
+dns=no           # (cmd. line: -r)
33
+rev_dns=no      # (cmd. line: -R)
34
+port=5060
35
+children=4
36
+fifo="/tmp/sip-router_fifo"
37
+
38
+# ------------------ module loading ----------------------------------
39
+
40
+# Uncomment this if you want to use SQL database
41
+#loadmodule "/usr/local/lib/sip-router/modules/mysql.so"
42
+
43
+loadmodule "/usr/local/lib/sip-router/modules/sl.so"
44
+loadmodule "/usr/local/lib/sip-router/modules/tm.so"
45
+loadmodule "/usr/local/lib/sip-router/modules/rr.so"
46
+loadmodule "/usr/local/lib/sip-router/modules/maxfwd.so"
47
+loadmodule "/usr/local/lib/sip-router/modules/usrloc.so"
48
+loadmodule "/usr/local/lib/sip-router/modules/registrar.so"
49
+loadmodule "/usr/local/lib/sip-router/modules/textops.so"
50
+
51
+# Uncomment this if you want digest authentication
52
+# mysql.so must be loaded !
53
+#loadmodule "/usr/local/lib/sip-router/modules/auth.so"
54
+#loadmodule "/usr/local/lib/sip-router/modules/auth_db.so"
55
+
56
+# !! Nathelper
57
+loadmodule "/usr/local/lib/sip-router/modules/nathelper.so"
58
+
59
+# ----------------- setting module-specific parameters ---------------
60
+
61
+# -- usrloc params --
62
+
63
+modparam("usrloc", "db_mode",   0)
64
+
65
+# Uncomment this if you want to use SQL database 
66
+# for persistent storage and comment the previous line
67
+#modparam("usrloc", "db_mode", 2)
68
+
69
+# -- auth params --
70
+# Uncomment if you are using auth module
71
+#
72
+#modparam("auth_db", "calculate_ha1", yes)
73
+#
74
+# If you set "calculate_ha1" parameter to yes (which true in this config), 
75
+# uncomment also the following parameter)
76
+#
77
+#modparam("auth_db", "plain_password_column", "password")
78
+
79
+# -- rr params --
80
+# add value to ;lr param to make some broken UAs happy
81
+modparam("rr", "enable_full_lr", 1)
82
+
83
+# !! Nathelper
84
+modparam("registrar", "nat_flag", 6)
85
+modparam("nathelper", "natping_interval", 30) # Ping interval 30 s
86
+modparam("nathelper", "ping_nated_only", 1)   # Ping only clients behind NAT
87
+
88
+# -------------------------  request routing logic -------------------
89
+
90
+# main routing logic
91
+
92
+route{
93
+
94
+	# initial sanity checks -- messages with
95
+	# max_forwards==0, or excessively long requests
96
+	if (!mf_process_maxfwd_header("10")) {
97
+		sl_send_reply("483","Too Many Hops");
98
+		break;
99
+	};
100
+	if (msg:len >=  max_len ) {
101
+		sl_send_reply("513", "Message too big");
102
+		break;
103
+	};
104
+
105
+        # !! Nathelper
106
+	# Special handling for NATed clients; first, NAT test is
107
+	# executed: it looks for via!=received and RFC1918 addresses
108
+	# in Contact (may fail if line-folding is used); also,
109
+	# the received test should, if completed, should check all
110
+	# vias for rpesence of received
111
+	if (nat_uac_test("3")) {
112
+		# Allow RR-ed requests, as these may indicate that
113
+		# a NAT-enabled proxy takes care of it; unless it is
114
+		# a REGISTER
115
+
116
+		if (method == "REGISTER" || ! search("^Record-Route:")) {
117
+		    log("LOG: Someone trying to register from private IP, rewriting\n");
118
+
119
+		    # This will work only for user agents that support symmetric
120
+		    # communication. We tested quite many of them and majority is
121
+		    # smart enough to be symmetric. In some phones it takes a configuration
122
+		    # option. With Cisco 7960, it is called NAT_Enable=Yes, with kphone it is
123
+		    # called "symmetric media" and "symmetric signalling".
124
+
125
+		    fix_nated_contact(); # Rewrite contact with source IP of signalling
126
+		    if (method == "INVITE") {
127
+		        fix_nated_sdp("1"); # Add direction=active to SDP
128
+		    };
129
+		    force_rport(); # Add rport parameter to topmost Via
130
+		    setflag(6);    # Mark as NATed
131
+		};
132
+	};
133
+
134
+	# we record-route all messages -- to make sure that
135
+	# subsequent messages will go through our proxy; that's
136
+	# particularly good if upstream and downstream entities
137
+	# use different transport protocol
138
+	if (!method=="REGISTER") record_route();	
139
+
140
+	# subsequent messages withing a dialog should take the
141
+	# path determined by record-routing
142
+	if (loose_route()) {
143
+		# mark routing logic in request
144
+		append_hf("P-hint: rr-enforced\r\n"); 
145
+		route(1);
146
+		break;
147
+	};
148
+
149
+	if (!uri==myself) {
150
+		# mark routing logic in request
151
+		append_hf("P-hint: outbound\r\n"); 
152
+		route(1);
153
+		break;
154
+	};
155
+
156
+	# if the request is for other domain use UsrLoc
157
+	# (in case, it does not work, use the following command
158
+	# with proper names and addresses in it)
159
+	if (uri==myself) {
160
+
161
+		if (method=="REGISTER") {
162
+
163
+# Uncomment this if you want to use digest authentication
164
+#			if (!www_authorize("iptel.org", "subscriber")) {
165
+#				www_challenge("iptel.org", "0");
166
+#				break;
167
+#			};
168
+
169
+			save("location");
170
+			break;
171
+		};
172
+
173
+		lookup("aliases");
174
+		if (!uri==myself) {
175
+			append_hf("P-hint: outbound alias\r\n"); 
176
+			route(1);
177
+			break;
178
+		};
179
+
180
+		# native SIP destinations are handled using our USRLOC DB
181
+		if (!lookup("location")) {
182
+			sl_send_reply("404", "Not Found");
183
+			break;
184
+		};
185
+	};
186
+	append_hf("P-hint: usrloc applied\r\n"); 
187
+	route(1);
188
+}
189
+
190
+route[1] 
191
+{
192
+	# !! Nathelper
193
+	if (uri=~"[@:](192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.)" && !search("^Route:")){
194
+	    sl_send_reply("479", "We don't forward to private IP addresses");
195
+	    break;
196
+        };
197
+	
198
+	# if client or server know to be behind a NAT, enable relay
199
+	if (isflagset(6)) {
200
+	    force_rtp_proxy();
201
+	};
202
+
203
+	# NAT processing of replies; apply to all transactions (for example,
204
+	# re-INVITEs from public to private UA are hard to identify as
205
+	# NATed at the moment of request processing); look at replies
206
+	t_on_reply("1");
207
+
208
+	# send it out now; use stateful forwarding as it works reliably
209
+	# even for UDP2TCP
210
+	if (!t_relay()) {
211
+		sl_reply_error();
212
+	};
213
+}
214
+
215
+# !! Nathelper
216
+onreply_route[1] {
217
+    # NATed transaction ?
218
+    if (isflagset(6) && status =~ "(183)|2[0-9][0-9]") {
219
+        fix_nated_contact();
220
+	force_rtp_proxy();
221
+    # otherwise, is it a transaction behind a NAT and we did not
222
+    # know at time of request processing ? (RFC1918 contacts)
223
+    } else if (nat_uac_test("1")) {
224
+        fix_nated_contact();
225
+    };
226
+}
227
+