Project

General

Profile

Download (3.94 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-2020 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: %1$s%2$s%3$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("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("Interface")?></th>
70
						<th><?=gettext("Protocol")?></th>
71
						<th><?=gettext("Ext IP")?></th>
72
						<th><?=gettext("Port")?></th>
73
						<th><?=gettext("Int IP")?></th>
74
						<th><?=gettext("Int Port")?></th>
75
						<th><?=gettext("Description")?></th>
76
					</tr>
77
				</thead>
78
				<tbody>
79
<?php
80
$i = 0;
81

    
82
foreach ($rdr_entries as $rdr_entry) {
83
	/* rdr log quick on igb2 inet proto tcp from any to any port = xxxxx keep state label "xxxxx" rtable 0 -> xxx.xxx.xxx.xxx port xxxxx */
84
	/* rdr log quick on igb2 inet proto udp from any to xxx.xxx.xxx.xxx port = xxxxxx keep state label "xxxxx" rtable 0 -> xxx.xxx.xxx.xxx port xxxxx */
85
	if (preg_match("/on (?P<iface>.*) inet proto (?P<proto>.*) from any to (?P<extaddr>.*) port = (?P<extport>.*) keep state label \"(?P<descr>.*)\" rtable [0-9] -> (?P<intaddr>.*) port (?P<intport>.*)/", $rdr_entry, $matches)) {
86
?>
87
					<tr>
88
						<td>
89
							<?= htmlspecialchars(convert_real_interface_to_friendly_descr($matches['iface'])) ?>
90
						</td>
91
						<td>
92
							<?= htmlspecialchars($matches['proto']) ?>
93
						</td>
94
						<td>
95
							<?= htmlspecialchars($matches['extaddr']) ?>
96
						</td>
97
						<td>
98
							<?= htmlspecialchars($matches['extport']) ?>
99
						</td>
100
						<td>
101
							<?= htmlspecialchars($matches['intaddr']) ?>
102
						</td>
103
						<td>
104
							<?= htmlspecialchars($matches['intport']) ?>
105
						</td>
106
						<td>
107
							<?= htmlspecialchars($matches['descr']) ?>
108
						</td>
109
					</tr>
110
<?php
111
	}
112
	$i++;
113
}
114
?>
115
				</tbody>
116
			</table>
117
		</div>
118
	</div>
119
</div>
120

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

    
132
<?php
133
include("foot.inc");
(191-191/235)