Project

General

Profile

Download (4.72 KB) Statistics
| Branch: | Tag: | Revision:
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 &amp; 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
<div class="panel-body panel-default">
97
	<div class="table-responsive">
98 6785e98f jim-p
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
99 18e020bd sbeaver
			<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
	<form action="status_upnp.php" method="post">
147 c10cb196 Stephen Beaver
		<nav class="action-buttons">
148 782922c2 Stephen Beaver
			<button class="btn btn-danger btn-sm" type="submit" name="clear" id="clear" value="<?=gettext("Clear all sessions")?>">
149 9d5a20cf heper
				<i class="fa fa-trash icon-embed-btn"></i>
150 782922c2 Stephen Beaver
				<?=gettext("Clear all sessions")?>
151
			</button>
152 18e020bd sbeaver
		</nav>
153
	</form>
154 c38fee60 Scott Ullrich
</div>
155 18e020bd sbeaver
156
<?php
157 c10cb196 Stephen Beaver
include("foot.inc");