From 3e59c78f30e8e7ac164dd62721b3fdf4ee69f1bc Mon Sep 17 00:00:00 2001 From: Augusto Bott Date: Sat, 27 Aug 2011 00:29:14 -0300 Subject: [PATCH] Latest updates from Teaman-IPTraffic cstats fixes, improvements on IP Traffic and QoS pages * cstats: since cstats can keep track IP traffic for a limited number of addresses on its database, when an address is added to the "Excluded IPs" list (admin-iptraffic.asp), its traffic history gets purged (makes room for another/new address to be tracked). * IP Traffic: previously, the "Details" page (renamed to "Transfer Rates") used different conntrack files under /proc for K24 and K26 builds, in an attempt to consider any/all IPv4 + IPv6 connections known to the router. This version sticks to IPv4-only until we figure out how to properly do that. * IP Traffic: added a "Monthly" history page, many visual improvements, added "helper" links/shortcuts from/to IP Traffic and QoS pages. --- release/src/router/cstats/cstats.c | 22 ++-- release/src/router/httpd/bwm.c | 13 ++- release/src/router/www/bwm-common.js | 9 +- release/src/router/www/bwm-hist.js | 13 +++ release/src/router/www/ipt-24.asp | 43 ++++---- .../router/www/{ipt-history.asp => ipt-daily.asp} | 67 ++++++++---- release/src/router/www/ipt-details.asp | 43 ++++---- .../www/{ipt-history.asp => ipt-monthly.asp} | 119 +++++++++++++-------- release/src/router/www/qos-ctrate.asp | 34 +++++- release/src/router/www/qos-detailed.asp | 39 +++++-- release/src/router/www/tomato.js | 6 +- 11 files changed, 279 insertions(+), 129 deletions(-) copy release/src/router/www/{ipt-history.asp => ipt-daily.asp} (80%) rename release/src/router/www/{ipt-history.asp => ipt-monthly.asp} (69%) diff --git a/release/src/router/cstats/cstats.c b/release/src/router/cstats/cstats.c index 125ae056b7..bbcc62c660 100644 --- a/release/src/router/cstats/cstats.c +++ b/release/src/router/cstats/cstats.c @@ -42,6 +42,7 @@ // #ifdef DEBUG_NOISY // #define _dprintf(args...) cprintf(args) +// #define _dprintf(args...) printf(args) // #else // #define _dprintf(args...) do { } while (0) // #endif @@ -521,6 +522,7 @@ static void save_datajs(FILE *f, int mode) p = history.dailyp[i]; max = MAX_NDAILY; } + else { data = history.monthly[i]; p = history.monthlyp[i]; @@ -745,7 +747,6 @@ static void calc(void) bump(history.daily[i], &history.dailyp[i], MAX_NDAILY, (tms->tm_year << 16) | ((uint32_t)tms->tm_mon << 8) | tms->tm_mday, counter); - // _dprintf("%s: calling bump i=%d %s total #%d history.monthlyp=%d\n", __FUNCTION__, i, ipaddr, history.howmany, history.monthlyp); n = nvram_get_int("cstats_offset"); if ((n < 1) || (n > 31)) n = 1; @@ -777,6 +778,18 @@ static void calc(void) } } + for (i = 0; i < history.howmany; ++i) { + if ((find_word(exclude, history.ipaddr[i]))) { + --history.howmany; + _dprintf("%s: #%d removing %s > excluded\n", __FUNCTION__, i, history.ipaddr[i]); + memcpy(history.ipaddr[i], history.ipaddr[i+1], (history.howmany - i) * sizeof(history.ipaddr[0])); + memcpy(history.daily[i], history.daily[i+1], (history.howmany - i) * sizeof(history.daily[0])); + history.dailyp[i] = history.dailyp[i+1]; + memcpy(history.monthly[i], history.monthly[i+1], (history.howmany - i) * sizeof(history.monthly[0])); + history.monthlyp[i] = history.monthlyp[i+1]; + } + } + // todo: total > user if (uptime >= save_utime) { save(0); @@ -785,9 +798,7 @@ static void calc(void) } } - -static void sig_handler(int sig) -{ +static void sig_handler(int sig) { switch (sig) { case SIGTERM: case SIGINT: @@ -805,8 +816,7 @@ static void sig_handler(int sig) } } -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { struct sigaction sa; long z; int new; diff --git a/release/src/router/httpd/bwm.c b/release/src/router/httpd/bwm.c index 7f56624295..d34a801192 100644 --- a/release/src/router/httpd/bwm.c +++ b/release/src/router/httpd/bwm.c @@ -184,7 +184,7 @@ void wo_bwmrestore(char *url) void wo_iptrestore(char *url) { if (rboot) { - redirect("/ipt-history.asp"); + redirect("/ipt-daily.asp"); } else { parse_asp("error.asp"); @@ -356,11 +356,14 @@ void asp_iptraffic(int argc, char **argv) { unsigned long tp_icmp, rp_icmp; unsigned long ct_tcp, ct_udp; -#if defined(TCONFIG_IPV6) && defined(LINUX26) - const char conntrack[] = "/proc/net/nf_conntrack"; -#else + +// needs extra tweaks in the code before this works as it should +// so we'll stick to IPv4-only for now... +// #if defined(TCONFIG_IPV6) && defined(LINUX26) +// const char conntrack[] = "/proc/net/nf_conntrack"; +// #else const char conntrack[] = "/proc/net/ip_conntrack"; -#endif +// #endif if ((b = fopen(conntrack, "r")) == NULL) return; diff --git a/release/src/router/www/bwm-common.js b/release/src/router/www/bwm-common.js index 41018ee0df..fc7c90f5c5 100644 --- a/release/src/router/www/bwm-common.js +++ b/release/src/router/www/bwm-common.js @@ -213,7 +213,9 @@ function loadData() t = hostnamecache[i] + ' (' + i + ')'; } else if (wl_ifidx(i) >= 0) { +/* REMOVE-BEGIN // else if (i == nvram.wl_ifname) { +REMOVE-END */ t = 'WL (' + i + ')'; } else if ((nvram.wan_proto == 'pptp') || (nvram.wan_proto == 'pppoe') || (nvram.wan_proto == 'l2tp')) { @@ -269,7 +271,7 @@ function initCommon(defAvg, defDrawMode, defDrawColor) if (nvram['rstats_colors'] != null) var c = nvram.rstats_colors.split(','); - else + else if (nvram['cstats_colors'] != null) var c = nvram.cstats_colors.split(','); while (c.length >= 3) { c[0] = escapeHTML(c[0]); @@ -329,7 +331,10 @@ function populateCache() { } REMOVE-END */ - if (dhcpd_lease != null ) { +/* REMOVE-BEGIN +// if (dhcpd_lease != null ) { +REMOVE-END */ + if (typeof(dhcpd_lease) != 'undefined') { for (var j=0; i'); for (var i = 0; i < s.length; ++i) { diff --git a/release/src/router/www/bwm-hist.js b/release/src/router/www/bwm-hist.js index a786ba9026..f1b4f4d293 100644 --- a/release/src/router/www/bwm-hist.js +++ b/release/src/router/www/bwm-hist.js @@ -105,6 +105,19 @@ function ymdText(yr, mo, da) return yr + '-' + (mo + 1).pad(2) + '-' + da.pad(2); } +function ymText(yr, mo) +{ + switch (dateFormat) { + case 1: + return (mo + 1).pad(2) + '-' + yr; + case 2: + return months[mo] + ', ' + yr; + case 3: + return (mo + 1).pad(2) + '.' + yr; + } + return yr + '-' + (mo + 1).pad(2); +} + function changeDate(e, c) { dateFormat = e.value * 1; diff --git a/release/src/router/www/ipt-24.asp b/release/src/router/www/ipt-24.asp index b4f7947c46..cb66f8e7e7 100644 --- a/release/src/router/www/ipt-24.asp +++ b/release/src/router/www/ipt-24.asp @@ -46,6 +46,7 @@ ul.tabs a, + diff --git a/release/src/router/www/ipt-history.asp b/release/src/router/www/ipt-daily.asp similarity index 80% copy from release/src/router/www/ipt-history.asp copy to release/src/router/www/ipt-daily.asp index 79e01d09c0..4195044ca4 100644 --- a/release/src/router/www/ipt-history.asp +++ b/release/src/router/www/ipt-daily.asp @@ -15,7 +15,7 @@ -[<% ident(); %>] IP Traffic: History +[<% ident(); %>] IP Traffic: Daily History <% css(); %> @@ -61,14 +61,12 @@ var dateFormat = -1; var scale = -1; -function genData() -{ - var w, i, h, t, q; +function genData() { + var w, i, h, t; w = window.open('', 'tomato_ipt_data_d'); w.document.writeln('
');
 	for (i = 0; i < daily_history.length; ++i) {
-		q = (dateFormat==2) ? '"' : '';
 		h = daily_history[i];
 		t = getYMD(h[0]);
 		w.document.writeln([t[0], t[1] + 1, t[2], h[1], h[2], h[3]].join(','));
@@ -77,8 +75,7 @@ function genData()
 	w.document.close();
 }
 
