Project

General

Profile

Download (6.96 KB) Statistics
| Branch: | Tag: | Revision:
1 0eacb3b2 Scott Ullrich
<?php
2
3
/* $Id$ */
4
/*
5
	diag_routes.php
6 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
7 0eacb3b2 Scott Ullrich
	Copyright (C) 2006 Fernando Lamos
8
	All rights reserved.
9
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12
13
	1. Redistributions of source code must retain the above copyright notice,
14
	this list of conditions and the following disclaimer.
15
16
	2. Redistributions in binary form must reproduce the above copyright
17
	notice, this list of conditions and the following disclaimer in the
18
	documentation and/or other materials provided with the distribution.
19
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
31
*/
32
33 13d193c2 Scott Ullrich
/*
34
	pfSense_BUILDER_BINARIES:	/usr/bin/netstat	
35
	pfSense_MODULE:	routing
36
*/
37 6b07c15a Matthew Grooms
##|+PRIV
38
##|*IDENT=page-diagnostics-routingtables
39
##|*NAME=Diagnostics: Routing tables page
40
##|*DESCR=Allow access to the 'Diagnostics: Routing tables' page.
41
##|*MATCH=diag_routes.php*
42
##|-PRIV
43
44 0eacb3b2 Scott Ullrich
include('guiconfig.inc');
45
46 92e8cb11 Renato Botelho
if (isset($_REQUEST['isAjax'])) {
47
	$netstat = "/usr/bin/netstat -rW";
48
	if (isset($_REQUEST['IPv6'])) {
49
		$netstat .= " -f inet6";
50
		echo "IPv6\n";
51
	} else {
52
		$netstat .= " -f inet";
53
		echo "IPv4\n";
54
	}
55
	if (!isset($_REQUEST['resolve']))
56
		$netstat .= " -n";
57
58
	if (!empty($_REQUEST['filter']))
59
		$netstat .= " | /usr/bin/sed -e '1,3d; 5,\$ { /" . escapeshellarg(htmlspecialchars($_REQUEST['filter'])) . "/!d; };'";
60
	else
61
		$netstat .= " | /usr/bin/sed -e '1,3d'";
62
63
	if (is_numeric($_REQUEST['limit']) && $_REQUEST['limit'] > 0)
64
		$netstat .= " | /usr/bin/head -n {$_REQUEST['limit']}";
65
66
	echo htmlspecialchars_decode(shell_exec($netstat));
67
68
	exit;
69
}
70
71 f8ec8de4 Renato Botelho
$pgtitle = array(gettext("Diagnostics"),gettext("Routing tables"));
72 b32dd0a6 jim-p
$shortcut_section = "routing";
73 0eacb3b2 Scott Ullrich
74
include('head.inc');
75
76
?>
77
<body link="#000000" vlink="#000000" alink="#000000">
78 92e8cb11 Renato Botelho
79 92e8dc9d Colin Fleming
<?php include("fbegin.inc"); ?>
80
81 92e8cb11 Renato Botelho
<script type="text/javascript">
82
//<![CDATA[
83
84
	function update_routes(section) {
85
		var url = "diag_routes.php";
86
		var limit = jQuery('#limit option:selected').text();
87
		var filter = jQuery('#filter').val();
88
		var params = "isAjax=true&limit=" + limit + "&filter=" + filter;
89
		if (jQuery('#resolve').is(':checked'))
90
			params += "&resolve=true";
91
		if (section == "IPv6")
92
			params += "&IPv6=true";
93
		var myAjax = new Ajax.Request(
94
			url,
95
			{
96
				method: 'post',
97
				parameters: params,
98
				onComplete: update_routes_callback
99
			});
100
	}
101
102
	function update_routes_callback(transport) {
103
		// First line contains section
104
		var responseTextArr = transport.responseText.split("\n");
105
		var section = responseTextArr.shift();
106
		var tbody = '';
107
		var field = '';
108
		var elements = 8;
109
		var tr_class = '';
110
111 92e8dc9d Colin Fleming
		var thead = '<tr><td class="listtopic" colspan="' + elements + '"><strong>' + section + '<\/strong><\/td><\/tr>' + "\n";
112 92e8cb11 Renato Botelho
		for (var i = 0; i < responseTextArr.length; i++) {
113
			if (responseTextArr[i] == "")
114
				continue;
115
			var tmp = '';
116
			if (i == 0) {
117
				tr_class = 'listhdrr';
118
				tmp += '<tr class="sortableHeaderRowIdentifier">' + "\n";
119
			} else {
120
				tr_class = 'listlr';
121
				tmp += '<tr>' + "\n";
122
			}
123
			var j = 0;
124
			var entry = responseTextArr[i].split(" ");
125
			for (var k = 0; k < entry.length; k++) {
126
				if (entry[k] == "")
127
					continue;
128
				if (i == 0 && j == (elements - 1))
129
					tr_class = 'listhdr';
130 92e8dc9d Colin Fleming
				tmp += '<td class="' + tr_class + '">' + entry[k] + '<\/td>' + "\n";
131 92e8cb11 Renato Botelho
				if (i > 0)
132
					tr_class = 'listr';
133
				j++;
134
			}
135
			// The 'Expire' field might be blank
136
			if (j == (elements - 1))
137 92e8dc9d Colin Fleming
				tmp += '<td class="listr">&nbsp;<\/td>' + "\n";
138
			tmp += '<\/tr>' + "\n";
139 92e8cb11 Renato Botelho
			if (i == 0)
140
				thead += tmp;
141
			else
142
				tbody += tmp;
143
		}
144
		jQuery('#' + section + ' > thead').html(thead);
145
		jQuery('#' + section + ' > tbody').html(tbody);
146
	}
