Project

General

Profile

Download (3.32 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * status_upnp.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7
 * Copyright (c) 2010 Seth Mos <seth.mos@dds.nl>
8
 * All rights reserved.
9
 *
10
 * 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
 *
14
 * http://www.apache.org/licenses/LICENSE-2.0
15
 *
16
 * 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
 */
22

    
23
##|+PRIV
24
##|*IDENT=page-status-upnpstatus
25
##|*NAME=Status: UPnP Status
26
##|*DESCR=Allow access to the 'Status: UPnP Status' page.
27
##|*MATCH=status_upnp.php*
28
##|-PRIV
29

    
30
require_once("guiconfig.inc");
31

    
32
if ($_POST) {
33
	if ($_POST['clear']) {
34
		upnp_action('restart');
35
		$savemsg = gettext("Rules have been cleared and the daemon restarted.");
36
	}
37
}
38

    
39
$rdr_entries = array();
40
exec("/sbin/pfctl -aminiupnpd -sn", $rdr_entries, $pf_ret);
41

    
42
$pgtitle = array(gettext("Status"), gettext("UPnP &amp; NAT-PMP"));
43
$shortcut_section = "upnp";
44

    
45
include("head.inc");
46

    
47
if ($savemsg) {
48
	print_info_box($savemsg, 'success');
49
}
50

    
51
if (!$config['installedpackages'] ||
52
    !$config['installedpackages']['miniupnpd']['config'][0]['iface_array'] ||
53
    !$config['installedpackages']['miniupnpd']['config'][0]['enable']) {
54

    
55
	print_info_box(sprintf(gettext('UPnP is currently disabled. It can be enabled here: %s%s%s.'), '<a href="pkg_edit.php?xml=miniupnpd.xml">', gettext('Services &gt; UPnP &amp; NAT-PMP'), '</a>'), 'danger');
56
	include("foot.inc");
57
	exit;
58
}
59

    
60
?>
61

    
62
<div class="panel panel-default">
63
	<div class="panel-heading"><h2 class="panel-title"><?=gettext(gettext("UPnP &amp; NAT-PMP Rules"))?></h2></div>
64
	<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
<?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
					<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
<?php
107
	}
108
	$i++;
109
}
110
?>
111
				</tbody>
112
			</table>
113
		</div>
114
	</div>
115
</div>
116

    
117
<div>
118
	<form action="status_upnp.php" method="post">
119
		<nav class="action-buttons">
120
			<button class="btn btn-danger btn-sm" type="submit" name="clear" id="clear" value="<?=gettext("Clear all sessions")?>">
121
				<i class="fa fa-trash icon-embed-btn"></i>
122
				<?=gettext("Clear all sessions")?>
123
			</button>
124
		</nav>
125
	</form>
126
</div>
127

    
128
<?php
129
include("foot.inc");
(182-182/225)