Project

General

Profile

Download (4.18 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 38809d47 Renato Botelho do Couto
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8 a68f7a3d Luiz Otavio O Souza
 * Copyright (c) 2014-2024 Rubicon Communications, LLC (Netgate)
9 c5d81585 Renato Botelho
 * Copyright (c) 2010 Seth Mos <seth.mos@dds.nl>
10
 * All rights reserved.
11 782922c2 Stephen Beaver
 *
12 b12ea3fb Renato Botelho
 * 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 782922c2 Stephen Beaver
 *
16 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
17 782922c2 Stephen Beaver
 *
18 b12ea3fb Renato Botelho
 * 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 782922c2 Stephen Beaver
 */
24 c38fee60 Scott Ullrich
25 6b07c15a Matthew Grooms
##|+PRIV
26
##|*IDENT=page-status-upnpstatus
27 fa36708b jim-p
##|*NAME=Status: UPnP IGD & PCP
28 b1024c96 jim-p
##|*DESCR=Allow access to the 'Status: UPnP IGD & PCP' page.
29 6b07c15a Matthew Grooms
##|*MATCH=status_upnp.php*
30
##|-PRIV
31
32 c81ef6e2 Phil Davis
require_once("guiconfig.inc");
33 c38fee60 Scott Ullrich
34
if ($_POST) {
35 18e020bd sbeaver
	if ($_POST['clear']) {
36 431484c8 Ryan Wagoner
		upnp_action('restart');
37 8545adde k-paulius
		$savemsg = gettext("Rules have been cleared and the daemon restarted.");
38 c38fee60 Scott Ullrich
	}
39
}
40
41
$rdr_entries = array();
42
exec("/sbin/pfctl -aminiupnpd -sn", $rdr_entries, $pf_ret);
43
44 ada8c696 Self-Hosting-Group
$pgtitle = array(gettext("Status"), gettext("UPnP IGD &amp; PCP"));
45 d5bd9ee7 jim-p
$shortcut_section = "upnp";
46 18e020bd sbeaver
47 c38fee60 Scott Ullrich
include("head.inc");
48 18e020bd sbeaver
49 abe98adb Phil Davis
if ($savemsg) {
50 18e020bd sbeaver
	print_info_box($savemsg, 'success');
51 abe98adb Phil Davis
}
52 18e020bd sbeaver
53 63d6bb4f Marcos Mendoza
if (!config_get_path('installedpackages/miniupnpd/config/0/iface_array') ||
54
    !config_path_enabled('installedpackages/miniupnpd/config/0')) {
55 18e020bd sbeaver
56 ada8c696 Self-Hosting-Group
	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 18e020bd sbeaver
	include("foot.inc");
58 89cb095e Ryan Wagoner
	exit;
59
}
60 18e020bd sbeaver
61 c38fee60 Scott Ullrich
?>
62 18e020bd sbeaver
63 060ed238 Stephen Beaver
<div class="panel panel-default">
64 ada8c696 Self-Hosting-Group
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Active Service Port Maps")?></h2></div>
65 060ed238 Stephen Beaver
	<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 a8183b25 jim-p
						<th><?=gettext("Interface")?></th>
71 ada8c696 Self-Hosting-Group
						<th><?=gettext("Ext Port")?></th>
72 a8183b25 jim-p
						<th><?=gettext("Int IP")?></th>
73
						<th><?=gettext("Int Port")?></th>
74 ada8c696 Self-Hosting-Group
						<th><?=gettext("Protocol")?></th>
75
						<th><?=gettext("Source IP")?></th>
76
						<th><?=gettext("Source Port")?></th>
77 060ed238 Stephen Beaver
						<th><?=gettext("Description")?></th>
78
					</tr>
79
				</thead>
80
				<tbody>
81 18e020bd sbeaver
<?php
82
$i = 0;
83
84
foreach ($rdr_entries as $rdr_entry) {
85 a8183b25 jim-p
	/* 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 ada8c696 Self-Hosting-Group
	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 18e020bd sbeaver
?>
89 060ed238 Stephen Beaver
					<tr>
90
						<td>
91 a8183b25 jim-p
							<?= htmlspecialchars(convert_real_interface_to_friendly_descr($matches['iface'])) ?>
92
						</td>
93
						<td>
94 ada8c696 Self-Hosting-Group
							<?= htmlspecialchars($matches['extport']) ?>
95 a8183b25 jim-p
						</td>
96 67f0518a jim-p
						<td>
97 ada8c696 Self-Hosting-Group
							<?= htmlspecialchars($matches['intaddr']) ?>
98 67f0518a jim-p
						</td>
99 a8183b25 jim-p
						<td>
100 ada8c696 Self-Hosting-Group
							<?= htmlspecialchars($matches['intport']) ?>
101 060ed238 Stephen Beaver
						</td>
102
						<td>
103 ada8c696 Self-Hosting-Group
							<?= htmlspecialchars(strtoupper($matches['proto'])) ?>
104 060ed238 Stephen Beaver
						</td>
105
						<td>
106 ada8c696 Self-Hosting-Group
							<?= htmlspecialchars($matches['srcaddr']) ?>
107 060ed238 Stephen Beaver
						</td>
108
						<td>
109 ada8c696 Self-Hosting-Group
							<?= htmlspecialchars($matches['srcport'] ?: "any") ?>
110 060ed238 Stephen Beaver
						</td>
111
						<td>
112 a8183b25 jim-p
							<?= htmlspecialchars($matches['descr']) ?>
113 060ed238 Stephen Beaver
						</td>
114
					</tr>
115 18e020bd sbeaver
<?php
116
	}
117
	$i++;
118
}
119
?>
120 060ed238 Stephen Beaver
				</tbody>
121
			</table>
122
		</div>
123 18e020bd sbeaver
	</div>
124 060ed238 Stephen Beaver
</div>
125
126
<div>
127 18e020bd sbeaver
	<form action="status_upnp.php" method="post">
128 c10cb196 Stephen Beaver
		<nav class="action-buttons">
129 782922c2 Stephen Beaver
			<button class="btn btn-danger btn-sm" type="submit" name="clear" id="clear" value="<?=gettext("Clear all sessions")?>">
130 c1d304b3 Marcos Mendoza
				<i class="fa-solid fa-trash-can icon-embed-btn"></i>
131 782922c2 Stephen Beaver
				<?=gettext("Clear all sessions")?>
132
			</button>
133 18e020bd sbeaver
		</nav>
134
	</form>
135 c38fee60 Scott Ullrich
</div>
136 18e020bd sbeaver
137
<?php
138 c10cb196 Stephen Beaver
include("foot.inc");