147
148
//]]>
149
</script>
150
151
<script type="text/javascript">
152
//<![CDATA[
153
154
	function update_all_routes() {
155
		update_routes("IPv4");
156
		update_routes("IPv6");
157
	}
158
159
	jQuery(document).ready(function(){setTimeout('update_all_routes()', 5000);});
160
161
//]]>
162
</script>
163
164 0eacb3b2 Scott Ullrich
<div id="mainarea">
165
<form action="diag_routes.php" method="post">
166 92e8dc9d Colin Fleming
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6" summary="diag routes">
167 0eacb3b2 Scott Ullrich
168
<tr>
169 f8ec8de4 Renato Botelho
<td class="vncellreq" width="22%"><?=gettext("Name resolution");?></td>
170 505371be Renato Botelho
<td class="vtable" width="78%">
171 92e8dc9d Colin Fleming
<input type="checkbox" class="formfld" id="resolve" name="resolve" value="yes" <?php if ($_POST['resolve'] == 'yes') echo "checked=\"checked\""; ?> /><?=gettext("Enable");?>
172 0eacb3b2 Scott Ullrich
<br />
173 f8ec8de4 Renato Botelho
<span class="expl"><?=gettext("Enable this to attempt to resolve names when displaying the tables.");?></span>
174 505371be Renato Botelho
</td>
175 0eacb3b2 Scott Ullrich
</tr>
176
177 92e8cb11 Renato Botelho
<tr>
178
<td class="vncellreq" width="22%"><?=gettext("Number of rows");?></td>
179
<td class="vtable" width="78%">
180
<select id="limit" name="limit">
181
<?php
182
	foreach (array("10", "50", "100", "200", "500", "1000", gettext("all")) as $item) {
183 92e8dc9d Colin Fleming
		echo "<option value=\"{$item}\" " . ($item == "100" ? "selected=\"selected\"" : "") . ">{$item}</option>\n";
184 92e8cb11 Renato Botelho
	}
185
?>
186
</select>
187
<br />
188
<span class="expl"><?=gettext("Select how many rows to display.");?></span>
189
</td>
190
</tr>
191
192
<tr>
193
<td class="vncellreq" width="22%"><?=gettext("Filter expression");?></td>
194
<td class="vtable" width="78%">
195
<input type="text" class="formfld search" name="filter" id="filter" />
196
<br />
197
<span class="expl"><?=gettext("Use a regular expression to filter IP address or hostnames.");?></span>
198
</td>
199
</tr>
200
201 0eacb3b2 Scott Ullrich
<tr>
202
<td class="vncellreq" width="22%">&nbsp;</td>
203 505371be Renato Botelho
<td class="vtable" width="78%">
204 92e8cb11 Renato Botelho
<input type="button" class="formbtn" name="update" onclick="update_all_routes();" value="<?=gettext("Update"); ?>" />
205 0eacb3b2 Scott Ullrich
<br />
206
<br />
207 f122c1a3 Erik Fonnesbeck
<span class="vexpl"><span class="red"><strong><?=gettext("Note:")?></strong></span> <?=gettext("By enabling name resolution, the query should take a bit longer. You can stop it at any time by clicking the Stop button in your browser.");?></span>
208 0eacb3b2 Scott Ullrich
</td>
209
</tr>
210
211
</table>
212
</form>
213
214 92e8dc9d Colin Fleming
<table class="tabcont sortable" width="100%" cellspacing="0" cellpadding="6" border="0" id="IPv4" summary="ipv4 routes">
215 92e8cb11 Renato Botelho
	<thead>
216
		<tr><td class="listtopic"><strong>IPv4</strong></td></tr>
217
	</thead>
218
	<tbody>
219
		<tr><td class="listhdrr"><?=gettext("Gathering data, please wait...");?></td></tr>
220
	</tbody>
221
</table>
222 92e8dc9d Colin Fleming
<table class="tabcont sortable" width="100%" cellspacing="0" cellpadding="6" border="0" id="IPv6" summary="ipv6 routes">
223 92e8cb11 Renato Botelho
	<thead>
224
		<tr><td class="listtopic"><strong>IPv6</strong></td></tr>
225
	</thead>
226
	<tbody>
227
		<tr><td class="listhdrr"><?=gettext("Gathering data, please wait...");?></td></tr>
228
	</tbody>
229 0eacb3b2 Scott Ullrich
</table>
230
231
</div>
232
233
<?php
234
include('fend.inc');
235
?>
236 92e8dc9d Colin Fleming
237
</body>
238
</html>