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
|
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 the
|
18
|
documentation and/or other materials provided with the distribution.
|
19
|
|
20
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
POSSIBILITY OF SUCH DAMAGE.
|
30
|
*/
|
31
|
/*
|
32
|
pfSense_BUILDER_BINARIES: /sbin/pfctl
|
33
|
pfSense_MODULE: upnp
|
34
|
*/
|
35
|
|
36
|
##|+PRIV
|
37
|
##|*IDENT=page-status-upnpstatus
|
38
|
##|*NAME=Status: UPnP Status page
|
39
|
##|*DESCR=Allow access to the 'Status: UPnP Status' page.
|
40
|
##|*MATCH=status_upnp.php*
|
41
|
##|-PRIV
|
42
|
|
43
|
require("guiconfig.inc");
|
44
|
|
45
|
if ($_POST) {
|
46
|
if ($_POST['clear'] == "Clear") {
|
47
|
upnp_action('restart');
|
48
|
$savemsg = gettext("Rules have been cleared and the daemon restarted");
|
49
|
}
|
50
|
}
|
51
|
|
52
|
$rdr_entries = array();
|
53
|
exec("/sbin/pfctl -aminiupnpd -sn", $rdr_entries, $pf_ret);
|
54
|
|
55
|
$now = time();
|
56
|
$year = date("Y");
|
57
|
|
58
|
$pgtitle = array(gettext("Status"),gettext("UPnP & NAT-PMP Status"));
|
59
|
$shortcut_section = "upnp";
|
60
|
include("head.inc");
|
61
|
?>
|
62
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
63
|
<?php include("fbegin.inc"); ?>
|
64
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
65
|
<?php
|
66
|
if(!$config['installedpackages'] || !$config['installedpackages']['miniupnpd']['config'][0]['iface_array'] ||
|
67
|
!$config['installedpackages']['miniupnpd']['config'][0]['enable']) {
|
68
|
echo gettext("UPnP is currently disabled.");
|
69
|
include("fend.inc");
|
70
|
echo '</body></html>';
|
71
|
exit;
|
72
|
}
|
73
|
?>
|
74
|
<div id="mainlevel">
|
75
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
76
|
<tr>
|
77
|
<td class="tabcont" >
|
78
|
<form action="status_upnp.php" method="post">
|
79
|
<input type="submit" name="clear" id="clear" value="<?=gettext("Clear");?>" /> <?=gettext("all currently connected sessions");?>.
|
80
|
</form>
|
81
|
</td>
|
82
|
</tr>
|
83
|
<tr>
|
84
|
<td class="tabcont" >
|
85
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabcont">
|
86
|
<tr>
|
87
|
<td width="10%" class="listhdrr"><?=gettext("Port");?></td>
|
88
|
<td width="10%" class="listhdrr"><?=gettext("Protocol");?></td>
|
89
|
<td width="20%" class="listhdrr"><?=gettext("Internal IP");?></td>
|
90
|
<td width="10%" class="listhdrr"><?=gettext("Int. Port");?></td>
|
91
|
<td width="50%" class="listhdr"><?=gettext("Description");?></td>
|
92
|
</tr>
|
93
|
<?php $i = 0; foreach ($rdr_entries as $rdr_entry) {
|
94
|
if (preg_match("/on (.*) inet proto (.*) from any to any port = (.*) keep state label \"(.*)\" rtable [0-9] -> (.*) port (.*)/", $rdr_entry, $matches))
|
95
|
$rdr_proto = $matches[2];
|
96
|
$rdr_port = $matches[3];
|
97
|
$rdr_label =$matches[4];
|
98
|
$rdr_ip = $matches[5];
|
99
|
$rdr_iport = $matches[6];
|
100
|
?>
|
101
|
<tr>
|
102
|
<td class="listlr">
|
103
|
<?php print $rdr_port;?>
|
104
|
</td>
|
105
|
<td class="listlr">
|
106
|
<?php print $rdr_proto;?>
|
107
|
</td>
|
108
|
<td class="listlr">
|
109
|
<?php print $rdr_ip;?>
|
110
|
</td>
|
111
|
<td class="listlr">
|
112
|
<?php print $rdr_iport;?>
|
113
|
</td>
|
114
|
<td class="listlr">
|
115
|
<?php print $rdr_label;?>
|
116
|
</td>
|
117
|
</tr>
|
118
|
<?php $i++; }?>
|
119
|
</table>
|
120
|
</td>
|
121
|
</tr>
|
122
|
</table>
|
123
|
</div>
|
124
|
<?php include("fend.inc"); ?>
|
125
|
</body>
|
126
|
</html>
|