1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
4 Copyright (C) 2006-2010 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 For use with Tomato Firmware only.
8 No part of this file may be used without permission.
12 <meta http-equiv='content-type' content='text/html;charset=utf-
8'
>
13 <meta name='robots' content='noindex,nofollow'
>
14 <title>[<%
ident(); %>] Advanced: Conntrack / Netfilter
</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'
>
16 <link rel='stylesheet' type='text/css' href='color.css'
>
17 <script type='text/javascript' src='tomato.js'
></script>
21 <script type='text/javascript' src='debug.js'
></script>
23 <script type='text/javascript'
>
25 // <% nvram("ct_tcp_timeout,ct_udp_timeout,ct_timeout,ct_max,ct_hashsize,nf_l7in,nf_ttl,nf_sip,nf_rtsp,nf_pptp,nf_h323,nf_ftp"); %>
28 var timer
= new TomatoTimer(check
);
34 if ((checker
) || (!running
)) return;
36 checker
= new XmlHttp();
37 checker
.onCompleted = function(text
, xml
) {
38 var conntrack
, total
, i
;
47 for (i
= 1; i
< 13; ++i
) {
48 E('count' + i
).innerHTML
= ' <small>('+ ((conntrack
[i
] || 0) * 1) + ' in this state)</small>';
50 E('count0').innerHTML
= '(' + ((conntrack
[0] || 0) * 1) + ' connections currently tracked)';
54 checker
.onError = function(x
) {
59 checker
.post('update.cgi', 'exec=ctcount&arg0=0');
65 E('spin').style
.visibility
= running
? 'visible' : 'hidden';
72 function expireTimer()
76 if (!expireText
) expireText
= e
.value
;
78 if (--expireTime
== 0) {
83 setTimeout(expireTimer
, 1000);
84 e
.value
= 'Expire Scheduled... ' + expireTime
;
88 function expireClicked()
91 E('expire').disabled
= true;
92 (new XmlHttp()).post('expct.cgi', '');
97 function verifyFields(focused
, quiet
)
101 for (i
= 1; i
< 9; ++i
) {
102 if (!v_range('_f_tcp_' + i
, quiet
, 1, 432000)) return 0;
104 for (i
= 0; i
< 2; ++i
) {
105 if (!v_range('_f_udp_' + i
, quiet
, 1, 432000)) return 0;
107 for (i
= 0; i
< 2; ++i
) {
108 if (!v_range('_f_ct_' + i
, quiet
, 1, 432000)) return 0;
111 if (!v_range('_ct_max', quiet
, 128, 300000)) return 0;
114 if (!v_range('_ct_hashsize', quiet
, 127, 65535)) return 0;
117 v
= (E('_f_nf_ttl').value
== '');
118 E('_f_ttl_val').style
.display
= v
? '' : 'none';
119 if ((v
) && !v_range('_f_ttl_val', quiet
, 0, 255)) return 0;
126 var i
, tcp
, udp
, ct
, fom
;
128 if (!verifyFields(null, false)) return;
132 for (i
= 1; i
< 9; ++i
) {
133 tcp
.push(E('_f_tcp_' + i
).value
);
138 for (i
= 0; i
< 2; ++i
) {
139 udp
.push(E('_f_udp_' + i
).value
);
143 for (i
= 0; i
< 2; ++i
) {
144 ct
.push(E('_f_ct_' + i
).value
);
148 fom
.ct_tcp_timeout
.value
= tcp
.join(' ');
149 fom
.ct_udp_timeout
.value
= udp
.join(' ');
150 fom
.ct_timeout
.value
= ct
.join(' ');
151 fom
.nf_l7in
.value
= E('_f_l7in').checked
? 1 : 0;
153 fom
.nf_sip
.value
= E('_f_sip').checked
? 1 : 0;
155 fom
.nf_rtsp
.value
= E('_f_rtsp').checked
? 1 : 0;
156 fom
.nf_pptp
.value
= E('_f_pptp').checked
? 1 : 0;
157 fom
.nf_h323
.value
= E('_f_h323').checked
? 1 : 0;
158 fom
.nf_ftp
.value
= E('_f_ftp').checked
? 1 : 0;
160 i
= E('_f_nf_ttl').value
;
162 fom
.nf_ttl
.value
= 'c:' + E('_f_ttl_val').value
;
164 fom
.nf_ttl
.value
= i
;
172 <form id='_fom' method='post' action='tomato.cgi'
>
173 <table id='container' cellspacing=
0>
174 <tr><td colspan=
2 id='header'
>
175 <div class='title'
>Tomato
</div>
176 <div class='version'
>Version <%
version(); %></div>
178 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
180 <div id='ident'
><%
ident(); %></div>
184 <input type='hidden' name='_nextpage' value='advanced-ctnf.asp'
>
185 <input type='hidden' name='_service' value='ctnf-restart'
>
187 <input type='hidden' name='ct_tcp_timeout' value=''
>
188 <input type='hidden' name='ct_udp_timeout' value=''
>
189 <input type='hidden' name='ct_timeout' value=''
>
190 <input type='hidden' name='nf_l7in' value=''
>
191 <input type='hidden' name='nf_ttl'
>
192 <input type='hidden' name='nf_rtsp'
>
193 <input type='hidden' name='nf_pptp'
>
194 <input type='hidden' name='nf_h323'
>
195 <input type='hidden' name='nf_ftp'
>
197 <input type='hidden' name='nf_sip'
>
200 <div class='section-title'
>Connections
</div>
201 <div class='section'
>
202 <script type='text/javascript'
>
203 createFieldTable('', [
204 { title
: 'Maximum Connections', name
: 'ct_max', type
: 'text', maxlen
: 6, size
: 8,
205 suffix
: ' <a href="javascript:clicked()" id="count0">[ count current... ]</a> <img src="spin.gif" style="vertical-align:bottom;padding-left:10px;visibility:hidden" id="spin" onclick="clicked()">',
206 value
: fixInt(nvram
.ct_max
|| 4096, 128, 300000, 4096) }
208 ,{ title
: 'Hash Table Size', name
: 'ct_hashsize', type
: 'text', maxlen
: 6, size
: 8, value
: nvram
.ct_hashsize
|| 1023 }
213 <input type='button' value='Drop Idle' onclick='expireClicked()' id='expire'
>
218 <div class='section-title'
>TCP Timeout
</div>
219 <div class='section'
>
220 <script type='text/javascript'
>
221 if ((v
= nvram
.ct_tcp_timeout
.match(/^(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/)) == null) {
222 v
= [0,0,1200,120,60,120,120,10,60,30,0];
224 titles
= ['-', 'None', 'Established', 'SYN Sent', 'SYN Received', 'FIN Wait', 'Time Wait', 'Close', 'Close Wait', 'Last ACK', 'Listen'];
225 f
= [{ title
: ' ', text
: '<small>(seconds)</small>' }];
226 for (i
= 1; i
< 11; ++i
) {
227 f
.push({ title
: titles
[i
], name
: ('f_tcp_' + (i
- 1)),
228 type
: 'text', maxlen
: 6, size
: 8, value
: v
[i
],
229 hidden
: (i
== 1 || i
== 10) ? 1 : 0,
230 suffix
: '<span id="count' + i
+ '"></span>' });
232 createFieldTable('', f
);
236 <div class='section-title'
>UDP Timeout
</div>
237 <div class='section'
>
238 <script type='text/javascript'
>
239 if ((v
= nvram
.ct_udp_timeout
.match(/^(\d+)\s+(\d+)$/)) == null) {
242 createFieldTable('', [
243 { title
: ' ', text
: '<small>(seconds)</small>' },
244 { title
: 'Unreplied', name
: 'f_udp_0', type
: 'text', maxlen
: 6, size
: 8, value
: v
[1], suffix
: '<span id="count11"></span>' },
245 { title
: 'Assured', name
: 'f_udp_1', type
: 'text', maxlen
: 6, size
: 8, value
: v
[2], suffix
: '<span id="count12"></span>' }
250 <div class='section-title'
>Other Timeouts
</div>
251 <div class='section'
>
252 <script type='text/javascript'
>
253 if ((v
= nvram
.ct_timeout
.match(/^(\d+)\s+(\d+)$/)) == null) {
256 createFieldTable('', [
257 { title
: ' ', text
: '<small>(seconds)</small>' },
258 { title
: 'Generic', name
: 'f_ct_0', type
: 'text', maxlen
: 6, size
: 8, value
: v
[1] },
259 { title
: 'ICMP', name
: 'f_ct_1', type
: 'text', maxlen
: 6, size
: 8, value
: v
[2] }
264 <div class='section-title'
>Tracking / NAT Helpers
</div>
265 <div class='section'
>
266 <script type='text/javascript'
>
267 createFieldTable('', [
268 { title
: 'FTP', name
: 'f_ftp', type
: 'checkbox', value
: nvram
.nf_ftp
!= '0' },
269 { title
: 'GRE / PPTP', name
: 'f_pptp', type
: 'checkbox', value
: nvram
.nf_pptp
!= '0' },
270 { title
: 'H.323', name
: 'f_h323', type
: 'checkbox', value
: nvram
.nf_h323
!= '0' },
272 { title
: 'SIP', name
: 'f_sip', type
: 'checkbox', value
: nvram
.nf_sip
!= '0' },
274 { title
: 'RTSP', name
: 'f_rtsp', type
: 'checkbox', value
: nvram
.nf_rtsp
!= '0' }
279 <div class='section-title'
>Miscellaneous
</div>
280 <div class='section'
>
281 <script type='text/javascript'
>
283 for (i
= -5; i
<= 5; ++i
) {
284 v
.push([i
+ '', i
? ((i
> 0) ? '+' : '') + i
: 'None']);
286 v
.push(['', 'Custom']);
288 createFieldTable('', [
289 { title
: 'TTL Adjust', multi
: [
290 { name
: 'f_nf_ttl', type
: 'select', options
: v
, value
: nvram
.nf_ttl
.substr(0, 2) == 'c:' ? '' : nvram
.nf_ttl
},
291 { name
: 'f_ttl_val', type
: 'text', maxlen
: 3, size
: 6, value
: nvram
.nf_ttl
.substr(0, 2) == 'c:' ? nvram
.nf_ttl
.substr(2, 5) : '' }
293 { title
: 'Inbound Layer 7', name
: 'f_l7in', type
: 'checkbox', value
: nvram
.nf_l7in
!= '0' }
301 <tr><td id='footer' colspan=
2>
302 <span id='footer-msg'
></span>
303 <input type='button' value='Save' id='save-button' onclick='save()'
>
304 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'
>
308 <script type='text/javascript'
>verifyFields(null, 1);</script>