1 |
c38fee60
|
Scott Ullrich
|
<?php
|
2 |
|
|
/* $Id$ */
|
3 |
|
|
/*
|
4 |
|
|
status_upnp.php
|
5 |
c7281770
|
Chris Buechler
|
part of pfSense (https://www.pfsense.org/)
|
6 |
c38fee60
|
Scott Ullrich
|
|
7 |
6216690b
|
smos
|
Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
|
8 |
ce77a9c4
|
Phil Davis
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
9 |
c38fee60
|
Scott Ullrich
|
All rights reserved.
|
10 |
|
|
|
11 |
|
|
Redistribution and use in source and binary forms, with or without
|
12 |
|
|
modification, are permitted provided that the following conditions are met:
|
13 |
|
|
|
14 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
15 |
|
|
this list of conditions and the following disclaimer.
|
16 |
|
|
|
17 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
18 |
|
|
notice, this list of conditions and the following disclaimer in the
|
19 |
|
|
documentation and/or other materials provided with the distribution.
|
20 |
|
|
|
21 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
25 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
31 |
|
|
*/
|
32 |
1d333258
|
Scott Ullrich
|
/*
|
33 |
|
|
pfSense_BUILDER_BINARIES: /sbin/pfctl
|
34 |
18e020bd
|
sbeaver
|
pfSense_MODULE: upnp
|
35 |
1d333258
|
Scott Ullrich
|
*/
|
36 |
c38fee60
|
Scott Ullrich
|
|
37 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
38 |
|
|
##|*IDENT=page-status-upnpstatus
|
39 |
|
|
##|*NAME=Status: UPnP Status page
|
40 |
|
|
##|*DESCR=Allow access to the 'Status: UPnP Status' page.
|
41 |
|
|
##|*MATCH=status_upnp.php*
|
42 |
|
|
##|-PRIV
|
43 |
|
|
|
44 |
c38fee60
|
Scott Ullrich
|
require("guiconfig.inc");
|
45 |
|
|
|
46 |
|
|
if ($_POST) {
|
47 |
18e020bd
|
sbeaver
|
if ($_POST['clear']) {
|
48 |
431484c8
|
Ryan Wagoner
|
upnp_action('restart');
|
49 |
92943d57
|
Rafael Lucas
|
$savemsg = gettext("Rules have been cleared and the daemon restarted");
|
50 |
c38fee60
|
Scott Ullrich
|
}
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
$rdr_entries = array();
|
54 |
|
|
exec("/sbin/pfctl -aminiupnpd -sn", $rdr_entries, $pf_ret);
|
55 |
|
|
|
56 |
92943d57
|
Rafael Lucas
|
$pgtitle = array(gettext("Status"),gettext("UPnP & NAT-PMP Status"));
|
57 |
d5bd9ee7
|
jim-p
|
$shortcut_section = "upnp";
|
58 |
18e020bd
|
sbeaver
|
|
59 |
c38fee60
|
Scott Ullrich
|
include("head.inc");
|
60 |
18e020bd
|
sbeaver
|
|
61 |
|
|
if ($savemsg)
|
62 |
|
|
print_info_box($savemsg, 'success');
|
63 |
|
|
|
64 |
80d5bd41
|
Phil Lavin
|
if(!$config['installedpackages'] || !$config['installedpackages']['miniupnpd']['config'][0]['iface_array'] ||
|
65 |
18e020bd
|
sbeaver
|
!$config['installedpackages']['miniupnpd']['config'][0]['enable']) {
|
66 |
|
|
|
67 |
|
|
print_info_box('UPnP is currently disabled.', 'danger');
|
68 |
|
|
include("foot.inc");
|
69 |
89cb095e
|
Ryan Wagoner
|
exit;
|
70 |
|
|
}
|
71 |
18e020bd
|
sbeaver
|
|
72 |
c38fee60
|
Scott Ullrich
|
?>
|
73 |
18e020bd
|
sbeaver
|
|
74 |
|
|
<div class="panel-body panel-default">
|
75 |
|
|
<div class="table-responsive">
|
76 |
|
|
<table class="table table-striped table-hover table-condensed">
|
77 |
|
|
<thead>
|
78 |
|
|
<tr>
|
79 |
|
|
<th><?=gettext("Port")?></th>
|
80 |
|
|
<th><?=gettext("Protocol")?></th>
|
81 |
|
|
<th><?=gettext("Internal IP")?></th>
|
82 |
|
|
<th><?=gettext("Int. Port")?></th>
|
83 |
|
|
<th><?=gettext("Description")?></th>
|
84 |
|
|
</tr>
|
85 |
|
|
</thead>
|
86 |
|
|
<tbody>
|
87 |
|
|
<?php
|
88 |
|
|
$i = 0;
|
89 |
|
|
|
90 |
|
|
foreach ($rdr_entries as $rdr_entry) {
|
91 |
|
|
if (preg_match("/on (.*) inet proto (.*) from any to any port = (.*) keep state label \"(.*)\" rtable [0-9] -> (.*) port (.*)/", $rdr_entry, $matches)) {
|
92 |
|
|
$rdr_proto = $matches[2];
|
93 |
|
|
$rdr_port = $matches[3];
|
94 |
|
|
$rdr_label =$matches[4];
|
95 |
|
|
$rdr_ip = $matches[5];
|
96 |
|
|
$rdr_iport = $matches[6];
|
97 |
|
|
|
98 |
|
|
?>
|
99 |
|
|
<tr>
|
100 |
|
|
<td>
|
101 |
|
|
<?=$rdr_port?>
|
102 |
|
|
</td>
|
103 |
|
|
<td>
|
104 |
|
|
<?=$rdr_proto?>
|
105 |
|
|
</td>
|
106 |
|
|
<td>
|
107 |
|
|
<?=$rdr_ip?>
|
108 |
|
|
</td>
|
109 |
|
|
<td>
|
110 |
|
|
<?=$rdr_iport?>
|
111 |
|
|
</td>
|
112 |
|
|
<td>
|
113 |
|
|
<?=$rdr_label?>
|
114 |
|
|
</td>
|
115 |
|
|
</tr>
|
116 |
|
|
<?php
|
117 |
|
|
}
|
118 |
|
|
$i++;
|
119 |
|
|
}
|
120 |
|
|
?>
|
121 |
|
|
</tbody>
|
122 |
|
|
</table>
|
123 |
|
|
</div>
|
124 |
|
|
<form action="status_upnp.php" method="post">
|
125 |
|
|
<nav class="action-buttons">
|
126 |
|
|
<input class="btn btn-danger" type="submit" name="clear" id="clear" value="<?=gettext("Clear all sessions")?>" />
|
127 |
|
|
</nav>
|
128 |
|
|
</form>
|
129 |
c38fee60
|
Scott Ullrich
|
</div>
|
130 |
18e020bd
|
sbeaver
|
|
131 |
|
|
<?php
|
132 |
|
|
include("foot.inc");
|