Project

General

Profile

Download (5.45 KB) Statistics
| Branch: | Tag: | Revision:
1 f1e01f7c Erik Fonnesbeck
<?php
2
/*
3 aaec5634 Renato Botelho
 * diag_sockets.php
4 fd9ebcd5 Stephen Beaver
 *
5 aaec5634 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 2a2396a6 Renato Botelho
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7 aaec5634 Renato Botelho
 * All rights reserved.
8 fd9ebcd5 Stephen Beaver
 *
9 aaec5634 Renato Botelho
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions are met:
11 fd9ebcd5 Stephen Beaver
 *
12 aaec5634 Renato Botelho
 * 1. Redistributions of source code must retain the above copyright notice,
13
 *    this list of conditions and the following disclaimer.
14 fd9ebcd5 Stephen Beaver
 *
15 aaec5634 Renato Botelho
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice, this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19 fd9ebcd5 Stephen Beaver
 *
20 aaec5634 Renato Botelho
 * 3. All advertising materials mentioning features or use of this software
21
 *    must display the following acknowledgment:
22
 *    "This product includes software developed by the pfSense Project
23
 *    for use in the pfSense® software distribution. (http://www.pfsense.org/).
24 fd9ebcd5 Stephen Beaver
 *
25 aaec5634 Renato Botelho
 * 4. The names "pfSense" and "pfSense Project" must not be used to
26
 *    endorse or promote products derived from this software without
27
 *    prior written permission. For written permission, please contact
28
 *    coreteam@pfsense.org.
29 fd9ebcd5 Stephen Beaver
 *
30 aaec5634 Renato Botelho
 * 5. Products derived from this software may not be called "pfSense"
31
 *    nor may "pfSense" appear in their names without prior written
32
 *    permission of the Electric Sheep Fencing, LLC.
33 fd9ebcd5 Stephen Beaver
 *
34 aaec5634 Renato Botelho
 * 6. Redistributions of any form whatsoever must retain the following
35
 *    acknowledgment:
36 0da0d43e Phil Davis
 *
37 aaec5634 Renato Botelho
 * "This product includes software developed by the pfSense Project
38
 * for use in the pfSense software distribution (http://www.pfsense.org/).
39 fd9ebcd5 Stephen Beaver
 *
40 aaec5634 Renato Botelho
 * THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
41
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
44
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51
 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 fd9ebcd5 Stephen Beaver
 */
53 f1e01f7c Erik Fonnesbeck
54
##|+PRIV
55
##|*IDENT=page-diagnostics-sockets
56 5230f468 jim-p
##|*NAME=Diagnostics: Sockets
57 f1e01f7c Erik Fonnesbeck
##|*DESCR=Allow access to the 'Diagnostics: Sockets' page.
58
##|*MATCH=diag_sockets.php*
59
##|-PRIV
60
61 6dfb6b27 Phil Davis
require_once('guiconfig.inc');
62 f1e01f7c Erik Fonnesbeck
63 699737d9 Phil Davis
$pgtitle = array(gettext("Diagnostics"), gettext("Sockets"));
64 f1e01f7c Erik Fonnesbeck
65
include('head.inc');
66
67
$showAll = isset($_GET['showAll']);
68 185b4365 Phil Davis
$showAllText = $showAll ? gettext("Show only listening sockets") : gettext("Show all socket connections");
69 f1e01f7c Erik Fonnesbeck
$showAllOption = $showAll ? "" : "?showAll";
70
71
?>
72 37676f4e jim-p
<button class="btn btn-info btn-sm" type="button" value="<?=$showAllText?>" onclick="window.location.href='diag_sockets.php<?=$showAllOption?>'">
73
	<i class="fa fa-<?= ($showAll) ? 'minus-circle' : 'plus-circle' ; ?> icon-embed-btn"></i>
74
	<?=$showAllText?>
75
</button>
76 b9a5448f Stephen Beaver
<br />
77
<br />
78 f1e01f7c Erik Fonnesbeck
79
<?php
80 5f601060 Phil Davis
	if (isset($_GET['showAll'])) {
81 f1e01f7c Erik Fonnesbeck
		$internet4 = shell_exec('sockstat -4');
82
		$internet6 = shell_exec('sockstat -6');
83
	} else {
84 b965f190 PiBa-NL
		$internet4 = shell_exec('sockstat -4l');
85
		$internet6 = shell_exec('sockstat -6l');
86 f1e01f7c Erik Fonnesbeck
	}