-function getYMD(n)
-{
+function getYMD(n) {
 	// [y,m,d]
 	return [(((n >> 16) & 0xFF) + 1900), ((n >>> 8) & 0xFF), (n & 0xFF)];
 }
@@ -104,8 +101,9 @@ function redraw() {
 			fskip=0;
 			b = daily_history[i];
 
-			if ((b[2] < 1) || (b[3] < 1))
-				continue;
+			if (E('_f_ignorezeroes').checked)
+				if ((b[2] < 1) || (b[3] < 1))
+					continue;
 
 			if (E('_f_begin_date').value.toString() != '0') {
 				if (b[0] < E('_f_begin_date').value)
@@ -178,11 +176,14 @@ function redraw() {
 					h = hostnamecache[b[1]] + ((b[1].indexOf(':') != -1) ? '
' : ' ') + '(' + b[1] + ')'; } } - h = h + '
'; - h = h + '[QoS Details]'; - h = h + '[QoS CTrates]'; - h = h + '[IPTraffic]'; - h = h + ''; + if (E('_f_shortcuts').checked) { + h = h + '
'; + h = h + '[qosdetails]'; + h = h + '[qosrates]'; + h = h + '[iptraf]'; + h = h + '[hide]'; + h = h + ''; + } var ymd = getYMD(b[0]); d = [ymdText(ymd[0], ymd[1], ymd[2]), h, rescale(b[2]), rescale(b[3]), rescale(b[2]+b[3])]; dg.insertData(-1, d); @@ -224,6 +225,17 @@ function viewIptDetail(n) { popupWindow('ipt-details.asp'); } +function addExcludeList(n) { + if (E('_f_filter_ipe').value.length<6) { + E('_f_filter_ipe').value = daily_history[n][1]; + } else { + if (E('_f_filter_ipe').value.indexOf(daily_history[n][1]) < 0) { + E('_f_filter_ipe').value = E('_f_filter_ipe').value + ',' + daily_history[n][1]; + } + } + dofilter(); +} + dg.dataToView = function(data) { return(data); } @@ -275,6 +287,8 @@ function init() { if ((c = cookie.get('ipt_filterip')) != null) { cookie.set('ipt_filterip', '', 0); if (c.length>6) { + E('_f_begin_date').value = 0; + E('_f_end_date').value = 0; E('_f_filter_ip').value = c; filterip = c.split(','); } @@ -290,6 +304,10 @@ function init() { E('_f_hostnames').checked = (((c = cookie.get('ipt_history_hostnames')) != null) && (c == '1')); + E('_f_shortcuts').checked = (((c = cookie.get('ipt_history_shortcuts')) != null) && (c == '1')); + + E('_f_ignorezeroes').checked = (((c = cookie.get('ipt_history_ignorezeroes')) != null) && (c == '1')); + if (((c = cookie.get('ipt_history_options_vis')) != null) && (c == '1')) { toggleVisibility("options"); } @@ -338,9 +356,19 @@ function verifyFields(focused, quiet) { cookie.set('ipt_history_hostnames', (E('_f_hostnames').checked ? '1' : '0'), 1); + cookie.set('ipt_history_shortcuts', (E('_f_shortcuts').checked ? '1' : '0'), 1); + + cookie.set('ipt_history_ignorezeroes', (E('_f_ignorezeroes').checked ? '1' : '0'), 1); + update_filter_dates(E('_f_begin_date')); update_filter_dates(E('_f_end_date')); + if ((E('_f_begin_date').value > E('_f_end_date').value) && ( E('_f_end_date').value != '0')) { + var tmp = E('_f_begin_date').value; + E('_f_begin_date').value = E('_f_end_date').value; + E('_f_end_date').value = tmp; + } + dofilter(); return 1; } @@ -359,7 +387,7 @@ function verifyFields(focused, quiet) { -
IP Traffic History
+
IP Traffic Daily History
@@ -371,12 +399,13 @@ var c; c = []; c.push({ title: 'List only these IPs', name: 'f_filter_ip', size: 50, maxlen: 255, type: 'text', suffix: ' (Comma separated list)' }); c.push({ title: 'Exclude these IPs', name: 'f_filter_ipe', size: 50, maxlen: 255, type: 'text', suffix: ' (Comma separated list)' }); -c.push({ title: 'Show stats by subnet', name: 'f_subnet', type: 'checkbox', suffix: ' (Not considered when calculating total traffic on last the line)' }); -c.push({ title: 'Show hostnames', name: 'f_hostnames', type: 'checkbox' }); -c.push({ title: 'Start Date', name: 'f_begin_date', type: 'select', options: [['0', 'Any']] }); -c.push({ title: 'End Date', name: 'f_end_date', type: 'select', options: [['0', 'Any']] }); +c.push({ title: 'Date Range', multi: [ { name: 'f_begin_date', type: 'select', options: [['0', 'Any']], suffix: ' - ' }, { name: 'f_end_date', type: 'select', options: [['0', 'Any']] } ] } ); c.push({ title: 'Date Format', name: 'f_dafm', type: 'select', options: [['0', 'yyyy-mm-dd'], ['1', 'mm-dd-yyyy'], ['2', 'mmm dd, yyyy'], ['3', 'dd.mm.yyyy']] }); c.push({ title: 'Scale', name: 'f_scale', type: 'select', options: [['0', 'KB'], ['1', 'MB'], ['2', 'GB']] }); +c.push({ title: 'Show subnet totals', name: 'f_subnet', type: 'checkbox', suffix: ' (Not considered when calculating total traffic on the last line)' }); +c.push({ title: 'Hide IPs without traffic', name: 'f_ignorezeroes', type: 'checkbox' }); +c.push({ title: 'Show known hostnames', name: 'f_hostnames', type: 'checkbox' }); +c.push({ title: 'Show shortcuts', name: 'f_shortcuts', type: 'checkbox' }); createFieldTable('',c);
diff --git a/release/src/router/www/ipt-details.asp b/release/src/router/www/ipt-details.asp index 593820a8d0..b53628639c 100644 --- a/release/src/router/www/ipt-details.asp +++ b/release/src/router/www/ipt-details.asp @@ -197,11 +197,15 @@ grid.populate = function() { h = hostnamecache[b[0]] + ((b[0].indexOf(':') != -1) ? '
' : ' ') + '(' + b[0] + ')'; } } - h = h + '
'; - h = h + '[QoS Details]'; - h = h + '[QoS CTrates]'; - h = h + '[IPTraffic]'; - h = h + ''; + + if (E('_f_shortcuts').checked) { + h = h + '
'; + h = h + '[qosdetails]'; + h = h + '[qosrates]'; + h = h + '[history]'; + h = h + '[hide]'; + h = h + ''; + } d = [h, rescale((b[1]/1024).toFixed(2)).toString(), @@ -227,8 +231,6 @@ grid.populate = function() { udpi.toFixed(0).toString() + '/' + udpo.toFixed(0).toString(), icmpi.toFixed(0).toString() + '/' + icmpo.toFixed(0).toString(), tcpconn.toString(), udpconn.toString() ]); -// if (E('_f_hostnames').checked) -// grid.setNames(); } function popupWindow(v) { @@ -247,21 +249,18 @@ function viewQosCTrates(n) { function viewIptHistory(n) { cookie.set('ipt_filterip', [avgiptraffic[n][0]], 1); - popupWindow('ipt-history.asp'); + popupWindow('ipt-daily.asp'); } -grid.setNames = function() { - var i, row, data; - - for (i = this.tb.rows.length - 2; i > 0; --i) { - row = this.tb.rows[i]; - data = row.getRowData(); - if(hostnamecache[data[0]] != null) { - data[0] = hostnamecache[data[0]] + ((data[0].indexOf(':') != -1) ? '
' : ' ') + '(' + data[0] + ')'; - row.setRowData(data); - row.cells[0].innerHTML = data[0]; +function addExcludeList(n) { + if (E('_f_filter_ipe').value.length<6) { + E('_f_filter_ipe').value = avgiptraffic[n][0]; + } else { + if (E('_f_filter_ipe').value.indexOf(avgiptraffic[n][0]) < 0) { + E('_f_filter_ipe').value = E('_f_filter_ipe').value + ',' + avgiptraffic[n][0]; } } + dofilter(); } grid.dataToView = function(data) { @@ -281,7 +280,6 @@ grid.setup = function() { } function init() { - if ((c = cookie.get('ipt_filterip')) != null) { cookie.set('ipt_filterip', '', 0); if (c.length>6) { @@ -301,6 +299,8 @@ function init() { E('_f_hostnames').checked = (((c = cookie.get('ipt_details_hostnames')) != null) && (c == '1')); + E('_f_shortcuts').checked = (((c = cookie.get('ipt_details_shortcuts')) != null) && (c == '1')); + populateCache(); grid.setup(); ref.postData = 'exec=iptraffic'; @@ -342,6 +342,8 @@ function verifyFields(focused, quiet) { cookie.set('ipt_details_hostnames', (E('_f_hostnames').checked ? '1' : '0'), 1); + cookie.set('ipt_details_shortcuts', (E('_f_shortcuts').checked ? '1' : '0'), 1); + dofilter(); return 1; } @@ -390,9 +392,10 @@ var c; c = []; c.push({ title: 'Only these IPs', name: 'f_filter_ip', size: 50, maxlen: 255, type: 'text', suffix: ' (Comma separated list)' }); c.push({ title: 'Exclude these IPs', name: 'f_filter_ipe', size: 50, maxlen: 255, type: 'text', suffix: ' (Comma separated list)' }); +c.push({ title: 'Scale', name: 'f_scale', type: 'select', options: [['0', 'KB'], ['1', 'MB'], ['2', 'GB']] }); c.push({ title: 'Ignore inactive hosts', name: 'f_onlyactive', type: 'checkbox' }); c.push({ title: 'Show hostnames', name: 'f_hostnames', type: 'checkbox' }); -c.push({ title: 'Scale', name: 'f_scale', type: 'select', options: [['0', 'KB'], ['1', 'MB'], ['2', 'GB']] }); +c.push({ title: 'Show shortcuts', name: 'f_shortcuts', type: 'checkbox' }); createFieldTable('',c);
diff --git a/release/src/router/www/ipt-history.asp b/release/src/router/www/ipt-monthly.asp similarity index 69% rename from release/src/router/www/ipt-history.asp rename to release/src/router/www/ipt-monthly.asp index 79e01d09c0..3d79815d60 100644 --- a/release/src/router/www/ipt-history.asp +++ b/release/src/router/www/ipt-monthly.asp @@ -15,7 +15,7 @@ -[<% ident(); %>] IP Traffic: History +[<% ident(); %>] IP Traffic: Monthly History <% css(); %> @@ -23,9 +23,9 @@ @@ -43,14 +43,14 @@ // <% devlist(); %> try { -// <% ipt_bandwidth("daily"); %> +// <% ipt_bandwidth("monthly"); %> } catch (ex) { - daily_history = []; + monthly_history = []; } cstats_busy = 0; -if (typeof(daily_history) == 'undefined') { - daily_history = []; +if (typeof(monthly_history) == 'undefined') { + monthly_history = []; cstats_busy = 1; } @@ -61,24 +61,21 @@ var dateFormat = -1; var scale = -1; -function genData() -{ - var w, i, h, t, q; +function genData() { + var w, i, h, t; w = window.open('', 'tomato_ipt_data_d'); w.document.writeln('
');
-	for (i = 0; i < daily_history.length; ++i) {
-		q = (dateFormat==2) ? '"' : '';
-		h = daily_history[i];
+	for (i = 0; i < monthly_history.length; ++i) {
+		h = monthly_history[i];
 		t = getYMD(h[0]);
-		w.document.writeln([t[0], t[1] + 1, t[2], h[1], h[2], h[3]].join(','));
+		w.document.writeln([t[0], t[1] + 1, h[1], h[2], h[3]].join(','));
 	}
 	w.document.writeln('
'); w.document.close(); } -function getYMD(n) -{ +function getYMD(n) { // [y,m,d] return [(((n >> 16) & 0xFF) + 1900), ((n >>> 8) & 0xFF), (n & 0xFF)]; } @@ -86,7 +83,7 @@ function getYMD(n) var dg = new TomatoGrid(); dg.setup = function() { - this.init('daily-grid', 'sort'); + this.init('monthly-grid', 'sort'); this.headerSet(['Date', 'Host', 'Download', 'Upload', 'Total']); } @@ -98,14 +95,15 @@ function redraw() { var hostslisted = []; var subnetslisted = []; - if (daily_history.length > 0) { + if (monthly_history.length > 0) { dg.removeAllData(); - for (i = 0; i < daily_history.length; ++i) { + for (i = 0; i < monthly_history.length; ++i) { fskip=0; - b = daily_history[i]; + b = monthly_history[i]; - if ((b[2] < 1) || (b[3] < 1)) - continue; + if (E('_f_ignorezeroes').checked) + if ((b[2] < 1) || (b[3] < 1)) + continue; if (E('_f_begin_date').value.toString() != '0') { if (b[0] < E('_f_begin_date').value) @@ -178,13 +176,16 @@ function redraw() { h = hostnamecache[b[1]] + ((b[1].indexOf(':') != -1) ? '
' : ' ') + '(' + b[1] + ')'; } } - h = h + '
'; - h = h + '[QoS Details]'; - h = h + '[QoS CTrates]'; - h = h + '[IPTraffic]'; - h = h + ''; + if (E('_f_shortcuts').checked) { + h = h + '
'; + h = h + '[qosdetails]'; + h = h + '[qosrates]'; + h = h + '[iptraf]'; + h = h + '[hide]'; + h = h + ''; + } var ymd = getYMD(b[0]); - d = [ymdText(ymd[0], ymd[1], ymd[2]), h, rescale(b[2]), rescale(b[3]), rescale(b[2]+b[3])]; + d = [ymText(ymd[0], ymd[1]), h, rescale(b[2]), rescale(b[3]), rescale(b[2]+b[3])]; dg.insertData(-1, d); } @@ -210,29 +211,40 @@ function popupWindow(v) { } function viewQosDetail(n) { - cookie.set('qos_filterip', [daily_history[n][1]], 1); + cookie.set('qos_filterip', [monthly_history[n][1]], 1); popupWindow('qos-detailed.asp'); } function viewQosCTrates(n) { - cookie.set('qos_filterip', [daily_history[n][1]], 1); + cookie.set('qos_filterip', [monthly_history[n][1]], 1); popupWindow('qos-ctrate.asp'); } function viewIptDetail(n) { - cookie.set('ipt_filterip', [daily_history[n][1]], 1); + cookie.set('ipt_filterip', [monthly_history[n][1]], 1); popupWindow('ipt-details.asp'); } +function addExcludeList(n) { + if (E('_f_filter_ipe').value.length<6) { + E('_f_filter_ipe').value = monthly_history[n][1]; + } else { + if (E('_f_filter_ipe').value.indexOf(monthly_history[n][1]) < 0) { + E('_f_filter_ipe').value = E('_f_filter_ipe').value + ',' + monthly_history[n][1]; + } + } + dofilter(); +} + dg.dataToView = function(data) { return(data); } function init_filter_dates() { var dates = []; - if (daily_history.length > 0) { - for (var i = 0; i < daily_history.length; ++i) { - dates.push('0x' + daily_history[i][0].toString(16)); + if (monthly_history.length > 0) { + for (var i = 0; i < monthly_history.length; ++i) { + dates.push('0x' + monthly_history[i][0].toString(16)); } if (dates.length > 0) { dates.sort(); @@ -248,8 +260,8 @@ function init_filter_dates() { var d = new Date(); for (var i = 0; i < dates.length; ++i) { var ymd = getYMD(dates[i]); - b.options[i+1] = new Option(ymdText(ymd[0], ymd[1], ymd[2]), dates[i], false, ((ymd[0]==d.getFullYear()) && (ymd[1]==d.getMonth()) && (ymd[2]==d.getDate()) )); - e.options[i+1] = new Option(ymdText(ymd[0], ymd[1], ymd[2]), dates[i], false, ((ymd[0]==d.getFullYear()) && (ymd[1]==d.getMonth()) && (ymd[2]==d.getDate()) )); + b.options[i+1] = new Option(ymText(ymd[0], ymd[1]), dates[i], false, ((ymd[0]==d.getFullYear()) && (ymd[1]==d.getMonth()) ) ); + e.options[i+1] = new Option(ymText(ymd[0], ymd[1]), dates[i], false, ((ymd[0]==d.getFullYear()) && (ymd[1]==d.getMonth()) ) ); } } @@ -257,7 +269,7 @@ function update_filter_dates(b) { for (var i = 0; i < b.options.length; ++i) { if(b.options[i].value.toString() != '0') { var ymd = getYMD(b.options[i].value); - b.options[i].text = ymdText(ymd[0], ymd[1], ymd[2]); + b.options[i].text = ymText(ymd[0], ymd[1]); } } } @@ -275,6 +287,8 @@ function init() { if ((c = cookie.get('ipt_filterip')) != null) { cookie.set('ipt_filterip', '', 0); if (c.length>6) { + E('_f_begin_date').value = 0; + E('_f_end_date').value = 0; E('_f_filter_ip').value = c; filterip = c.split(','); } @@ -290,6 +304,10 @@ function init() { E('_f_hostnames').checked = (((c = cookie.get('ipt_history_hostnames')) != null) && (c == '1')); + E('_f_shortcuts').checked = (((c = cookie.get('ipt_history_shortcuts')) != null) && (c == '1')); + + E('_f_ignorezeroes').checked = (((c = cookie.get('ipt_history_ignorezeroes')) != null) && (c == '1')); + if (((c = cookie.get('ipt_history_options_vis')) != null) && (c == '1')) { toggleVisibility("options"); } @@ -338,9 +356,19 @@ function verifyFields(focused, quiet) { cookie.set('ipt_history_hostnames', (E('_f_hostnames').checked ? '1' : '0'), 1); + cookie.set('ipt_history_shortcuts', (E('_f_shortcuts').checked ? '1' : '0'), 1); + + cookie.set('ipt_history_ignorezeroes', (E('_f_ignorezeroes').checked ? '1' : '0'), 1); + update_filter_dates(E('_f_begin_date')); update_filter_dates(E('_f_end_date')); + if ((E('_f_begin_date').value > E('_f_end_date').value) && ( E('_f_end_date').value != '0')) { + var tmp = E('_f_begin_date').value; + E('_f_begin_date').value = E('_f_end_date').value; + E('_f_end_date').value = tmp; + } + dofilter(); return 1; } @@ -359,9 +387,9 @@ function verifyFields(focused, quiet) { -
IP Traffic History
+
IP Traffic Monthly History
-
+
@@ -371,12 +399,13 @@ var c; c = []; c.push({ title: 'List only these IPs', name: 'f_filter_ip', size: 50, maxlen: 255, type: 'text', suffix: ' (Comma separated list)' }); c.push({ title: 'Exclude these IPs', name: 'f_filter_ipe', size: 50, maxlen: 255, type: 'text', suffix: ' (Comma separated list)' }); -c.push({ title: 'Show stats by subnet', name: 'f_subnet', type: 'checkbox', suffix: ' (Not considered when calculating total traffic on last the line)' }); -c.push({ title: 'Show hostnames', name: 'f_hostnames', type: 'checkbox' }); -c.push({ title: 'Start Date', name: 'f_begin_date', type: 'select', options: [['0', 'Any']] }); -c.push({ title: 'End Date', name: 'f_end_date', type: 'select', options: [['0', 'Any']] }); -c.push({ title: 'Date Format', name: 'f_dafm', type: 'select', options: [['0', 'yyyy-mm-dd'], ['1', 'mm-dd-yyyy'], ['2', 'mmm dd, yyyy'], ['3', 'dd.mm.yyyy']] }); +c.push({ title: 'Date Range', multi: [ { name: 'f_begin_date', type: 'select', options: [['0', 'Any']], suffix: ' - ' }, { name: 'f_end_date', type: 'select', options: [['0', 'Any']] } ] } ); +c.push({ title: 'Date Format', name: 'f_dafm', type: 'select', options: [['0', 'yyyy-mm'], ['1', 'mm-yyyy'], ['2', 'mmm, yyyy'], ['3', 'mm.yyyy']] }); c.push({ title: 'Scale', name: 'f_scale', type: 'select', options: [['0', 'KB'], ['1', 'MB'], ['2', 'GB']] }); +c.push({ title: 'Show subnet totals', name: 'f_subnet', type: 'checkbox', suffix: ' (Not considered when calculating total traffic on the last line)' }); +c.push({ title: 'Hide IPs without traffic', name: 'f_ignorezeroes', type: 'checkbox' }); +c.push({ title: 'Show known hostnames', name: 'f_hostnames', type: 'checkbox' }); +c.push({ title: 'Show shortcuts', name: 'f_shortcuts', type: 'checkbox' }); createFieldTable('',c);
diff --git a/release/src/router/www/qos-ctrate.asp b/release/src/router/www/qos-ctrate.asp index a7a2b85f52..c9eae1748b 100644 --- a/release/src/router/www/qos-ctrate.asp +++ b/release/src/router/www/qos-ctrate.asp @@ -201,9 +201,11 @@ grid.setName = function(ip, name) { row = this.tb.rows[i]; data = row.getRowData(); for (j = cols.length-1; j >= 0; j--) { - if (data[cols[j]] == ip) { + if (data[cols[j]].indexOf(ip) != -1 ) { data[cols[j]] = name + ((ip.indexOf(':') != -1) ? '
' : ' ') + '(' + ip + ')'; row.setRowData(data); + if (E('_f_shortcuts').checked) + data[cols[j]] = data[cols[j]] + ' [Hide]'; row.cells[cols[j]].innerHTML = data[cols[j]]; row.style.cursor = 'default'; } @@ -312,8 +314,7 @@ ref.refresh = function(text) c[ip] = cache[ip]; b[cols[j]] = cache[ip] + ((ip.indexOf(':') != -1) ? '
' : ' ') + '(' + ip + ')'; cursor = 'default'; - } - else { + } else { if (resolveCB) { if (!q[ip]) { q[ip] = 1; @@ -323,6 +324,12 @@ ref.refresh = function(text) } else cursor = null; } + if (E('_f_shortcuts').checked) { + if (cache[ip] == null) { + b[cols[j]] = b[cols[j]] + ' [resolve]'; + } + b[cols[j]] = b[cols[j]] + ' [hide]'; + } } numconnshown++; @@ -347,6 +354,22 @@ ref.refresh = function(text) E('numtotalconn').innerHTML='(' + numconntotal + ' connections)'; } +function addExcludeList(address) { + if (E('_f_filter_ipe').value.length<6) { + E('_f_filter_ipe').value = address; + } else { + if (E('_f_filter_ipe').value.indexOf(address) < 0) { + E('_f_filter_ipe').value = E('_f_filter_ipe').value + ',' + address; + } + } + dofilter(); +} + +function addToResolveQueue(ip) { + queue.push(ip); + resolve(); +} + function init() { var c; @@ -379,6 +402,8 @@ function init() thres = 0; } + E('_f_shortcuts').checked = (((c = cookie.get('qos_ctr_shortcuts')) != null) && (c == '1')); + E('_f_excludebythreshold').checked = (thres != 0); grid.setup(); ref.postData = 'exec=ctrate&arg0=' + readDelay + '&arg1=' + thres; @@ -432,6 +457,8 @@ function verifyFields(focused, quiet) { cookie.set('qos_ctr_mcast', b); } + cookie.set('qos_ctr_shortcuts', (E('_f_shortcuts').checked ? '1' : '0'), 1); + thresChanged(); resolveChanged(); dofilter(); @@ -474,6 +501,7 @@ c.push({ title: 'Exclude IPv4 broadcast', name: 'f_excludebcast', type: 'checkbo c.push({ title: 'Exclude IPv4 multicast', name: 'f_excludemcast', type: 'checkbox' }); c.push({ title: 'Ignore inactive connections', name: 'f_excludebythreshold', type: 'checkbox' }); c.push({ title: 'Auto resolve addresses', name: 'f_autoresolve', type: 'checkbox' }); +c.push({ title: 'Show shortcuts', name: 'f_shortcuts', type: 'checkbox' }); createFieldTable('',c);
diff --git a/release/src/router/www/qos-detailed.asp b/release/src/router/www/qos-detailed.asp index dbce2881d4..2d9a9113fa 100644 --- a/release/src/router/www/qos-detailed.asp +++ b/release/src/router/www/qos-detailed.asp @@ -205,9 +205,11 @@ grid.setName = function(ip, name) { row = this.tb.rows[i]; data = row.getRowData(); for (j = cols.length-1; j >= 0; j--) { - if (data[cols[j]] == ip) { + if (data[cols[j]].indexOf(ip) != -1 ) { data[cols[j]] = name + ((ip.indexOf(':') != -1) ? '
' : ' ') + '(' + ip + ')'; row.setRowData(data); + if (E('_f_shortcuts').checked) + data[cols[j]] = data[cols[j]] + ' [Hide]'; row.cells[cols[j]].innerHTML = data[cols[j]]; row.style.cursor = 'default'; } @@ -225,8 +227,7 @@ var ref = new TomatoRefresh('update.cgi', '', 0, 'qos_detailed'); var numconntotal = 0; var numconnshown = 0; -ref.refresh = function(text) -{ +ref.refresh = function(text) { var i, b, d, cols, j; ++lock; @@ -327,6 +328,12 @@ ref.refresh = function(text) } else cursor = null; } + if (E('_f_shortcuts').checked) { + if (cache[ip] == null) { + b[cols[j]] = b[cols[j]] + ' [resolve]'; + } + b[cols[j]] = b[cols[j]] + ' [hide]'; + } } numconnshown++; @@ -350,8 +357,23 @@ ref.refresh = function(text) E('numtotalconn').innerHTML='(' + numconntotal + ' connections)'; } -function init() -{ +function addExcludeList(address) { + if (E('_f_filter_ipe').value.length<6) { + E('_f_filter_ipe').value = address; + } else { + if (E('_f_filter_ipe').value.indexOf(address) < 0) { + E('_f_filter_ipe').value = E('_f_filter_ipe').value + ',' + address; + } + } + dofilter(); +} + +function addToResolveQueue(ip) { + queue.push(ip); + resolve(); +} + +function init() { var c; if ((c = cookie.get('qos_filterip')) != null) { @@ -379,6 +401,9 @@ function init() } if (viewClass != -1) E('stitle').innerHTML = 'Details: ' + abc[viewClass] + ' '; + + E('_f_shortcuts').checked = (((c = cookie.get('qos_detailed_shortcuts')) != null) && (c == '1')); + grid.setup(); ref.postData = 'exec=ctdump&arg0=' + viewClass; ref.initPage(250); @@ -432,6 +457,8 @@ function verifyFields(focused, quiet) cookie.set('qos_mcast', b); } + cookie.set('qos_detailed_shortcuts', (E('_f_shortcuts').checked ? '1' : '0'), 1); + dofilter(); resolveChanged(); return 1; @@ -452,7 +479,6 @@ function verifyFields(focused, quiet) -
Details
@@ -473,6 +499,7 @@ c.push({ title: 'Exclude gateway traffic', name: 'f_excludegw', type: 'checkbox' c.push({ title: 'Exclude IPv4 broadcast', name: 'f_excludebcast', type: 'checkbox' }); c.push({ title: 'Exclude IPv4 multicast', name: 'f_excludemcast', type: 'checkbox' }); c.push({ title: 'Auto resolve addresses', name: 'f_autoresolve', type: 'checkbox' }); +c.push({ title: 'Show shortcuts', name: 'f_shortcuts', type: 'checkbox' }); createFieldTable('',c);
diff --git a/release/src/router/www/tomato.js b/release/src/router/www/tomato.js index a77377fc7b..0cb7aa162d 100644 --- a/release/src/router/www/tomato.js +++ b/release/src/router/www/tomato.js @@ -2284,9 +2284,9 @@ function navi() ['IP Traffic', 'ipt', 0, [ ['Real-Time', 'realtime.asp'], ['Last 24 Hours', '24.asp'], - ['Details', 'details.asp'], - ['History', 'history.asp'] ] ], - + ['Transfer Rates', 'details.asp'], + ['Daily', 'daily.asp'], + ['Monthly', 'monthly.asp'] ] ], ['Tools', 'tools', 0, [ ['Ping', 'ping.asp'], ['Trace', 'trace.asp'], -- 2.11.4.GIT