Project

General

Profile

Download (3.32 KB) Statistics
| Branch: | Tag: | Revision:
1 c38fee60 Scott Ullrich
<?php
2
/*
3 c5d81585 Renato Botelho
 * status_upnp.php
4 782922c2 Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 81299b5c Renato Botelho
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7 c5d81585 Renato Botelho
 * Copyright (c) 2010 Seth Mos <seth.mos@dds.nl>
8
 * All rights reserved.
9 782922c2 Stephen Beaver
 *
10 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
11
 * you may not use this file except in compliance with the License.
12
 * You may obtain a copy of the License at
13 782922c2 Stephen Beaver
 *
14 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
15 782922c2 Stephen Beaver
 *
16 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
17
 * distributed under the License is distributed on an "AS IS" BASIS,
18
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
 * See the License for the specific language governing permissions and
20
 * limitations under the License.
21 782922c2 Stephen Beaver
 */
22 c38fee60 Scott Ullrich
23 6b07c15a Matthew Grooms
##|+PRIV
24
##|*IDENT=page-status-upnpstatus
25 5230f468 jim-p
##|*NAME=Status: UPnP Status
26 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Status: UPnP Status' page.
27
##|*MATCH=status_upnp.php*
28
##|-PRIV
29
30 c81ef6e2 Phil Davis
require_once("guiconfig.inc");
31 c38fee60 Scott Ullrich
32
if ($_POST) {
33 18e020bd sbeaver
	if ($_POST['clear']) {
34 431484c8 Ryan Wagoner
		upnp_action('restart');
35 8545adde k-paulius
		$savemsg = gettext("Rules have been cleared and the daemon restarted.");
36 c38fee60 Scott Ullrich
	}
37
}
38
39
$rdr_entries = array();
40
exec("/sbin/pfctl -aminiupnpd -sn", $rdr_entries, $pf_ret);
41
42 abe98adb Phil Davis
$pgtitle = array(gettext("Status"), gettext("UPnP &amp; NAT-PMP"));
43 d5bd9ee7 jim-p
$shortcut_section = "upnp";
44 18e020bd sbeaver
45 c38fee60 Scott Ullrich
include("head.inc");
46 18e020bd sbeaver
47 abe98adb Phil Davis
if ($savemsg) {
48 18e020bd sbeaver
	print_info_box($savemsg, 'success');
49 abe98adb Phil Davis
}
50 18e020bd sbeaver
51 abe98adb Phil Davis
if (!$config['installedpackages'] ||
52
    !$config['installedpackages']['miniupnpd']['config'][0]['iface_array'] ||
53
    !$config['installedpackages']['miniupnpd']['config'][0]['enable']) {
54 18e020bd sbeaver
55 702fa4d0 Phil Davis
	print_info_box(sprintf(gettext('UPnP is currently disabled. It can be enabled here: %1$s%2$s%3$s.'), '<a href="pkg_edit.php?xml=miniupnpd.xml">', gettext('Services &gt; UPnP &amp; NAT-PMP'), '</a>'), 'danger');
56 18e020bd sbeaver
	include("foot.inc");
57 89cb095e Ryan Wagoner
	exit;
58
}
59 18e020bd sbeaver
60 c38fee60 Scott Ullrich
?>
61 18e020bd sbeaver
62 060ed238 Stephen Beaver
<div class="panel panel-default">
63 3224663a Phil Davis
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("UPnP &amp; NAT-PMP Rules")?></h2></div>
64 060ed238 Stephen Beaver
	<div class="panel-body">
65
		<div class="table-responsive">
66
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
67
				<thead>
68
					<tr>
69
						<th><?=gettext("Port")?></th>
70
						<th><?=gettext("Protocol")?></th>
71
						<th><?=gettext("Internal IP")?></th>
72
						<th><?=gettext("Int. Port")?></th>
73
						<th><?=gettext("Description")?></th>
74
					</tr>
75
				</thead>
76
				<tbody>
77 18e020bd sbeaver
<?php
78
$i = 0;
79
80
foreach ($rdr_entries as $rdr_entry) {
81
	if (preg_match("/on (.*) inet proto (.*) from any to any port = (.*) keep state label \"(.*)\" rtable [0-9] -> (.*) port (.*)/", $rdr_entry, $matches)) {
82
	$rdr_proto = $matches[2];
83
	$rdr_port = $matches[3];
84
	$rdr_label =$matches[4];
85
	$rdr_ip = $matches[5];
86
	$rdr_iport = $matches[6];
87
88
?>
89 060ed238 Stephen Beaver
					<tr>
90
						<td>
91
							<?=$rdr_port?>
92
						</td>
93
						<td>
94
							<?=$rdr_proto?>
95
						</td>
96
						<td>
97
							<?=$rdr_ip?>
98
						</td>
99
						<td>
100
							<?=$rdr_iport?>
101
						</td>
102
						<td>
103
							<?=$rdr_label?>
104
						</td>
105
					</tr>
106 18e020bd sbeaver
<?php
107
	}
108
	$i++;
109
}
110
?>
111 060ed238 Stephen Beaver
				</tbody>
112
			</table>
113
		</div>
114 18e020bd sbeaver
	</div>
115 060ed238 Stephen Beaver
</div>
116
117
<div>
118 18e020bd sbeaver
	<form action="status_upnp.php" method="post">
119 c10cb196 Stephen Beaver
		<nav class="action-buttons">
120 782922c2 Stephen Beaver
			<button class="btn btn-danger btn-sm" type="submit" name="clear" id="clear" value="<?=gettext("Clear all sessions")?>">
121 9d5a20cf heper
				<i class="fa fa-trash icon-embed-btn"></i>
122 782922c2 Stephen Beaver
				<?=gettext("Clear all sessions")?>
123
			</button>
124 18e020bd sbeaver
		</nav>
125
	</form>
126 c38fee60 Scott Ullrich
</div>
127 18e020bd sbeaver
128
<?php
129 c10cb196 Stephen Beaver
include("foot.inc");