Project

General

Profile

Download (4.91 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
##|+PRIV
58
##|*IDENT=page-status-upnpstatus
59
##|*NAME=Status: UPnP Status
60
##|*DESCR=Allow access to the 'Status: UPnP Status' page.
61
##|*MATCH=status_upnp.php*
62
##|-PRIV
63

    
64
require_once("guiconfig.inc");
65

    
66
if ($_POST) {
67
	if ($_POST['clear']) {
68
		upnp_action('restart');
69
		$savemsg = gettext("Rules have been cleared and the daemon restarted.");
70
	}
71
}
72

    
73
$rdr_entries = array();
74
exec("/sbin/pfctl -aminiupnpd -sn", $rdr_entries, $pf_ret);
75

    
76
$pgtitle = array(gettext("Status"), gettext("UPnP &amp; NAT-PMP"));
77
$shortcut_section = "upnp";
78

    
79
include("head.inc");
80

    
81
if ($savemsg) {
82
	print_info_box($savemsg, 'success');
83
}
84

    
85
if (!$config['installedpackages'] ||
86
    !$config['installedpackages']['miniupnpd']['config'][0]['iface_array'] ||
87
    !$config['installedpackages']['miniupnpd']['config'][0]['enable']) {
88

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

    
94
?>
95

    
96
<div class="panel panel-default">
97
	<div class="panel-heading"><h2 class="panel-title"><?=gettext(gettext("UPnP &amp; NAT-PMP Rules"))?></h2></div>
98
	<div class="panel-body">
99
		<div class="table-responsive">
100
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
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
	</div>
149
</div>
150

    
151
<div>
152
	<form action="status_upnp.php" method="post">
153
		<nav class="action-buttons">
154
			<button class="btn btn-danger btn-sm" type="submit" name="clear" id="clear" value="<?=gettext("Clear all sessions")?>">
155
				<i class="fa fa-trash icon-embed-btn"></i>
156
				<?=gettext("Clear all sessions")?>
157
			</button>
158
		</nav>
159
	</form>
160
</div>
161

    
162
<?php
163
include("foot.inc");
(183-183/225)