<commit_before><%#
 Copyright 2010-2018 <NAME> <<EMAIL>>
 Licensed to the public under the Apache License 2.0.
-%>

<%+header%>

<script type="text/javascript">//<![CDATA[
	var bwxhr = new XHR();

	var G;
	var TIME  = 0;
	var UDP   = 1;
	var TCP   = 2;
	var OTHER = 3;

	var width  = 760;
	var height = 300;
	var step   = 5;

	var data_wanted = Math.floor(width / step);
	var data_fill   = 1;
	var data_stamp  = 0;

	var data_udp = [ ];
	var data_tcp = [ ];
	var data_otr = [ ];

	var line_udp;
	var line_tcp;

	var label_25;
	var label_50;
	var label_75;

	var label_udp_cur;
	var label_udp_avg;
	var label_udp_peak;

	var label_tcp_cur;
	var label_tcp_avg;
	var label_tcp_peak;

	var label_otr_cur;
	var label_otr_avg;
	var label_otr_peak;

	var label_scale;

	var conn_table;

	var dns_cache = { };


	/* wait for SVG */
	window.setTimeout(
		function() {
			var svg = document.getElementById('bwsvg');

			try {
				G = svg.getSVGDocument
					? svg.getSVGDocument() : svg.contentDocument;
			}
			catch(e) {
				G = document.embeds['bwsvg'].getSVGDocument();
			}

			if (!G)
			{
				window.setTimeout(arguments.callee, 1000);
			}
			else
			{
				/* find sizes */
				width       = svg.offsetWidth  - 2;
				height      = svg.offsetHeight - 2;
				data_wanted = Math.ceil(width / step);

				/* prefill datasets */
				for (var i = 0; i < data_wanted; i++)
				{
					data_udp[i] = 0;
					data_tcp[i] = 0;
					data_otr[i] = 0;
				}

				/* find svg elements */
				line_udp = G.getElementById('udp');
				line_tcp = G.getElementById('tcp');
				line_otr = G.getElementById('other');

				label_25 = G.getElementById('label_25');
				label_50 = G.getElementById('label_50');
				label_75 = G.getElementById('label_75');

				label_udp_cur  = document.getElementById('lb_udp_cur');
				label_udp_avg  = document.getElementById('lb_udp_avg');
				label_udp_peak = document.getElementById('lb_udp_peak');

				label_tcp_cur  = document.getElementById('lb_tcp_cur');
				label_tcp_avg  = document.getElementById('lb_tcp_avg');
				label_tcp_peak = document.getElementById('lb_tcp_peak');

				label_otr_cur  = document.getElementById('lb_otr_cur');
				label_otr_avg  = document.getElementById('lb_otr_avg');
				label_otr_peak = document.getElementById('lb_otr_peak');

				label_scale    = document.getElementById('scale');

				conn_table     = document.getElementById('connections');


				/* plot horizontal time interval lines */
				for (var i = width % (step * 60); i < width; i += step * 60)
				{
					var line = G.createElementNS('http://www.w3.org/2000/svg', 'line');
						line.setAttribute('x1', i);
						line.setAttribute('y1', 0);
						line.setAttribute('x2', i);
						line.setAttribute('y2', '100%');
						line.setAttribute('style', 'stroke:black;stroke-width:0.1');

					var text = G.createElementNS('http://www.w3.org/2000/svg', 'text');
						text.setAttribute('x', i + 5);
						text.setAttribute('y', 15);
						text.setAttribute('style', 'fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000');
						text.appendChild(G.createTextNode(Math.round((width - i) / step / 60) + 'm'));

					label_25.parentNode.appendChild(line);
					label_25.parentNode.appendChild(text);
				}

				label_scale.innerHTML = String.format('<%:(%d minute window, %d second interval)%>', data_wanted / 60, 3);

				/* render datasets, start update interval */
				XHR.poll(3, '<%=build_url("admin/status/realtime/connections_status")%>', null,
					function(x, json)
					{
						var rows = [];
						var conn = json.connections;

						var lookup_queue = [ ];

						conn.sort(function(a, b) {
							return b.bytes - a.bytes;
						});

						for (var i = 0; i < conn.length; i++)
						{
							var c  = conn[i];

							if ((c.src == '127.0.0.1' && c.dst == '127.0.0.1') ||
							    (c.src == '::1'       && c.dst == '::1'))
								continue;

							if (!dns_cache[c.src])
								lookup_queue.push(c.src);

							if (!dns_cache[c.dst])
								lookup_queue.push(c.dst);

							var src = dns_cache[c.src] || (c.layer3 == 'ipv6' ? '[' + c.src + ']' : c.src);
							var dst = dns_cache[c.dst] || (c.layer3 == 'ipv6' ? '[' + c.dst + ']' : c.dst);

							rows.push([
								c.layer3.toUpperCase(),
								c.layer4.toUpperCase(),
								src + ':' + c.sport,
								dst + ':' + c.dport,
								'%1024.2mB (%d <%:Pkts.%>)'.format(c.bytes, c.packets)
							]);
						}

						cbi_update_table(conn_table, rows, '<em><%:No information available%></em>');

						if (lookup_queue.length > 0)
							XHR.get('<%=build_url("admin/status/nameinfo")%>/' + lookup_queue.slice(0, 100).join('/'), null,
								function(x, json)
								{
									for (var addr in json)
										dns_cache[addr] = json[addr];
								}
							);


						var data = json.statistics;

						var data_max   = 0;
						var data_scale = 0;

						var data_udp_avg = 0;
						var data_tcp_avg = 0;<commit_msg>luci-mod-status: Remove port suffix where not applicable<commit_after><%#
 Copyright 2010-2018 <NAME> <<EMAIL>>
 Licensed to the public under the Apache License 2.0.
-%>

<%+header%>

<script type="text/javascript">//<![CDATA[
	var bwxhr = new XHR();

	var G;
	var TIME  = 0;
	var UDP   = 1;
	var TCP   = 2;
	var OTHER = 3;

	var width  = 760;
	var height = 300;
	var step   = 5;

	var data_wanted = Math.floor(width / step);
	var data_fill   = 1;
	var data_stamp  = 0;

	var data_udp = [ ];
	var data_tcp = [ ];
	var data_otr = [ ];

	var line_udp;
	var line_tcp;

	var label_25;
	var label_50;
	var label_75;

	var label_udp_cur;
	var label_udp_avg;
	var label_udp_peak;

	var label_tcp_cur;
	var label_tcp_avg;
	var label_tcp_peak;

	var label_otr_cur;
	var label_otr_avg;
	var label_otr_peak;

	var label_scale;

	var conn_table;

	var dns_cache = { };


	/* wait for SVG */
	window.setTimeout(
		function() {
			var svg = document.getElementById('bwsvg');

			try {
				G = svg.getSVGDocument
					? svg.getSVGDocument() : svg.contentDocument;
			}
			catch(e) {
				G = document.embeds['bwsvg'].getSVGDocument();
			}

			if (!G)
			{
				window.setTimeout(arguments.callee, 1000);
			}
			else
			{
				/* find sizes */
				width       = svg.offsetWidth  - 2;
				height      = svg.offsetHeight - 2;
				data_wanted = Math.ceil(width / step);

				/* prefill datasets */
				for (var i = 0; i < data_wanted; i++)
				{
					data_udp[i] = 0;
					data_tcp[i] = 0;
					data_otr[i] = 0;
				}

				/* find svg elements */
				line_udp = G.getElementById('udp');
				line_tcp = G.getElementById('tcp');
				line_otr = G.getElementById('other');

				label_25 = G.getElementById('label_25');
				label_50 = G.getElementById('label_50');
				label_75 = G.getElementById('label_75');

				label_udp_cur  = document.getElementById('lb_udp_cur');
				label_udp_avg  = document.getElementById('lb_udp_avg');
				label_udp_peak = document.getElementById('lb_udp_peak');

				label_tcp_cur  = document.getElementById('lb_tcp_cur');
				label_tcp_avg  = document.getElementById('lb_tcp_avg');
				label_tcp_peak = document.getElementById('lb_tcp_peak');

				label_otr_cur  = document.getElementById('lb_otr_cur');
				label_otr_avg  = document.getElementById('lb_otr_avg');
				label_otr_peak = document.getElementById('lb_otr_peak');

				label_scale    = document.getElementById('scale');

				conn_table     = document.getElementById('connections');


				/* plot horizontal time interval lines */
				for (var i = width % (step * 60); i < width; i += step * 60)
				{
					var line = G.createElementNS('http://www.w3.org/2000/svg', 'line');
						line.setAttribute('x1', i);
						line.setAttribute('y1', 0);
						line.setAttribute('x2', i);
						line.setAttribute('y2', '100%');
						line.setAttribute('style', 'stroke:black;stroke-width:0.1');

					var text = G.createElementNS('http://www.w3.org/2000/svg', 'text');
						text.setAttribute('x', i + 5);
						text.setAttribute('y', 15);
						text.setAttribute('style', 'fill:#eee; font-size:9pt; font-family:sans-serif; text-shadow:1px 1px 1px #000');
						text.appendChild(G.createTextNode(Math.round((width - i) / step / 60) + 'm'));

					label_25.parentNode.appendChild(line);
					label_25.parentNode.appendChild(text);
				}

				label_scale.innerHTML = String.format('<%:(%d minute window, %d second interval)%>', data_wanted / 60, 3);

				/* render datasets, start update interval */
				XHR.poll(3, '<%=build_url("admin/status/realtime/connections_status")%>', null,
					function(x, json)
					{
						var rows = [];
						var conn = json.connections;

						var lookup_queue = [ ];

						conn.sort(function(a, b) {
							return b.bytes - a.bytes;
						});

						for (var i = 0; i < conn.length; i++)
						{
							var c  = conn[i];

							if ((c.src == '127.0.0.1' && c.dst == '127.0.0.1') ||
							    (c.src == '::1'       && c.dst == '::1'))
								continue;

							if (!dns_cache[c.src])
								lookup_queue.push(c.src);

							if (!dns_cache[c.dst])
								lookup_queue.push(c.dst);

							var src = dns_cache[c.src] || (c.layer3 == 'ipv6' ? '[' + c.src + ']' : c.src);
							var dst = dns_cache[c.dst] || (c.layer3 == 'ipv6' ? '[' + c.dst + ']' : c.dst);

							rows.push([
								c.layer3.toUpperCase(),
								c.layer4.toUpperCase(),
								c.hasOwnProperty('sport') ? (src + ':' + c.sport) : src,
								c.hasOwnProperty('dport') ? (dst + ':' + c.dport) : dst,
								'%1024.2mB (%d <%:Pkts.%>)'.format(c.bytes, c.packets)
							]);
						}

						cbi_update_table(conn_table, rows, '<em><%:No information available%></em>');

						if (lookup_queue.length > 0)
							XHR.get('<%=build_url("admin/status/nameinfo")%>/' + lookup_queue.slice(0, 100).join('/'), null,
								function(x, json)
								{
									for (var addr in json)
										dns_cache[addr] = json[addr];
								}
							);


						var data = json.statistics;

						var data_max   = 0;
						var data_scale = 0;

						var data_udp_avg = 0;
						var data_tcp_avg = 0;
{'fraction_non_alphanumeric': 0.16447566482689413, 'fraction_numerical': 0.02609131961866533, 'mean_word_length': 2.6734242535938075, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6439489', 'n_tokens_mistral': 4795, 'n_tokens_neox': 3631, 'n_words': 711}