1
|
<?php
|
2
|
/*
|
3
|
* status_upnp.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2016 Electric Sheep Fencing, LLC
|
7
|
* Copyright (c) 2010 Seth Mos <seth.mos@dds.nl>
|
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
|
18
|
* the documentation and/or other materials provided with the
|
19
|
* distribution.
|
20
|
*
|
21
|
* 3. All advertising materials mentioning features or use of this software
|
22
|
* must display the following acknowledgment:
|
23
|
* "This product includes software developed by the pfSense Project
|
24
|
* for use in the pfSense® software distribution. (http://www.pfsense.org/).
|
25
|
*
|
26
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
27
|
* endorse or promote products derived from this software without
|
28
|
* prior written permission. For written permission, please contact
|
29
|
* coreteam@pfsense.org.
|
30
|
*
|
31
|
* 5. Products derived from this software may not be called "pfSense"
|
32
|
* nor may "pfSense" appear in their names without prior written
|
33
|
* permission of the Electric Sheep Fencing, LLC.
|
34
|
*
|
35
|
* 6. Redistributions of any form whatsoever must retain the following
|
36
|
* acknowledgment:
|
37
|
*
|
38
|
* "This product includes software developed by the pfSense Project
|
39
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
40
|
*
|
41
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
42
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
43
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
44
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
45
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
46
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
47
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
48
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
49
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
50
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
51
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
52
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
53
|
*/
|
54
|
|
55
|
##|+PRIV
|
56
|
##|*IDENT=page-status-upnpstatus
|
57
|
##|*NAME=Status: UPnP Status
|
58
|
##|*DESCR=Allow access to the 'Status: UPnP Status' page.
|
59
|
##|*MATCH=status_upnp.php*
|
60
|
##|-PRIV
|
61
|
|
62
|
require_once("guiconfig.inc");
|
63
|
|
64
|
if ($_POST) {
|
65
|
if ($_POST['clear']) {
|
66
|
upnp_action('restart');
|
67
|
$savemsg = gettext("Rules have been cleared and the daemon restarted.");
|
68
|
}
|
69
|
}
|
70
|
|
71
|
$rdr_entries = array();
|
72
|
exec("/sbin/pfctl -aminiupnpd -sn", $rdr_entries, $pf_ret);
|
73
|
|
74
|
$pgtitle = array(gettext("Status"), gettext("UPnP & NAT-PMP"));
|
75
|
$shortcut_section = "upnp";
|
76
|
|
77
|
include("head.inc");
|
78
|
|
79
|
if ($savemsg) {
|
80
|
print_info_box($savemsg, 'success');
|
81
|
}
|
82
|
|
83
|
if (!$config['installedpackages'] ||
|
84
|
!$config['installedpackages']['miniupnpd']['config'][0]['iface_array'] ||
|
85
|
!$config['installedpackages']['miniupnpd']['config'][0]['enable']) {
|
86
|
|
87
|
print_info_box('UPnP is currently disabled.', 'danger');
|
88
|
include("foot.inc");
|
89
|
exit;
|
90
|
}
|
91
|
|
92
|
?>
|
93
|
|
94
|
<div class="panel panel-default">
|
95
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext(gettext("UPnP & NAT-PMP Rules"))?></h2></div>
|
96
|
<div class="panel-body">
|
97
|
<div class="table-responsive">
|
98
|
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
|
99
|
<thead>
|
100
|
<tr>
|
101
|
<th><?=gettext("Port")?></th>
|
102
|
<th><?=gettext("Protocol")?></th>
|
103
|
<th><?=gettext("Internal IP")?></th>
|
104
|
<th><?=gettext("Int. Port")?></th>
|
105
|
<th><?=gettext("Description")?></th>
|
106
|
</tr>
|
107
|
</thead>
|
108
|
<tbody>
|
109
|
<?php
|
110
|
$i = 0;
|
111
|
|
112
|
foreach ($rdr_entries as $rdr_entry) {
|
113
|
if (preg_match("/on (.*) inet proto (.*) from any to any port = (.*) keep state label \"(.*)\" rtable [0-9] -> (.*) port (.*)/", $rdr_entry, $matches)) {
|
114
|
$rdr_proto = $matches[2];
|
115
|
$rdr_port = $matches[3];
|
116
|
$rdr_label =$matches[4];
|
117
|
$rdr_ip = $matches[5];
|
118
|
$rdr_iport = $matches[6];
|
119
|
|
120
|
?>
|
121
|
<tr>
|
122
|
<td>
|
123
|
<?=$rdr_port?>
|
124
|
</td>
|
125
|
<td>
|
126
|
<?=$rdr_proto?>
|
127
|
</td>
|
128
|
<td>
|
129
|
<?=$rdr_ip?>
|
130
|
</td>
|
131
|
<td>
|
132
|
<?=$rdr_iport?>
|
133
|
</td>
|
134
|
<td>
|
135
|
<?=$rdr_label?>
|
136
|
</td>
|
137
|
</tr>
|
138
|
<?php
|
139
|
}
|
140
|
$i++;
|
141
|
}
|
142
|
?>
|
143
|
</tbody>
|
144
|
</table>
|
145
|
</div>
|
146
|
</div>
|
147
|
</div>
|
148
|
|
149
|
<div>
|
150
|
<form action="status_upnp.php" method="post">
|
151
|
<nav class="action-buttons">
|
152
|
<button class="btn btn-danger btn-sm" type="submit" name="clear" id="clear" value="<?=gettext("Clear all sessions")?>">
|
153
|
<i class="fa fa-trash icon-embed-btn"></i>
|
154
|
<?=gettext("Clear all sessions")?>
|
155
|
</button>
|
156
|
</nav>
|
157
|
</form>
|
158
|
</div>
|
159
|
|
160
|
<?php
|
161
|
include("foot.inc");
|