1 |
c38fee60
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
|
|
status_upnp.php
|
4 |
|
|
*/
|
5 |
782922c2
|
Stephen Beaver
|
/* ====================================================================
|
6 |
|
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
7 |
cb41dd63
|
Renato Botelho
|
* Copyright (c) 2010 Seth Mos <seth.mos@dds.nl>
|
8 |
782922c2
|
Stephen Beaver
|
*
|
9 |
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
10 |
|
|
* are permitted provided that the following conditions are met:
|
11 |
|
|
*
|
12 |
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
13 |
|
|
* this list of conditions and the following disclaimer.
|
14 |
|
|
*
|
15 |
|
|
* 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 |
|
|
*
|
20 |
|
|
* 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 |
|
|
*
|
25 |
|
|
* 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 |
|
|
*
|
30 |
|
|
* 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 |
|
|
*
|
34 |
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
35 |
|
|
* acknowledgment:
|
36 |
|
|
*
|
37 |
|
|
* "This product includes software developed by the pfSense Project
|
38 |
|
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
39 |
|
|
*
|
40 |
|
|
* 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 |
|
|
*
|
53 |
|
|
* ====================================================================
|
54 |
|
|
*
|
55 |
|
|
*/
|
56 |
c38fee60
|
Scott Ullrich
|
|
57 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
58 |
|
|
##|*IDENT=page-status-upnpstatus
|
59 |
5230f468
|
jim-p
|
##|*NAME=Status: UPnP Status
|
60 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Status: UPnP Status' page.
|
61 |
|
|
##|*MATCH=status_upnp.php*
|
62 |
|
|
##|-PRIV
|
63 |
|
|
|
64 |
c38fee60
|
Scott Ullrich
|
require("guiconfig.inc");
|
65 |
|
|
|
66 |
|
|
if ($_POST) {
|
67 |
18e020bd
|
sbeaver
|
if ($_POST['clear']) {
|
68 |
431484c8
|
Ryan Wagoner
|
upnp_action('restart');
|
69 |
92943d57
|
Rafael Lucas
|
$savemsg = gettext("Rules have been cleared and the daemon restarted");
|
70 |
c38fee60
|
Scott Ullrich
|
}
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
$rdr_entries = array();
|
74 |
|
|
exec("/sbin/pfctl -aminiupnpd -sn", $rdr_entries, $pf_ret);
|
75 |
|
|
|
76 |
abe98adb
|
Phil Davis
|
$pgtitle = array(gettext("Status"), gettext("UPnP & NAT-PMP"));
|
77 |
d5bd9ee7
|
jim-p
|
$shortcut_section = "upnp";
|
78 |
18e020bd
|
sbeaver
|
|
79 |
c38fee60
|
Scott Ullrich
|
include("head.inc");
|
80 |
18e020bd
|
sbeaver
|
|
81 |
abe98adb
|
Phil Davis
|
if ($savemsg) {
|
82 |
18e020bd
|
sbeaver
|
print_info_box($savemsg, 'success');
|
83 |
abe98adb
|
Phil Davis
|
}
|
84 |
18e020bd
|
sbeaver
|
|
85 |
abe98adb
|
Phil Davis
|
if (!$config['installedpackages'] ||
|
86 |
|
|
!$config['installedpackages']['miniupnpd']['config'][0]['iface_array'] ||
|
87 |
|
|
!$config['installedpackages']['miniupnpd']['config'][0]['enable']) {
|
88 |
18e020bd
|
sbeaver
|
|
89 |
|
|
print_info_box('UPnP is currently disabled.', 'danger');
|
90 |
|
|
include("foot.inc");
|
91 |
89cb095e
|
Ryan Wagoner
|
exit;
|
92 |
|
|
}
|
93 |
18e020bd
|
sbeaver
|
|
94 |
c38fee60
|
Scott Ullrich
|
?>
|
95 |
18e020bd
|
sbeaver
|
|
96 |
060ed238
|
Stephen Beaver
|
<div class="panel panel-default">
|
97 |
|
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('UPnP rules')?></h2></div>
|
98 |
|
|
<div class="panel-body">
|
99 |
|
|
<div class="table-responsive">
|
100 |
|
|
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
|
101 |
|
|
<thead>
|
102 |
|
|
<tr>
|
103 |
|
|
<th><?=gettext("Port")?></th>
|
104 |
|
|
<th><?=gettext("Protocol")?></th>
|
105 |
|
|
<th><?=gettext("Internal IP")?></th>
|
106 |
|
|
<th><?=gettext("Int. Port")?></th>
|
107 |
|
|
<th><?=gettext("Description")?></th>
|
108 |
|
|
</tr>
|
109 |
|
|
</thead>
|
110 |
|
|
<tbody>
|
111 |
18e020bd
|
sbeaver
|
<?php
|
112 |
|
|
$i = 0;
|
113 |
|
|
|
114 |
|
|
foreach ($rdr_entries as $rdr_entry) {
|
115 |
|
|
if (preg_match("/on (.*) inet proto (.*) from any to any port = (.*) keep state label \"(.*)\" rtable [0-9] -> (.*) port (.*)/", $rdr_entry, $matches)) {
|
116 |
|
|
$rdr_proto = $matches[2];
|
117 |
|
|
$rdr_port = $matches[3];
|
118 |
|
|
$rdr_label =$matches[4];
|
119 |
|
|
$rdr_ip = $matches[5];
|
120 |
|
|
$rdr_iport = $matches[6];
|
121 |
|
|
|
122 |
|
|
?>
|
123 |
060ed238
|
Stephen Beaver
|
<tr>
|
124 |
|
|
<td>
|
125 |
|
|
<?=$rdr_port?>
|
126 |
|
|
</td>
|
127 |
|
|
<td>
|
128 |
|
|
<?=$rdr_proto?>
|
129 |
|
|
</td>
|
130 |
|
|
<td>
|
131 |
|
|
<?=$rdr_ip?>
|
132 |
|
|
</td>
|
133 |
|
|
<td>
|
134 |
|
|
<?=$rdr_iport?>
|
135 |
|
|
</td>
|
136 |
|
|
<td>
|
137 |
|
|
<?=$rdr_label?>
|
138 |
|
|
</td>
|
139 |
|
|
</tr>
|
140 |
18e020bd
|
sbeaver
|
<?php
|
141 |
|
|
}
|
142 |
|
|
$i++;
|
143 |
|
|
}
|
144 |
|
|
?>
|
145 |
060ed238
|
Stephen Beaver
|
</tbody>
|
146 |
|
|
</table>
|
147 |
|
|
</div>
|
148 |
18e020bd
|
sbeaver
|
</div>
|
149 |
060ed238
|
Stephen Beaver
|
</div>
|
150 |
|
|
|
151 |
|
|
<div>
|
152 |
18e020bd
|
sbeaver
|
<form action="status_upnp.php" method="post">
|
153 |
c10cb196
|
Stephen Beaver
|
<nav class="action-buttons">
|
154 |
782922c2
|
Stephen Beaver
|
<button class="btn btn-danger btn-sm" type="submit" name="clear" id="clear" value="<?=gettext("Clear all sessions")?>">
|
155 |
9d5a20cf
|
heper
|
<i class="fa fa-trash icon-embed-btn"></i>
|
156 |
782922c2
|
Stephen Beaver
|
<?=gettext("Clear all sessions")?>
|
157 |
|
|
</button>
|
158 |
18e020bd
|
sbeaver
|
</nav>
|
159 |
|
|
</form>
|
160 |
c38fee60
|
Scott Ullrich
|
</div>
|
161 |
18e020bd
|
sbeaver
|
|
162 |
|
|
<?php
|
163 |
c10cb196
|
Stephen Beaver
|
include("foot.inc");
|