1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
status_upnp.php
|
5
|
part of pfSense (https://www.pfsense.org/)
|
6
|
|
7
|
Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
|
8
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
9
|
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
|
/*
|
33
|
pfSense_BUILDER_BINARIES: /sbin/pfctl
|
34
|
pfSense_MODULE: upnp
|
35
|
*/
|
36
|
|
37
|
##|+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
|
require("guiconfig.inc");
|
45
|
|
46
|
if ($_POST) {
|
47
|
if ($_POST['clear']) {
|
48
|
upnp_action('restart');
|
49
|
$savemsg = gettext("Rules have been cleared and the daemon restarted");
|
50
|
}
|
51
|
}
|
52
|
|
53
|
$rdr_entries = array();
|
54
|
exec("/sbin/pfctl -aminiupnpd -sn", $rdr_entries, $pf_ret);
|
55
|
|
56
|
$pgtitle = array(gettext("Status"),gettext("UPnP & NAT-PMP Status"));
|
57
|
$shortcut_section = "upnp";
|
58
|
|
59
|
include("head.inc");
|
60
|
|
61
|
if ($savemsg)
|
62
|
print_info_box($savemsg, 'success');
|
63
|
|
64
|
if(!$config['installedpackages'] || !$config['installedpackages']['miniupnpd']['config'][0]['iface_array'] ||
|
65
|
!$config['installedpackages']['miniupnpd']['config'][0]['enable']) {
|
66
|
|
67
|
print_info_box('UPnP is currently disabled.', 'danger');
|
68
|
include("foot.inc");
|
69
|
exit;
|
70
|
}
|
71
|
|
72
|
?>
|
73
|
|
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
|
</div>
|
130
|
|
131
|
<?php
|
132
|
include("foot.inc");
|