Project

General

Profile

Download (4.8 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	status_upnp.php
5
	part of pfSense (https://www.pfsense.org/)
6
*/
7
/* ====================================================================
8
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
9
 *  Copyright (c)  2010 Seth Mos <seth.mos@dds.nl>
10
 *
11
 *	Redistribution and use in source and binary forms, with or without modification,
12
 *	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
19
 *		the documentation and/or other materials provided with the
20
 *		distribution.
21
 *
22
 *	3. All advertising materials mentioning features or use of this software
23
 *		must display the following acknowledgment:
24
 *		"This product includes software developed by the pfSense Project
25
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
26
 *
27
 *	4. The names "pfSense" and "pfSense Project" must not be used to
28
 *		 endorse or promote products derived from this software without
29
 *		 prior written permission. For written permission, please contact
30
 *		 coreteam@pfsense.org.
31
 *
32
 *	5. Products derived from this software may not be called "pfSense"
33
 *		nor may "pfSense" appear in their names without prior written
34
 *		permission of the Electric Sheep Fencing, LLC.
35
 *
36
 *	6. Redistributions of any form whatsoever must retain the following
37
 *		acknowledgment:
38
 *
39
 *	"This product includes software developed by the pfSense Project
40
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
41
 *
42
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
43
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
46
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
54
 *
55
 *	====================================================================
56
 *
57
 */
58
/*
59
	pfSense_BUILDER_BINARIES:	/sbin/pfctl
60
	pfSense_MODULE: upnp
61
*/
62

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

    
70
require("guiconfig.inc");
71

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

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

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

    
85
include("head.inc");
86

    
87
if ($savemsg)
88
	print_info_box($savemsg, 'success');
89

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

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

    
98
?>
99

    
100
<div class="panel-body panel-default">
101
	<div class="table-responsive">
102
		<table class="table table-striped table-hover table-condensed">
103
			<thead>
104
				<tr>
105
					<th><?=gettext("Port")?></th>
106
					<th><?=gettext("Protocol")?></th>
107
					<th><?=gettext("Internal IP")?></th>
108
					<th><?=gettext("Int. Port")?></th>
109
					<th><?=gettext("Description")?></th>
110
				</tr>
111
			</thead>
112
			<tbody>
113
<?php
114
$i = 0;
115

    
116
foreach ($rdr_entries as $rdr_entry) {
117
	if (preg_match("/on (.*) inet proto (.*) from any to any port = (.*) keep state label \"(.*)\" rtable [0-9] -> (.*) port (.*)/", $rdr_entry, $matches)) {
118
	$rdr_proto = $matches[2];
119
	$rdr_port = $matches[3];
120
	$rdr_label =$matches[4];
121
	$rdr_ip = $matches[5];
122
	$rdr_iport = $matches[6];
123

    
124
?>
125
				<tr>
126
					<td>
127
						<?=$rdr_port?>
128
					</td>
129
					<td>
130
						<?=$rdr_proto?>
131
					</td>
132
					<td>
133
						<?=$rdr_ip?>
134
					</td>
135
					<td>
136
						<?=$rdr_iport?>
137
					</td>
138
					<td>
139
						<?=$rdr_label?>
140
					</td>
141
				</tr>
142
<?php
143
	}
144
	$i++;
145
}
146
?>
147
			</tbody>
148
		</table>
149
	</div>
150
	<form action="status_upnp.php" method="post">
151
		<nav class="action-buttons">
152
			<button class="btn btn-danger btn-sm" type="submit" name="clear" id="clear" value="<?=gettext("Clear all sessions")?>">
153
				<i class="fa fa-trash icon-embed-btn"></i>
154
				<?=gettext("Clear all sessions")?>
155
			</button>
156
		</nav>
157
	</form>
158
</div>
159

    
160
<?php
161
include("foot.inc");
(184-184/234)