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(); %>] Admin: IP Traffic Monitoring
</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'
>
17 <script type='text/javascript' src='tomato.js'
></script>
20 <style type='text/css'
>
27 <script type='text/javascript' src='debug.js'
></script>
29 <script type='text/javascript'
>
31 // <% nvram("cstats_enable,cstats_path,cstats_stime,cstats_offset,cstats_exclude,cstats_include,cstats_sshut,et0macaddr,cifs1,cifs2,jffs2_on,cstats_bak,cstats_all,cstats_labels"); %>
36 if (((i
= name
.lastIndexOf('/')) > 0) || ((i
= name
.lastIndexOf('\\')) > 0))
37 name
= name
.substring(i
+ 1, name
.length
);
41 function backupNameChanged()
43 if (location
.href
.match(/^(http.+?\/.+\/)/)) {
44 E('backup-link').href
= RegExp
.$1 + 'ipt/' + fix(E('backup-name').value
) + '.gz?_http_id=' + nvram
.http_id
;
48 function backupButton()
52 name
= fix(E('backup-name').value
);
53 if (name
.length
<= 1) {
54 alert('Invalid filename');
57 location
.href
= 'ipt/' + name
+ '.gz?_http_id=' + nvram
.http_id
;
60 function restoreButton()
66 name
= fix(E('restore-name').value
);
67 name
= name
.toLowerCase();
68 if ((name
.length
<= 3) || (name
.substring(name
.length
- 3, name
.length
).toLowerCase() != '.gz')) {
69 alert('Incorrect filename. Expecting a ".gz" file.');
72 if (!confirm('Restore data from ' + name
+ '?')) return;
74 E('restore-button').disabled
= 1;
75 fields
.disableAll(E('config-section'), 1);
76 fields
.disableAll(E('backup-section'), 1);
77 fields
.disableAll(E('footer'), 1);
79 E('restore-form').submit();
84 var s
= E('_f_loc').value
;
85 return (s
== '*user') ? E('_f_user').value
: s
;
88 function verifyFields(focused
, quiet
)
92 var eLoc
, eUser
, eTime
, eOfs
;
94 var eInc
, eExc
, eAll
, eBak
, eLab
;
98 eTime
= E('_cstats_stime');
99 eOfs
= E('_cstats_offset');
101 eInc
= E('_cstats_include');
102 eExc
= E('_cstats_exclude');
106 eLab
= E('_cstats_labels');
108 b
= !E('_f_cstats_enable').checked
;
118 E('_f_new').disabled
= b
;
119 E('_f_sshut').disabled
= b
;
120 E('backup-button').disabled
= b
;
121 E('backup-name').disabled
= b
;
122 E('restore-button').disabled
= b
;
123 E('restore-name').disabled
= b
;
129 eInc
.disabled
= eAll
.checked
;
132 E('newmsg').style
.visibility
= ((nvram
.cstats_path
!= path
) && (path
!= '*nvram') && (path
!= '')) ? 'visible' : 'hidden';
137 elem
.display(eUser
, b
);
139 if (!v_length(eUser
, quiet
, 2)) return 0;
140 if (path
.substr(0, 1) != '/') {
141 ferror
.set(eUser
, 'Please start at the / root directory.', quiet
);
145 else if (v
== '/jffs/') {
146 if (nvram
.jffs2_on
!= '1') {
147 ferror
.set(eLoc
, 'JFFS2 is not enabled.', quiet
);
151 else if (v
.match(/^\/cifs(1|2)\/$/)) {
152 if (nvram
['cifs' + RegExp
.$1].substr(0, 1) != '1') {
153 ferror
.set(eLoc
, 'CIFS #' + RegExp
.$1 + ' is not enabled.', quiet
);
161 E('_f_bak').disabled
= bak
;
163 return v_range(eOfs
, quiet
, 1, 31);
168 var fom
, path
, en
, e
, aj
;
170 if (!verifyFields(null, false)) return;
173 en
= E('_f_cstats_enable').checked
;
175 fom
._service
.value
= 'cstats-restart';
178 if (((E('_cstats_stime').value
* 1) <= 48) &&
179 ((path
== '*nvram') || (path
== '/jffs/'))) {
180 if (!confirm('Frequent saving to NVRAM or JFFS2 is not recommended. Continue anyway?')) return;
182 if ((nvram
.cstats_path
!= path
) && (fom
.cstats_path
.value
!= path
) && (path
!= '') && (path
!= '*nvram') &&
183 (path
.substr(path
.length
- 1, 1) != '/')) {
184 if (!confirm('Note: ' + path
+ ' will be treated as a file. If this is a directory, please use a trailing /. Continue anyway?')) return;
186 fom
.cstats_path
.value
= path
;
188 if (E('_f_new').checked
) {
189 fom
._service
.value
= 'cstatsnew-restart';
194 fom
.cstats_path
.disabled
= !en
;
195 fom
.cstats_enable
.value
= en
? 1 : 0;
196 fom
.cstats_sshut
.value
= E('_f_sshut').checked
? 1 : 0;
197 fom
.cstats_bak
.value
= E('_f_bak').checked
? 1 : 0;
198 fom
.cstats_all
.value
= E('_f_all').checked
? 1 : 0;
200 e
= E('_cstats_exclude');
201 e
.value
= e
.value
.replace(/\s+/g, ',').replace(/,+/g, ',');
203 e
= E('_cstats_include');
204 e
.value
= e
.value
.replace(/\s+/g, ',').replace(/,+/g, ',');
206 fields
.disableAll(E('backup-section'), 1);
207 fields
.disableAll(E('restore-section'), 1);
208 form
.submit(fom
, aj
);
210 fields
.disableAll(E('backup-section'), 0);
211 fields
.disableAll(E('restore-section'), 0);
219 if (((c
= cookie
.get('admin_iptraffic_notes_vis')) != null) && (c
== '1')) toggleVisibility("notes");
222 function toggleVisibility(whichone
) {
223 if (E('sesdiv_' + whichone
).style
.display
== '') {
224 E('sesdiv_' + whichone
).style
.display
= 'none';
225 E('sesdiv_' + whichone
+ '_showhide').innerHTML
= '(Click here to show)';
226 cookie
.set('admin_iptraffic_' + whichone
+ '_vis', 0);
228 E('sesdiv_' + whichone
).style
.display
='';
229 E('sesdiv_' + whichone
+ '_showhide').innerHTML
= '(Click here to hide)';
230 cookie
.set('admin_iptraffic_' + whichone
+ '_vis', 1);
236 <body onload=
"init()">
237 <table id='container' cellspacing=
0>
238 <tr><td colspan=
2 id='header'
>
239 <div class='title'
>Tomato
</div>
240 <div class='version'
>Version <%
version(); %></div>
242 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
244 <div id='ident'
><%
ident(); %></div>
248 <div class='section-title'
>IP Traffic Monitoring
</div>
249 <div class='section' id='config-section'
>
250 <form id='_fom' method='post' action='tomato.cgi'
>
251 <input type='hidden' name='_nextpage' value='admin-iptraffic.asp'
>
252 <input type='hidden' name='_service' value='cstats-restart'
>
253 <input type='hidden' name='cstats_enable'
>
254 <input type='hidden' name='cstats_path'
>
255 <input type='hidden' name='cstats_sshut'
>
256 <input type='hidden' name='cstats_bak'
>
257 <input type='hidden' name='cstats_all'
>
259 <script type='text/javascript'
>
260 switch (nvram
.cstats_path
) {
266 loc
= nvram
.cstats_path
;
272 createFieldTable('', [
273 { title
: 'Enable', name
: 'f_cstats_enable', type
: 'checkbox', value
: nvram
.cstats_enable
== '1' },
274 { title
: 'Save History Location', multi
: [
276 // { name: 'f_loc', type: 'select', options: [['','RAM (Temporary)'],['*nvram','NVRAM'],['/jffs/','JFFS2'],['/cifs1/','CIFS 1'],['/cifs2/','CIFS 2'],['*user','Custom Path']], value: loc },
278 { name
: 'f_loc', type
: 'select', options
: [['','RAM (Temporary)'],['/jffs/','JFFS2'],['/cifs1/','CIFS 1'],['/cifs2/','CIFS 2'],['*user','Custom Path']], value
: loc
},
279 { name
: 'f_user', type
: 'text', maxlen
: 48, size
: 50, value
: nvram
.cstats_path
}
281 { title
: 'Save Frequency', indent
: 2, name
: 'cstats_stime', type
: 'select', value
: nvram
.cstats_stime
, options
: [
282 [1,'Every Hour'],[2,'Every 2 Hours'],[3,'Every 3 Hours'],[4,'Every 4 Hours'],[5,'Every 5 Hours'],[6,'Every 6 Hours'],
283 [9,'Every 9 Hours'],[12,'Every 12 Hours'],[24,'Every 24 Hours'],[48,'Every 2 Days'],[72,'Every 3 Days'],[96,'Every 4 Days'],
284 [120,'Every 5 Days'],[144,'Every 6 Days'],[168,'Every Week']] },
285 { title
: 'Save On Shutdown', indent
: 2, name
: 'f_sshut', type
: 'checkbox', value
: nvram
.cstats_sshut
== '1' },
286 { title
: 'Create New File<br><small>(Reset Data)</small>', indent
: 2, name
: 'f_new', type
: 'checkbox', value
: 0,
287 suffix
: ' <b id="newmsg" style="visibility:hidden"><small>(note: enable if this is a new file)</small></b>' },
288 { title
: 'Create Backups', indent
: 2, name
: 'f_bak', type
: 'checkbox', value
: nvram
.cstats_bak
== '1' },
289 { title
: 'First Day Of The Month', name
: 'cstats_offset', type
: 'text', value
: nvram
.cstats_offset
, maxlen
: 2, size
: 4 },
290 { title
: 'Excluded IPs', name
: 'cstats_exclude', type
: 'text', value
: nvram
.cstats_exclude
, maxlen
: 512, size
: 50, suffix
: ' <small>(comma separated list)</small>' },
291 { title
: 'Included IPs', name
: 'cstats_include', type
: 'text', value
: nvram
.cstats_include
, maxlen
: 2048, size
: 50, suffix
: ' <small>(comma separated list)</small>' },
292 { title
: 'Enable Auto-Discovery', name
: 'f_all', type
: 'checkbox', value
: nvram
.cstats_all
== '1', suffix
: ' <small>(automatically include new IPs in monitoring as soon as any traffic is detected)</small>' },
293 { title
: 'Labels on graphics', name
: 'cstats_labels', type
: 'select', value
: nvram
.cstats_stime
, options
: [[0,'Show known hostnames and IPs'],[1,'Prefer to show only known hostnames, otherwise show IPs'],[2,'Show only IPs']], value
: nvram
.cstats_labels
}
301 <div class='section-title'
>Backup
</div>
302 <div class='section' id='backup-section'
>
304 <script type='text/javascript'
>
305 W("<input type='text' size='40' maxlength='64' id='backup-name' name='backup_name' onchange='backupNameChanged()' value='tomato_cstats_" + nvram
.et0macaddr
.replace(/:/g
, '').toLowerCase() + "'>");
308 <input type='button' name='f_backup_button' id='backup-button' onclick='backupButton()' value='Backup'
>
310 <a href='' id='backup-link'
>Link
</a>
314 <div class='section-title'
>Restore
</div>
315 <div class='section' id='restore-section'
>
316 <form id='restore-form' method='post' action='ipt/restore.cgi?_http_id=<%
nv(http_id
); %>' encType='multipart/form-data'
>
317 <input type='file' size='
40' id='restore-name' name='restore_name'
>
318 <input type='button' name='f_restore_button' id='restore-button' value='Restore' onclick='restoreButton()'
>
325 <div class='section-title'
>Notes
<small><i><a href='javascript:toggleVisibility(
"notes");'
><span id='sesdiv_notes_showhide'
>(Click here to show)
</span></a></i></small></div>
326 <div class='section' id='sesdiv_notes' style='display:none'
>
328 <li>IP Traffic is about monitoring
<i>IPv4
</i> network traffic flowing
<i>through
</i> the router.
</li>
329 <li>Check your
<a href=basic-network.asp
>LAN Settings
</a> before enabling this feature: any/all LAN interfaces must have a netmask with at least
16 bits set (
255.255.0.0).
</li>
330 <li>Monitoring of larger subnets is not supported.
</li>
335 <li><b>Other relevant notes/hints:
</b>
337 <li>Before enabling this feature, please check your
<a href=basic-network.asp
>LAN Settings
</a> and make sure the netmask on any/all of your LAN bridges has been configured properly (i.e. netmask with at least
16 bits set or
"255.255.0.0").
</li>
338 <li>Although technically supported, it's not actually recommended having IP Traffic monitoring enabled with subnets larger than/the equivalent of a class C network (i.e. netmask with at least
24 bits set or
"255.255.255.0").
</li>
339 <li>IP Traffic monitoring keeps track of data/packets that would be either
<i>coming from/leaving
</i> or
<i>going to/arriving
</i> IPs on LAN interfaces/subnets.
</li>
340 <li>As a rule of thumb, this means keeping track of network/data packets being forwarded from/to LAN interfaces as a result of some kind of routing (or NAT) and would exclude any/all data/packets being exchanged between devices reachable/within the same LAN interface (i.e. on the same IP subnet/LAN bridge, even if packets are actually being forwarded from/to wired/wireless/different interfaces through the router).
</li>
342 <li>Network traffic/communications flowing from/to/between different LAN bridges/subnets will be tracked/accounted separately/accordingly (
"twice", as in: number of bytes/packets
<i>coming from
</i> the first LAN bridge and (the same) number of bytes/packets
<i>going to
</i> the second LAN bridge).
</li>
352 <tr><td id='footer' colspan=
2>
354 <span id='footer-msg'
></span>
355 <input type='button' value='Save' id='save-button' onclick='save()'
>
356 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'
>
361 <script type='text/javascript'
>verifyFields(null, 1);</script>