Project

General

Profile

Download (4.18 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-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2024 Rubicon Communications, LLC (Netgate)
9
 * Copyright (c) 2010 Seth Mos <seth.mos@dds.nl>
10
 * All rights reserved.
11
 *
12
 * Licensed under the Apache License, Version 2.0 (the "License");
13
 * you may not use this file except in compliance with the License.
14
 * You may obtain a copy of the License at
15
 *
16
 * http://www.apache.org/licenses/LICENSE-2.0
17
 *
18
 * Unless required by applicable law or agreed to in writing, software
19
 * distributed under the License is distributed on an "AS IS" BASIS,
20
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
 * See the License for the specific language governing permissions and
22
 * limitations under the License.
23
 */
24

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

    
32
require_once("guiconfig.inc");
33

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

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

    
44
$pgtitle = array(gettext("Status"), gettext("UPnP IGD &amp; PCP"));
45
$shortcut_section = "upnp";
46

    
47
include("head.inc");
48

    
49
if ($savemsg) {
50
	print_info_box($savemsg, 'success');
51
}
52

    
53
if (!config_get_path('installedpackages/miniupnpd/config/0/iface_array') ||
54
    !config_path_enabled('installedpackages/miniupnpd/config/0')) {
55

    
56
	print_info_box(sprintf(gettext('Service 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 IGD &amp; PCP'), '</a>'), 'danger');
57
	include("foot.inc");
58
	exit;
59
}
60

    
61
?>
62

    
63
<div class="panel panel-default">
64
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Active Service Port Maps")?></h2></div>
65
	<div class="panel-body">
66
		<div class="table-responsive">
67
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
68
				<thead>
69
					<tr>
70
						<th><?=gettext("Interface")?></th>
71
						<th><?=gettext("Ext Port")?></th>
72
						<th><?=gettext("Int IP")?></th>
73
						<th><?=gettext("Int Port")?></th>
74
						<th><?=gettext("Protocol")?></th>
75
						<th><?=gettext("Source IP")?></th>
76
						<th><?=gettext("Source Port")?></th>
77
						<th><?=gettext("Description")?></th>
78
					</tr>
79
				</thead>
80
				<tbody>
81
<?php
82
$i = 0;
83

    
84
foreach ($rdr_entries as $rdr_entry) {
85
	/* 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 */
86
	/* 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 */
87
	if (preg_match("/on (?P<iface>.*) inet proto (?P<proto>.*) from (?P<srcaddr>.*) (port (?P<srcport>.*) )?to (?P<extaddr>.*) port = (?P<extport>.*) keep state (label \"(?P<descr>.*)\" )?rtable [0-9] -> (?P<intaddr>.*) port (?P<intport>.*)/", $rdr_entry, $matches)) {
88
?>
89
					<tr>
90
						<td>
91
							<?= htmlspecialchars(convert_real_interface_to_friendly_descr($matches['iface'])) ?>
92
						</td>
93
						<td>
94
							<?= htmlspecialchars($matches['extport']) ?>
95
						</td>
96
						<td>
97
							<?= htmlspecialchars($matches['intaddr']) ?>
98
						</td>
99
						<td>
100
							<?= htmlspecialchars($matches['intport']) ?>
101
						</td>
102
						<td>
103
							<?= htmlspecialchars(strtoupper($matches['proto'])) ?>
104
						</td>
105
						<td>
106
							<?= htmlspecialchars($matches['srcaddr']) ?>
107
						</td>
108
						<td>
109
							<?= htmlspecialchars($matches['srcport'] ?: "any") ?>
110
						</td>
111
						<td>
112
							<?= htmlspecialchars($matches['descr']) ?>
113
						</td>
114
					</tr>
115
<?php
116
	}
117
	$i++;
118
}
119
?>
120
				</tbody>
121
			</table>
122
		</div>
123
	</div>
124
</div>
125

    
126
<div>
127
	<form action="status_upnp.php" method="post">
128
		<nav class="action-buttons">
129
			<button class="btn btn-danger btn-sm" type="submit" name="clear" id="clear" value="<?=gettext("Clear all sessions")?>">
130
				<i class="fa-solid fa-trash-can icon-embed-btn"></i>
131
				<?=gettext("Clear all sessions")?>
132
			</button>
133
		</nav>
134
	</form>
135
</div>
136

    
137
<?php
138
include("foot.inc");
(186-186/232)