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/Connection Details 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 Details
</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'
>
37 <script type='text/javascript' src='debug.js'
></script>
38 <script type='text/javascript' src='protocols.js'
></script>
39 <script type='text/javascript' src='interfaces.js'
></script>
41 <script type='text/javascript'
>
43 // <% nvram('qos_classnames,lan_ipaddr,lan1_ipaddr,lan2_ipaddr,lan3_ipaddr,lan_netmask,lan1_netmask,lan2_netmask,lan3_netmask,t_hidelr'); %>
45 var Unclassified
= ['Unclassified'];
46 var classNames
= nvram
.qos_classnames
.split(' '); //Toastman Class Labels
47 var abc
= Unclassified
.concat(classNames
);
49 var colors
= ['F08080','E6E6FA','0066CC','8FBC8F','FAFAD2','ADD8E6','9ACD32','E0FFFF','90EE90','FF9933','FFF0F5'];
53 if ((viewClass
= '<% cgi_get("class"); %>') == '') {
56 else if ((isNaN(viewClass
*= 1)) || (viewClass
< 0) || (viewClass
> 10)) {
67 if ((queue
.length
== 0) || (xob
)) return;
70 xob
.onCompleted = function(text
, xml
) {
72 for (var i
= 0; i
< resolve_data
.length
; ++i
) {
73 var r
= resolve_data
[i
];
74 if (r
[1] == '') r
[1] = r
[0];
76 if (lock
== 0) grid
.setName(r
[0], r
[1]);
78 if (queue
.length
== 0) {
79 if ((lock
== 0) && (resolveCB
) && (grid
.sortColumn
== 4)) grid
.resort();
81 else setTimeout(resolve
, 500);
84 xob
.onError = function(ex
) {
88 xob
.post('resolve.cgi', 'ip=' + queue
.splice(0, 20).join(','));
95 function resolveChanged()
99 b
= E('_f_autoresolve').checked
? 1 : 0;
100 if (b
!= resolveCB
) {
102 cookie
.set('qos_resolve', b
);
104 if (b
) grid
.resolveAll();
107 var grid
= new TomatoGrid();
109 grid
.dataToView = function(data
) {
111 for (var col
= 0; col
< data
.length
; ++col
) {
114 s
= abc
[data
[col
]] || ('' + data
[col
]);
117 s
= (data
[col
] * 1 > 0) ? ('' + data
[col
]) : '';
121 s
= scaleSize(data
[col
] * 1);
132 grid
.sortCompare = function(a
, b
) {
134 var col
= obj
.sortColumn
;
135 var da
= a
.getRowData();
136 var db
= b
.getRowData();
145 r
= cmpInt(da
[col
], db
[col
]);
148 r
= cmpInt(da
[col
] ? da
[col
] : 10000, db
[col
] ? db
[col
] : 10000);
152 var a
= fixIP(da
[col
]);
153 var b
= fixIP(db
[col
]);
154 if ((a
!= null) && (b
!= null)) {
155 r
= aton(a
) - aton(b
);
159 r
= cmpText(da
[col
], db
[col
]);
162 return obj
.sortAscending
? r
: -r
;
165 grid
.onClick = function(cell
) {
167 var ip
= row
.getRowData()[3];
168 if (this.lastClicked
!= row
) {
169 this.lastClicked
= row
;
170 if (ip
.indexOf('<') == -1) {
172 row
.style
.cursor
= 'wait';
181 grid
.resolveAll = function()
183 var i
, ip
, row
, q
, cols
, j
;
187 for (i
= 1; i
< this.tb
.rows
.length
; ++i
) {
188 row
= this.tb
.rows
[i
];
189 for (j
= cols
.length
-1; j
>= 0; j
--) {
190 ip
= row
.getRowData()[cols
[j
]];
191 if (ip
.indexOf('<') == -1) {
196 row
.style
.cursor
= 'wait';
204 grid
.setName = function(ip
, name
) {
205 var i
, row
, data
, cols
, j
;
208 for (i
= this.tb
.rows
.length
- 1; i
> 0; --i
) {
209 row
= this.tb
.rows
[i
];
210 data
= row
.getRowData();
211 for (j
= cols
.length
-1; j
>= 0; j
--) {
212 if (data
[cols
[j
]] == ip
) {
213 data
[cols
[j
]] = name
+ ((ip
.indexOf(':') != -1) ? '<br>' : ' ') + '<small>(' + ip
+ ')</small>';
214 row
.setRowData(data
);
215 if (E('_f_shortcuts').checked
)
216 data
[cols
[j
]] = data
[cols
[j
]] + ' <small><a href="javascript:addExcludeList(\'' + ip
+ '\')" title="Exclude from List">[Hide]</a></small>';
217 row
.cells
[cols
[j
]].innerHTML
= data
[cols
[j
]];
218 row
.style
.cursor
= 'default';
224 grid
.setup = function() {
225 this.init('grid', 'sort');
226 this.headerSet(['Proto', 'Source', 'S Port', 'Destination', 'D Port', 'Class', 'Rule', 'Bytes Out', 'Bytes In']);
229 var ref
= new TomatoRefresh('update.cgi', '', 0, 'qos_detailed');
231 var numconntotal
= 0;
232 var numconnshown
= 0;
234 ref
.refresh = function(text
) {
235 var i
, b
, d
, cols
, j
;
250 grid
.lastClicked
= null;
251 grid
.removeAllData();
262 for (i
= 0; i
< ctdump
.length
; ++i
) {
267 if (E('_f_excludegw').checked
) {
268 if ((b
[2] == nvram
.lan_ipaddr
) || (b
[3] == nvram
.lan_ipaddr
) ||
269 (b
[2] == nvram
.lan1_ipaddr
) || (b
[3] == nvram
.lan1_ipaddr
) ||
270 (b
[2] == nvram
.lan2_ipaddr
) || (b
[3] == nvram
.lan2_ipaddr
) ||
271 (b
[2] == nvram
.lan3_ipaddr
) || (b
[3] == nvram
.lan3_ipaddr
) ||
272 (b
[2] == '127.0.0.1') || (b
[3] == '127.0.0.1')) {
277 if (E('_f_excludebcast').checked
) {
278 if ((b
[3] == getBroadcastAddress(getNetworkAddress(nvram
.lan_ipaddr
,nvram
.lan_netmask
),nvram
.lan_netmask
)) ||
279 (b
[3] == getBroadcastAddress(getNetworkAddress(nvram
.lan1_ipaddr
,nvram
.lan1_netmask
),nvram
.lan1_netmask
)) ||
280 (b
[3] == getBroadcastAddress(getNetworkAddress(nvram
.lan2_ipaddr
,nvram
.lan2_netmask
),nvram
.lan2_netmask
)) ||
281 (b
[3] == getBroadcastAddress(getNetworkAddress(nvram
.lan3_ipaddr
,nvram
.lan3_netmask
),nvram
.lan3_netmask
)) ||
282 (b
[3] == '255.255.255.255') || (b
[3] == '0.0.0.0')) {
287 if (E('_f_excludemcast').checked
) {
288 var mmin
= 3758096384; // aton('224.0.0.0')
289 var mmax
= 4026531839; // aton('239.255.255.255')
290 if (((aton(b
[2]) >= mmin
) && (aton(b
[2]) <= mmax
)) ||
291 ((aton(b
[3]) >= mmin
) && (aton(b
[3]) <= mmax
))) {
296 if (filteripe
.length
>0) {
298 for (x
= 0; x
< filteripe
.length
; ++x
) {
299 if ((b
[2] == filteripe
[x
]) || (b
[3] == filteripe
[x
])) {
304 if (fskip
== 1) continue;
307 if (filterip
.length
>0) {
309 for (x
= 0; x
< filterip
.length
; ++x
) {
310 if ((b
[2] == filterip
[x
]) || (b
[3] == filterip
[x
])) {
315 if (fskip
== 1) continue;
318 for (j
= cols
.length
-1; j
>= 0; j
--) {
320 if (cache
[ip
] != null) {
322 b
[cols
[j
]] = cache
[ip
] + ((ip
.indexOf(':') != -1) ? '<br>' : ' ') + '<small>(' + ip
+ ')</small>';
335 if (E('_f_shortcuts').checked
) {
336 if (cache
[ip
] == null) {
337 b
[cols
[j
]] = b
[cols
[j
]] + ' <small><a href="javascript:addToResolveQueue(\'' + ip
+ '\')" title="Resolve the hostname of this address">[resolve]</a></small>';
339 b
[cols
[j
]] = b
[cols
[j
]] + ' <small><a href="javascript:addExcludeList(\'' + ip
+ '\')" title="Filter out this IP">[hide]</a></small>';
344 d
= [protocols
[b
[0]] || b
[0], b
[2], b
[4], b
[3], b
[5], b
[8], b
[9], b
[6], b
[7]];
345 var row
= grid
.insertData(-1, d
);
346 if (cursor
) row
.style
.cursor
= cursor
;
353 setTimeout(function() { E('loading').style
.visibility
= 'hidden'; }, 100);
357 if (resolveCB
) resolve();
358 if (numconnshown
!= numconntotal
)
359 E('numtotalconn').innerHTML
='<small><i>(showing ' + numconnshown
+ ' out of ' + numconntotal
+ ' connections)</i></small>';
361 E('numtotalconn').innerHTML
='<small><i>(' + numconntotal
+ ' connections)</i></small>';
364 function addExcludeList(address
) {
365 if (E('_f_filter_ipe').value
.length
<6) {
366 E('_f_filter_ipe').value
= address
;
368 if (E('_f_filter_ipe').value
.indexOf(address
) < 0) {
369 E('_f_filter_ipe').value
= E('_f_filter_ipe').value
+ ',' + address
;
375 function addToResolveQueue(ip
) {
383 if ((c
= cookie
.get('qos_filterip')) != null) {
384 cookie
.set('qos_filterip', '', 0);
386 E('_f_filter_ip').value
= c
;
387 filterip
= c
.split(',');
391 if (((c
= cookie
.get('qos_resolve')) != null) && (c
== '1')) {
392 E('_f_autoresolve').checked
= resolveCB
= 1;
395 if (((c
= cookie
.get('qos_bcast')) != null) && (c
== '1')) {
396 E('_f_excludebcast').checked
= bcastCB
= 1;
399 if (((c
= cookie
.get('qos_mcast')) != null) && (c
== '1')) {
400 E('_f_excludemcast').checked
= mcastCB
= 1;
403 if (((c
= cookie
.get('qos_details_filters_vis')) != null) && (c
== '1')) {
404 toggleVisibility("filters");
407 if (viewClass
!= -1) E('stitle').innerHTML
= 'Details: ' + abc
[viewClass
] + ' <span id=\'numtotalconn\'></span>';
409 E('_f_shortcuts').checked
= (((c
= cookie
.get('qos_detailed_shortcuts')) != null) && (c
== '1'));
412 ref
.postData
= 'exec=ctdump&arg0=' + viewClass
;
415 if (!ref
.running
) ref
.once
= 1;
419 function dofilter() {
420 if (E('_f_filter_ip').value
.length
>6) {
421 filterip
= E('_f_filter_ip').value
.split(',');
426 if (E('_f_filter_ipe').value
.length
>6) {
427 filteripe
= E('_f_filter_ipe').value
.split(',');
432 if (!ref
.running
) ref
.once
= 1;
436 function toggleVisibility(whichone
) {
437 if(E('sesdiv' + whichone
).style
.display
=='') {
438 E('sesdiv' + whichone
).style
.display
='none';
439 E('sesdiv' + whichone
+ 'showhide').innerHTML
='(Click here to show)';
440 cookie
.set('qos_details_' + whichone
+ '_vis', 0);
442 E('sesdiv' + whichone
).style
.display
='';
443 E('sesdiv' + whichone
+ 'showhide').innerHTML
='(Click here to hide)';
444 cookie
.set('qos_details_' + whichone
+ '_vis', 1);
448 function verifyFields(focused
, quiet
)
452 b
= E('_f_excludebcast').checked
? 1 : 0;
455 cookie
.set('qos_bcast', b
);
458 b
= E('_f_excludemcast').checked
? 1 : 0;
461 cookie
.set('qos_mcast', b
);
464 cookie
.set('qos_detailed_shortcuts', (E('_f_shortcuts').checked
? '1' : '0'), 1);
473 <body onload='init()'
>
474 <form id='_fom' action='javascript:{}'
>
475 <table id='container' cellspacing=
0>
476 <tr><td colspan=
2 id='header'
>
477 <div class='title'
>Tomato
</div>
478 <div class='version'
>Version <%
version(); %></div>
480 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
482 <div id='ident'
><%
ident(); %></div>
486 <div class='section-title' id='stitle' onclick='document.
location=
"qos-graphs.asp"' style='cursor:pointer'
>Details
<span id='numtotalconn'
></span></div>
487 <div class='section'
>
488 <table id='grid' class='tomato-grid'
style=
"float:left" cellspacing=
1></table>
490 <div id='loading'
><br><b>Loading...
</b></div>
495 <div class='section-title'
>Filters
<small><i><a href='javascript:toggleVisibility(
"filters");'
><span id='sesdivfiltersshowhide'
>(Click here to show)
</span></a></i></small></div>
496 <div class='section' id='sesdivfilters' style='display:none'
>
497 <script type='text/javascript'
>
500 c
.push({ title
: 'Show only these IPs', name
: 'f_filter_ip', size
: 50, maxlen
: 255, type
: 'text', suffix
: ' <small>(Comma separated list)</small>' });
501 c
.push({ title
: 'Exclude these IPs', name
: 'f_filter_ipe', size
: 50, maxlen
: 255, type
: 'text', suffix
: ' <small>(Comma separated list)</small>' });
502 c
.push({ title
: 'Exclude gateway traffic', name
: 'f_excludegw', type
: 'checkbox', value
: ((nvram
.t_hidelr
) == '1' ? 1 : 0) });
503 c
.push({ title
: 'Exclude IPv4 broadcast', name
: 'f_excludebcast', type
: 'checkbox' });
504 c
.push({ title
: 'Exclude IPv4 multicast', name
: 'f_excludemcast', type
: 'checkbox' });
505 c
.push({ title
: 'Auto resolve addresses', name
: 'f_autoresolve', type
: 'checkbox' });
506 c
.push({ title
: 'Show shortcuts', name
: 'f_shortcuts', type
: 'checkbox' });
507 createFieldTable('',c
);
514 <tr><td id='footer' colspan=
2>
515 <script type='text/javascript'
>genStdRefresh(1,1,'ref.toggle()');</script>