87 b9a5448f Stephen Beaver
88
89 f1e01f7c Erik Fonnesbeck
	foreach (array(&$internet4, &$internet6) as $tabindex => $table) {
90
		$elements = ($tabindex == 0 ? 7 : 7);
91
		$name = ($tabindex == 0 ? 'IPv4' : 'IPv6');
92
?>
93 b9a5448f Stephen Beaver
<div class="panel panel-default">
94 3d7a8696 k-paulius
	<div class="panel-heading"><h2 class="panel-title"><?=$name?> <?=gettext("System Socket Information")?></h2></div>
95 b9a5448f Stephen Beaver
	<div class="panel-body">
96 a6ff5ea1 sbeaver
		<div class="table table-responsive">
97 10fe1eb5 Stephen Beaver
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
98 a6ff5ea1 sbeaver
				<thead>
99 f1e01f7c Erik Fonnesbeck
<?php
100 a6ff5ea1 sbeaver
					foreach (explode("\n", $table) as $i => $line) {
101 947141fd Phil Davis
						if (trim($line) == "") {
102 a6ff5ea1 sbeaver
							continue;
103 947141fd Phil Davis
						}
104 a6ff5ea1 sbeaver
105
						$j = 0;
106 63ff711e Colin Fleming
						print("<tr>\n");
107 a6ff5ea1 sbeaver
						foreach (explode(' ', $line) as $entry) {
108 947141fd Phil Davis
							if ($entry == '' || $entry == "ADDRESS") {
109 b9a5448f Stephen Beaver
								continue;
110 947141fd Phil Davis
							}
111 b9a5448f Stephen Beaver
112
							if ($i == 0) {
113 a6ff5ea1 sbeaver
								print("<th class=\"$class\">$entry</th>\n");
114 947141fd Phil Davis
							} else {
115 a6ff5ea1 sbeaver
								print("<td class=\"$class\">$entry</td>\n");
116 b9a5448f Stephen Beaver
							}
117 a6ff5ea1 sbeaver
118
							$j++;
119
						}
120
						print("</tr>\n");
121 947141fd Phil Davis
						if ($i == 0) {
122 b9a5448f Stephen Beaver
							print("</thead>\n");
123
							print("<tbody>\n");
124
						}
125 a6ff5ea1 sbeaver
					}
126
?>
127
				</tbody>
128
			</table>
129
		</div>
130 b9a5448f Stephen Beaver
	</div>
131
</div>
132 f1e01f7c Erik Fonnesbeck
<?php
133 f1dab9ec sbeaver
	}
134 f1e01f7c Erik Fonnesbeck
?>
135 b9a5448f Stephen Beaver
136
<div>
137 35681930 Stephen Beaver
<div class="infoblock">
138 b9a5448f Stephen Beaver
<?php
139 9fcda3db jim-p
print_info_box(gettext('Socket Information') . '<br /><br />' .
140
gettext('This page shows all listening sockets by default, and shows both listening and outbound connection sockets when <strong>Show all socket connections</strong> is clicked.<br /><br />' .
141
		'The information listed for each socket is:' . '<br /><br />' .
142
		'<dl class="dl-horizontal responsive">' .
143
			'<dt>USER</dt>			<dd>The user who owns the socket.</dd>' .
144
			'<dt>COMMAND</dt>		<dd>The command which holds the socket.</dd>' .
145
			'<dt>PID</dt>			<dd>The process ID of the command which holds the socket.</dd>' .
146
			'<dt>FD</dt>			<dd>The file descriptor number of the socket.</dd>' .
147
			'<dt>PROTO</dt>			<dd>The transport protocol associated with the socket.</dd>' .
148
			'<dt>LOCAL ADDRESS</dt>		<dd>The address the local end of the socket is bound to.</dd>' .
149
			'<dt>FOREIGN ADDRESS</dt>	<dd>The address the foreign end of the socket is bound to.</dd>' .
150
		'</dl>'), 'info', false);
151 b9a5448f Stephen Beaver
?>
152
</div>
153 f1e01f7c Erik Fonnesbeck
</div>
154
<?php
155 f1dab9ec sbeaver
156
include('foot.inc');
157