1 |
f1e01f7c
|
Erik Fonnesbeck
|
<?php
|
2 |
|
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* diag_sockets.php
|
4 |
fd9ebcd5
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
b8f91b7c
|
Luiz Souza
|
* Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
8 |
fd9ebcd5
|
Stephen Beaver
|
*
|
9 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
10 |
|
|
* you may not use this file except in compliance with the License.
|
11 |
|
|
* You may obtain a copy of the License at
|
12 |
fd9ebcd5
|
Stephen Beaver
|
*
|
13 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
14 |
fd9ebcd5
|
Stephen Beaver
|
*
|
15 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
16 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
17 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18 |
|
|
* See the License for the specific language governing permissions and
|
19 |
|
|
* limitations under the License.
|
20 |
fd9ebcd5
|
Stephen Beaver
|
*/
|
21 |
f1e01f7c
|
Erik Fonnesbeck
|
|
22 |
|
|
##|+PRIV
|
23 |
|
|
##|*IDENT=page-diagnostics-sockets
|
24 |
5230f468
|
jim-p
|
##|*NAME=Diagnostics: Sockets
|
25 |
f1e01f7c
|
Erik Fonnesbeck
|
##|*DESCR=Allow access to the 'Diagnostics: Sockets' page.
|
26 |
|
|
##|*MATCH=diag_sockets.php*
|
27 |
|
|
##|-PRIV
|
28 |
|
|
|
29 |
86573bb9
|
Phil Davis
|
require_once('guiconfig.inc');
|
30 |
f1e01f7c
|
Erik Fonnesbeck
|
|
31 |
699737d9
|
Phil Davis
|
$pgtitle = array(gettext("Diagnostics"), gettext("Sockets"));
|
32 |
f1e01f7c
|
Erik Fonnesbeck
|
|
33 |
|
|
include('head.inc');
|
34 |
|
|
|
35 |
7f4268b6
|
Steve Beaver
|
$showAll = isset($_REQUEST['showAll']);
|
36 |
185b4365
|
Phil Davis
|
$showAllText = $showAll ? gettext("Show only listening sockets") : gettext("Show all socket connections");
|
37 |
f1e01f7c
|
Erik Fonnesbeck
|
$showAllOption = $showAll ? "" : "?showAll";
|
38 |
|
|
|
39 |
|
|
?>
|
40 |
37676f4e
|
jim-p
|
<button class="btn btn-info btn-sm" type="button" value="<?=$showAllText?>" onclick="window.location.href='diag_sockets.php<?=$showAllOption?>'">
|
41 |
|
|
<i class="fa fa-<?= ($showAll) ? 'minus-circle' : 'plus-circle' ; ?> icon-embed-btn"></i>
|
42 |
|
|
<?=$showAllText?>
|
43 |
|
|
</button>
|
44 |
b9a5448f
|
Stephen Beaver
|
<br />
|
45 |
|
|
<br />
|
46 |
f1e01f7c
|
Erik Fonnesbeck
|
|
47 |
|
|
<?php
|
48 |
cbb82e6b
|
Steve Beaver
|
if (isset($_REQUEST['showAll'])) {
|
49 |
f1e01f7c
|
Erik Fonnesbeck
|
$internet4 = shell_exec('sockstat -4');
|
50 |
|
|
$internet6 = shell_exec('sockstat -6');
|
51 |
|
|
} else {
|
52 |
b965f190
|
PiBa-NL
|
$internet4 = shell_exec('sockstat -4l');
|
53 |
|
|
$internet6 = shell_exec('sockstat -6l');
|
54 |
f1e01f7c
|
Erik Fonnesbeck
|
}
|
55 |
b9a5448f
|
Stephen Beaver
|
|
56 |
|
|
|
57 |
f1e01f7c
|
Erik Fonnesbeck
|
foreach (array(&$internet4, &$internet6) as $tabindex => $table) {
|
58 |
|
|
$elements = ($tabindex == 0 ? 7 : 7);
|
59 |
|
|
$name = ($tabindex == 0 ? 'IPv4' : 'IPv6');
|
60 |
|
|
?>
|
61 |
b9a5448f
|
Stephen Beaver
|
<div class="panel panel-default">
|
62 |
3d7a8696
|
k-paulius
|
<div class="panel-heading"><h2 class="panel-title"><?=$name?> <?=gettext("System Socket Information")?></h2></div>
|
63 |
b9a5448f
|
Stephen Beaver
|
<div class="panel-body">
|
64 |
a6ff5ea1
|
sbeaver
|
<div class="table table-responsive">
|
65 |
10fe1eb5
|
Stephen Beaver
|
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
|
66 |
a6ff5ea1
|
sbeaver
|
<thead>
|
67 |
f1e01f7c
|
Erik Fonnesbeck
|
<?php
|
68 |
a6ff5ea1
|
sbeaver
|
foreach (explode("\n", $table) as $i => $line) {
|
69 |
947141fd
|
Phil Davis
|
if (trim($line) == "") {
|
70 |
a6ff5ea1
|
sbeaver
|
continue;
|
71 |
947141fd
|
Phil Davis
|
}
|
72 |
a6ff5ea1
|
sbeaver
|
|
73 |
|
|
$j = 0;
|
74 |
63ff711e
|
Colin Fleming
|
print("<tr>\n");
|
75 |
a6ff5ea1
|
sbeaver
|
foreach (explode(' ', $line) as $entry) {
|
76 |
947141fd
|
Phil Davis
|
if ($entry == '' || $entry == "ADDRESS") {
|
77 |
b9a5448f
|
Stephen Beaver
|
continue;
|
78 |
947141fd
|
Phil Davis
|
}
|
79 |
b9a5448f
|
Stephen Beaver
|
|
80 |
|
|
if ($i == 0) {
|
81 |
a6ff5ea1
|
sbeaver
|
print("<th class=\"$class\">$entry</th>\n");
|
82 |
947141fd
|
Phil Davis
|
} else {
|
83 |
a6ff5ea1
|
sbeaver
|
print("<td class=\"$class\">$entry</td>\n");
|
84 |
b9a5448f
|
Stephen Beaver
|
}
|
85 |
a6ff5ea1
|
sbeaver
|
|
86 |
|
|
$j++;
|
87 |
|
|
}
|
88 |
|
|
print("</tr>\n");
|
89 |
947141fd
|
Phil Davis
|
if ($i == 0) {
|
90 |
b9a5448f
|
Stephen Beaver
|
print("</thead>\n");
|
91 |
|
|
print("<tbody>\n");
|
92 |
|
|
}
|
93 |
a6ff5ea1
|
sbeaver
|
}
|
94 |
|
|
?>
|
95 |
|
|
</tbody>
|
96 |
|
|
</table>
|
97 |
|
|
</div>
|
98 |
b9a5448f
|
Stephen Beaver
|
</div>
|
99 |
|
|
</div>
|
100 |
f1e01f7c
|
Erik Fonnesbeck
|
<?php
|
101 |
f1dab9ec
|
sbeaver
|
}
|
102 |
f1e01f7c
|
Erik Fonnesbeck
|
?>
|
103 |
b9a5448f
|
Stephen Beaver
|
|
104 |
|
|
<div>
|
105 |
35681930
|
Stephen Beaver
|
<div class="infoblock">
|
106 |
b9a5448f
|
Stephen Beaver
|
<?php
|
107 |
5db70796
|
Phil Davis
|
print_info_box(
|
108 |
|
|
gettext('Socket Information') .
|
109 |
|
|
'<br /><br />' .
|
110 |
|
|
sprintf(gettext('This page shows all listening sockets by default, and shows both listening and outbound connection sockets when %1$sShow all socket connections%2$s is clicked.'), '<strong>', '</strong>') .
|
111 |
|
|
'<br /><br />' .
|
112 |
|
|
gettext('The information listed for each socket is:') .
|
113 |
|
|
'<br /><br />' .
|
114 |
1121b4a7
|
jim-p
|
'<dl class="dl-horizontal responsive">' .
|
115 |
5db70796
|
Phil Davis
|
sprintf(gettext('%1$sUSER%2$s %3$sThe user who owns the socket.%4$s'), '<dt>', '</dt>', '<dd>', '</dd>') .
|
116 |
|
|
sprintf(gettext('%1$sCOMMAND%2$s %3$sThe command which holds the socket.%4$s'), '<dt>', '</dt>', '<dd>', '</dd>') .
|
117 |
|
|
sprintf(gettext('%1$sPID%2$s %3$sThe process ID of the command which holds the socket.%4$s'), '<dt>', '</dt>', '<dd>', '</dd>') .
|
118 |
|
|
sprintf(gettext('%1$sFD%2$s %3$sThe file descriptor number of the socket.%4$s'), '<dt>', '</dt>', '<dd>', '</dd>') .
|
119 |
|
|
sprintf(gettext('%1$sPROTO%2$s %3$sThe transport protocol associated with the socket.%4$s'), '<dt>', '</dt>', '<dd>', '</dd>') .
|
120 |
|
|
sprintf(gettext('%1$sLOCAL ADDRESS%2$s %3$sThe address the local end of the socket is bound to.%4$s'), '<dt>', '</dt>', '<dd>', '</dd>') .
|
121 |
|
|
sprintf(gettext('%1$sFOREIGN ADDRESS%2$s %3$sThe address the foreign end of the socket is bound to.%4$s'), '<dt>', '</dt>', '<dd>', '</dd>') .
|
122 |
|
|
'</dl>',
|
123 |
|
|
'info',
|
124 |
|
|
false);
|
125 |
b9a5448f
|
Stephen Beaver
|
?>
|
126 |
|
|
</div>
|
127 |
f1e01f7c
|
Erik Fonnesbeck
|
</div>
|
128 |
|
|
<?php
|
129 |
f1dab9ec
|
sbeaver
|
|
130 |
|
|
include('foot.inc');
|