Project

General

Profile

Download (4.75 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	status_upnp.php
4
*/
5
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7
 *	Copyright (c)  2010 Seth Mos <seth.mos@dds.nl>
8
 *
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
/*
57
	pfSense_BUILDER_BINARIES:	/sbin/pfctl
58
	pfSense_MODULE: upnp
59
*/
60

    
61
##|+PRIV
62
##|*IDENT=page-status-upnpstatus
63
##|*NAME=Status: UPnP Status page
64
##|*DESCR=Allow access to the 'Status: UPnP Status' page.
65
##|*MATCH=status_upnp.php*
66
##|-PRIV
67

    
68
require("guiconfig.inc");
69

    
70
if ($_POST) {
71
	if ($_POST['clear']) {
72
		upnp_action('restart');
73
		$savemsg = gettext("Rules have been cleared and the daemon restarted");
74
	}
75
}
76

    
77
$rdr_entries = array();
78
exec("/sbin/pfctl -aminiupnpd -sn", $rdr_entries, $pf_ret);
79

    
80
$pgtitle = array(gettext("Status"),gettext("UPnP &amp; NAT-PMP Status"));
81
$shortcut_section = "upnp";
82

    
83
include("head.inc");
84

    
85
if ($savemsg)
86
	print_info_box($savemsg, 'success');
87

    
88
if(!$config['installedpackages'] || !$config['installedpackages']['miniupnpd']['config'][0]['iface_array'] ||
89
   !$config['installedpackages']['miniupnpd']['config'][0]['enable']) {
90

    
91
	print_info_box('UPnP is currently disabled.', 'danger');
92
	include("foot.inc");
93
	exit;
94
}
95

    
96
?>
97

    
98
<div class="panel-body panel-default">
99
	<div class="table-responsive">
100
		<table class="table table-striped table-hover table-condensed">
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
<?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
				<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
<?php
141
	}
142
	$i++;
143
}
144
?>
145
			</tbody>
146
		</table>
147
	</div>
148
	<form action="status_upnp.php" method="post">
149
		<nav class="action-buttons">
150
			<button class="btn btn-danger btn-sm" type="submit" name="clear" id="clear" value="<?=gettext("Clear all sessions")?>">
151
				<i class="fa fa-trash icon-embed-btn"></i>
152
				<?=gettext("Clear all sessions")?>
153
			</button>
154
		</nav>
155
	</form>
156
</div>
157

    
158
<?php
159
include("foot.inc");
(184-184/234)