1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
4 Copyright (C) 2006-2010 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 Filtering/Extensions on this QoS/Transfer Rates page
8 Copyright (C) 2011 Augusto Bott
9 http://code.google.com/p/tomato-sdhc-vlan/
11 For use with Tomato Firmware only.
12 No part of this file may be used without permission.
16 <meta http-equiv='content-type' content='text/html;charset=utf-
8'
>
17 <meta name='robots' content='noindex,nofollow'
>
18 <title>[<%
ident(); %>] QoS: View Per-Connection Transfer Rates
</title>
19 <link rel='stylesheet' type='text/css' href='tomato.css'
>
21 <script type='text/javascript' src='tomato.js'
></script>
25 <style type='text/css'
>
34 <script type='text/javascript' src='debug.js'
></script>
35 <script type='text/javascript' src='protocols.js'
></script>
36 <script type='text/javascript' src='interfaces.js'
></script>
38 <script type='text/javascript'
>
39 // <% nvram('lan_ipaddr,lan1_ipaddr,lan2_ipaddr,lan3_ipaddr,lan_netmask,lan1_netmask,lan2_netmask,lan3_netmask,t_hidelr'); %>
43 readDelay
= fixInt('<% cgi_get("delay"); %>', 2, 30, 2);
52 if ((queue
.length
== 0) || (xob
)) return;
55 xob
.onCompleted = function(text
, xml
) {
57 for (var i
= 0; i
< resolve_data
.length
; ++i
) {
58 var r
= resolve_data
[i
];
59 if (r
[1] == '') r
[1] = r
[0];
61 if (lock
== 0) grid
.setName(r
[0], r
[1]);
63 if (queue
.length
== 0) {
64 if ((lock
== 0) && (resolveCB
) && (grid
.sortColumn
== 4)) grid
.resort();
66 else setTimeout(resolve
, 500);
69 xob
.onError = function(ex
) {
73 xob
.post('resolve.cgi', 'ip=' + queue
.splice(0, 20).join(','));
80 function resolveChanged()
84 b
= E('_f_autoresolve').checked
? 1 : 0;
87 cookie
.set('qos_ctr_resolve', b
);
89 if (b
) grid
.resolveAll();
94 function thresChanged()
98 b
= E('_f_excludebythreshold').checked
? fixInt('<% cgi_get("thres"); %>', 100, 10000000, 100) : 0;
101 cookie
.set('qos_ctr_thres', b
);
102 ref
.postData
= 'exec=ctrate&arg0=' + readDelay
+ '&arg1=' + thres
;
103 if (!ref
.running
) ref
.once
= 1;
104 E('loading').style
.visibility
= '';
109 var grid
= new TomatoGrid();
111 grid
.dataToView = function(data
) {
113 for (var col
= 0; col
< data
.length
; ++col
) {
117 s
= (data
[col
] / (readDelay
* 1024)).toFixed(1);
128 grid
.sortCompare = function(a
, b
) {
130 var col
= obj
.sortColumn
;
131 var da
= a
.getRowData();
132 var db
= b
.getRowData();
140 r
= cmpInt(da
[col
], db
[col
]);
144 var a
= fixIP(da
[col
]);
145 var b
= fixIP(db
[col
]);
146 if ((a
!= null) && (b
!= null)) {
147 r
= aton(a
) - aton(b
);
151 r
= cmpText(da
[col
], db
[col
]);
154 return obj
.sortAscending
? r
: -r
;
157 grid
.onClick = function(cell
) {
159 var ip
= row
.getRowData()[3];
160 if (this.lastClicked
!= row
) {
161 this.lastClicked
= row
;
162 if (ip
.indexOf('<') == -1) {
164 row
.style
.cursor
= 'wait';
173 grid
.resolveAll = function()
175 var i
, ip
, row
, q
, cols
, j
;
179 for (i
= 1; i
< this.tb
.rows
.length
; ++i
) {
180 row
= this.tb
.rows
[i
];
181 for (j
= cols
.length
-1; j
>= 0; j
--) {
182 ip
= row
.getRowData()[cols
[j
]];
183 if (ip
.indexOf('<') == -1) {
188 row
.style
.cursor
= 'wait';
196 grid
.setName = function(ip
, name
) {
197 var i
, row
, data
, cols
, j
;
200 for (i
= this.tb
.rows
.length
- 1; i
> 0; --i
) {
201 row
= this.tb
.rows
[i
];
202 data
= row
.getRowData();
203 for (j
= cols
.length
-1; j
>= 0; j
--) {
204 if (data
[cols
[j
]].indexOf(ip
) != -1 ) {
205 data
[cols
[j
]] = name
+ ((ip
.indexOf(':') != -1) ? '<br>' : ' ') + '<small>(' + ip
+ ')</small>';
206 row
.setRowData(data
);
207 if (E('_f_shortcuts').checked
)
208 data
[cols
[j
]] = data
[cols
[j
]] + ' <small><a href="javascript:addExcludeList(\'' + ip
+ '\')" title="Exclude from List">[Hide]</a></small>';
209 row
.cells
[cols
[j
]].innerHTML
= data
[cols
[j
]];
210 row
.style
.cursor
= 'default';
216 grid
.setup = function() {
217 this.init('grid', 'sort');
218 this.headerSet(['Proto', 'Source', 'S Port', 'Destination', 'D Port', 'UL Rate', 'DL Rate']);
221 var ref
= new TomatoRefresh('update.cgi', '', 0, 'qos_ctrate');
223 var numconntotal
= 0;
224 var numconnshown
= 0;
226 ref
.refresh = function(text
)
228 var i
, b
, d
, cols
, j
;
243 grid
.lastClicked
= null;
244 grid
.removeAllData();
255 for (i
= 0; i
< ctrate
.length
; ++i
) {
260 if (E('_f_excludegw').checked
) {
261 if ((b
[1] == nvram
.lan_ipaddr
) || (b
[2] == nvram
.lan_ipaddr
) ||
262 (b
[1] == nvram
.lan1_ipaddr
) || (b
[2] == nvram
.lan1_ipaddr
) ||
263 (b
[1] == nvram
.lan2_ipaddr
) || (b
[2] == nvram
.lan2_ipaddr
) ||
264 (b
[1] == nvram
.lan3_ipaddr
) || (b
[2] == nvram
.lan3_ipaddr
) ||
265 (b
[1] == '127.0.0.1') || (b
[2] == '127.0.0.1') ) {
270 if (E('_f_excludebcast').checked
) {
271 if ((b
[2] == getBroadcastAddress(getNetworkAddress(nvram
.lan_ipaddr
,nvram
.lan_netmask
),nvram
.lan_netmask
)) ||
272 (b
[2] == getBroadcastAddress(getNetworkAddress(nvram
.lan1_ipaddr
,nvram
.lan1_netmask
),nvram
.lan1_netmask
)) ||
273 (b
[2] == getBroadcastAddress(getNetworkAddress(nvram
.lan2_ipaddr
,nvram
.lan2_netmask
),nvram
.lan2_netmask
)) ||
274 (b
[2] == getBroadcastAddress(getNetworkAddress(nvram
.lan3_ipaddr
,nvram
.lan3_netmask
),nvram
.lan3_netmask
)) ||
275 (b
[2] == '255.255.255.255') || (b
[2] == '0.0.0.0') ) {
280 if (E('_f_excludemcast').checked
) {
281 var mmin
= 3758096384; // aton('224.0.0.0') == 3758096384
282 var mmax
= 4026531839; // aton('239.255.255.255') == 4026531839
283 if (((aton(b
[1]) >= mmin
) && (aton(b
[1]) <= mmax
)) ||
284 ((aton(b
[2]) >= mmin
) && (aton(b
[2]) <= mmax
))) {
289 if (filteripe
.length
>0) {
291 for (x
= 0; x
< filteripe
.length
; ++x
) {
292 if ((b
[1] == filteripe
[x
]) || (b
[2] == filteripe
[x
])) {
297 if (fskip
== 1) continue;
300 if (filterip
.length
>0) {
302 for (x
= 0; x
< filterip
.length
; ++x
) {
303 if ((b
[1] == filterip
[x
]) || (b
[2] == filterip
[x
])) {
308 if (fskip
== 1) continue;
311 for (j
= cols
.length
-1; j
>= 0; j
--) {
313 if (cache
[ip
] != null) {
315 b
[cols
[j
]] = cache
[ip
] + ((ip
.indexOf(':') != -1) ? '<br>' : ' ') + '<small>(' + ip
+ ')</small>';
327 if (E('_f_shortcuts').checked
) {
328 if (cache
[ip
] == null) {
329 b
[cols
[j
]] = b
[cols
[j
]] + ' <small><a href="javascript:addToResolveQueue(\'' + ip
+ '\')" title="Resolve the hostname of this address">[resolve]</a></small>';
331 b
[cols
[j
]] = b
[cols
[j
]] + ' <small><a href="javascript:addExcludeList(\'' + ip
+ '\')" title="Filter out this IP">[hide]</a></small>';
336 d
= [protocols
[b
[0]] || b
[0], b
[1], b
[3], b
[2], b
[4], b
[5], b
[6]];
337 var row
= grid
.insertData(-1, d
);
338 if (cursor
) row
.style
.cursor
= cursor
;
345 setTimeout(function() { E('loading').style
.visibility
= 'hidden'; }, 100);
349 if (resolveCB
) resolve();
351 if (numconnshown
!= numconntotal
)
352 E('numtotalconn').innerHTML
='<small><i>(showing ' + numconnshown
+ ' out of ' + numconntotal
+ ' connections)</i></small>';
354 E('numtotalconn').innerHTML
='<small><i>(' + numconntotal
+ ' connections)</i></small>';
357 function addExcludeList(address
) {
358 if (E('_f_filter_ipe').value
.length
<6) {
359 E('_f_filter_ipe').value
= address
;
361 if (E('_f_filter_ipe').value
.indexOf(address
) < 0) {
362 E('_f_filter_ipe').value
= E('_f_filter_ipe').value
+ ',' + address
;
368 function addToResolveQueue(ip
) {
377 if ((c
= cookie
.get('qos_filterip')) != null) {
378 cookie
.set('qos_filterip', '', 0);
380 E('_f_filter_ip').value
= c
;
381 filterip
= c
.split(',');
385 if (((c
= cookie
.get('qos_ctr_resolve')) != null) && (c
== '1')) {
386 E('_f_autoresolve').checked
= resolveCB
= 1;
389 if (((c
= cookie
.get('qos_ctr_bcast')) != null) && (c
== '1')) {
390 E('_f_excludebcast').checked
= bcastCB
= 1;
393 if (((c
= cookie
.get('qos_ctr_mcast')) != null) && (c
== '1')) {
394 E('_f_excludemcast').checked
= mcastCB
= 1;
397 if (((c
= cookie
.get('qos_ctr_filters_vis')) != null) && (c
== '1')) {
398 toggleVisibility("filters");
401 if ((thres
= cookie
.get('qos_ctr_thres')) == null || isNaN(thres
*= 1)) {
405 E('_f_shortcuts').checked
= (((c
= cookie
.get('qos_ctr_shortcuts')) != null) && (c
== '1'));
407 E('_f_excludebythreshold').checked
= (thres
!= 0);
409 ref
.postData
= 'exec=ctrate&arg0=' + readDelay
+ '&arg1=' + thres
;
412 if (!ref
.running
) ref
.once
= 1;
416 function dofilter() {
417 if (E('_f_filter_ip').value
.length
>6) {
418 filterip
= E('_f_filter_ip').value
.split(',');
423 if (E('_f_filter_ipe').value
.length
>6) {
424 filteripe
= E('_f_filter_ipe').value
.split(',');
433 function toggleVisibility(whichone
) {
434 if(E('sesdiv' + whichone
).style
.display
=='') {
435 E('sesdiv' + whichone
).style
.display
='none';
436 E('sesdiv' + whichone
+ 'showhide').innerHTML
='(Click here to show)';
437 cookie
.set('qos_ctr_' + whichone
+ '_vis', 0);
439 E('sesdiv' + whichone
).style
.display
='';
440 E('sesdiv' + whichone
+ 'showhide').innerHTML
='(Click here to hide)';
441 cookie
.set('qos_ctr_' + whichone
+ '_vis', 1);
445 function verifyFields(focused
, quiet
) {
448 b
= E('_f_excludebcast').checked
? 1 : 0;
451 cookie
.set('qos_ctr_bcast', b
);
454 b
= E('_f_excludemcast').checked
? 1 : 0;
457 cookie
.set('qos_ctr_mcast', b
);
460 cookie
.set('qos_ctr_shortcuts', (E('_f_shortcuts').checked
? '1' : '0'), 1);
470 <body onload='init()'
>
471 <form id='_fom' action='javascript:{}'
>
472 <table id='container' cellspacing=
0>
473 <tr><td colspan=
2 id='header'
>
474 <div class='title'
>Tomato
</div>
475 <div class='version'
>Version <%
version(); %></div>
477 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
479 <div id='ident'
><%
ident(); %></div>
483 <div class='section-title' id='stitle' onclick='document.
location=
"qos-graphs.asp"' style='cursor:pointer'
>Transfer Rates
<span id='numtotalconn'
></span></div>
484 <div class='section'
>
485 <table id='grid' class='tomato-grid'
style=
"float:left" cellspacing=
1></table>
487 <div id='loading'
><br><b>Loading...
</b></div>
492 <div class='section-title'
>Filters
<small><i><a href='javascript:toggleVisibility(
"filters");'
><span id='sesdivfiltersshowhide'
>(Click here to show)
</span></a></i></small></div>
493 <div class='section' id='sesdivfilters' style='display:none'
>
494 <script type='text/javascript'
>
497 c
.push({ title
: 'Only these IPs', name
: 'f_filter_ip', size
: 50, maxlen
: 255, type
: 'text', suffix
: ' <small>(Comma separated list)</small>' });
498 c
.push({ title
: 'Exclude these IPs', name
: 'f_filter_ipe', size
: 50, maxlen
: 255, type
: 'text', suffix
: ' <small>(Comma separated list)</small>' });
499 c
.push({ title
: 'Exclude gateway traffic', name
: 'f_excludegw', type
: 'checkbox', value
: ((nvram
.t_hidelr
) == '1' ? 1 : 0) });
500 c
.push({ title
: 'Exclude IPv4 broadcast', name
: 'f_excludebcast', type
: 'checkbox' });
501 c
.push({ title
: 'Exclude IPv4 multicast', name
: 'f_excludemcast', type
: 'checkbox' });
502 c
.push({ title
: 'Ignore inactive connections', name
: 'f_excludebythreshold', type
: 'checkbox' });
503 c
.push({ title
: 'Auto resolve addresses', name
: 'f_autoresolve', type
: 'checkbox' });
504 c
.push({ title
: 'Show shortcuts', name
: 'f_shortcuts', type
: 'checkbox' });
505 createFieldTable('',c
);
512 <tr><td id='footer' colspan=
2>
513 <script type='text/javascript'
>genStdRefresh(1,1,'ref.toggle()');</script>