Project

General

Profile

Download (1.34 KB) Statistics
| Branch: | Tag: | Revision:
1
/*
2
 * pfanchordrill
3
 *
4
 * part of pfSense (https://www.pfsense.org)
5
 * Copyright (c) 2016 Electric Sheep Fencing
6
 * Copyright (c) 2016-2019 Rubicon Communications, LLC (Netgate)
7
 * All rights reserved.
8
 *
9
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12
 *
13
 * http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20
 */
21
/* Recursively check anchors for rules/nat and also for anchors inside anchors (like those used by UPnP) */
22
function anchor_recurse($name = '') {
23
	$anchor_list = "";
24
	if ($name) {
25
		$name = ' -a ' . escapeshellarg($name);
26
	}
27
	exec("/sbin/pfctl -sA{$name} 2>&1", $anchor_list);
28
	foreach ($anchor_list as $anchor) {
29
		$anchor = trim($anchor);
30
		echo "\n{$anchor} rules/nat contents:\n";
31
		system("/sbin/pfctl -a " . escapeshellarg($anchor) . " -sn");
32
		system("/sbin/pfctl -a " . escapeshellarg($anchor) . " -sr");
33
		anchor_recurse($anchor);
34
	}
35
}
36

    
37
/* Start with a the root list of anchors */
38
anchor_recurse();
(16-16/24)