Project

General

Profile

Download (4.34 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * diag_resetstate.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-2020 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * originally based on m0n0wall (http://m0n0.ch/wall)
12
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
13
 * All rights reserved.
14
 *
15
 * Licensed under the Apache License, Version 2.0 (the "License");
16
 * you may not use this file except in compliance with the License.
17
 * You may obtain a copy of the License at
18
 *
19
 * http://www.apache.org/licenses/LICENSE-2.0
20
 *
21
 * Unless required by applicable law or agreed to in writing, software
22
 * distributed under the License is distributed on an "AS IS" BASIS,
23
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
 * See the License for the specific language governing permissions and
25
 * limitations under the License.
26
 */
27

    
28
##|+PRIV
29
##|*IDENT=page-diagnostics-resetstate
30
##|*NAME=Diagnostics: Reset states
31
##|*DESCR=Allow access to the 'Diagnostics: Reset states' page.
32
##|*MATCH=diag_resetstate.php*
33
##|-PRIV
34

    
35
require_once("guiconfig.inc");
36
require_once("filter.inc");
37

    
38
if ($_POST) {
39
	$savemsg = "";
40

    
41
	if ($_POST['statetable']) {
42
		filter_flush_state_table();
43
		if ($savemsg) {
44
			$savemsg .= " ";
45
		}
46
		$savemsg .= gettext("The state table has been flushed successfully.");
47
	}
48

    
49
	if ($_POST['sourcetracking']) {
50
		mwexec("/sbin/pfctl -F Sources");
51
		if ($savemsg) {
52
			$savemsg .= " <br />";
53
		}
54
		$savemsg .= gettext("The source tracking table has been flushed successfully.");
55
	}
56
}
57

    
58
$pgtitle = array(gettext("Diagnostics"), gettext("States"), gettext("Reset States"));
59
$pglinks = array("", "diag_dump_states.php", "@self");
60
include("head.inc");
61

    
62
if ($input_errors) {
63
	print_input_errors($input_errors);
64
}
65

    
66
if ($savemsg) {
67
	print_info_box($savemsg, 'success');
68
}
69

    
70
$statetablehelp = sprintf(gettext('Resetting the state tables will remove all entries from the corresponding tables. This means that all open connections ' .
71
					'will be broken and will have to be re-established. This may be necessary after making substantial changes to the ' .
72
					'firewall and/or NAT rules, especially if there are IP protocol mappings (e.g. for PPTP or IPv6) with open connections.%1$s' .
73
					'The firewall will normally leave the state tables intact when changing rules.%2$s' .
74
					'%3$sNOTE:%4$s Resetting the firewall state table may cause the browser session to appear hung after clicking &quot;Reset&quot;. ' .
75
					'Simply refresh the page to continue.'), "<br /><br />", "<br /><br />", "<strong>", "</strong>");
76

    
77
$sourcetablehelp = sprintf(gettext('Resetting the source tracking table will remove all source/destination associations. ' .
78
					'This means that the "sticky" source/destination association ' .
79
					'will be cleared for all clients.%s' .
80
					'This does not clear active connection states, only source tracking.'), "<br /><br />");
81

    
82
$tab_array = array();
83
$tab_array[] = array(gettext("States"), false, "diag_dump_states.php");
84

    
85
if (isset($config['system']['lb_use_sticky'])) {
86
	$tab_array[] = array(gettext("Source Tracking"), false, "diag_dump_states_sources.php");
87
}
88

    
89
$tab_array[] = array(gettext("Reset States"), true, "diag_resetstate.php");
90
display_top_tabs($tab_array);
91

    
92
$form = new Form(false);
93

    
94
$section = new Form_Section('State reset options');
95

    
96
$section->addInput(new Form_Checkbox(
97
	'statetable',
98
	'State Table',
99
	'Reset the firewall state table',
100
	false
101
))->setHelp($statetablehelp);
102

    
103
if (isset($config['system']['lb_use_sticky'])) {
104
	$section->addInput(new Form_Checkbox(
105
		'sourcetracking',
106
		'Source Tracking',
107
		'Reset firewall source tracking',
108
		false
109
	))->setHelp($sourcetablehelp);
110
}
111

    
112
$form->add($section);
113

    
114
$form->addGlobal(new Form_Button(
115
	'Submit',
116
	'Reset',
117
	null,
118
	'fa-trash'
119
))->addClass('btn-warning');
120

    
121
print $form;
122

    
123
$nonechecked = gettext("Please select at least one reset option");
124
$cfmmsg = gettext("Do you really want to reset the selected states?");
125
?>
126

    
127
<script type="text/javascript">
128
//<![CDATA[
129
	events.push(function(){
130

    
131
		$('form').submit(function(event){
132
			if ( !($('#statetable').prop("checked") == true) && !($('#sourcetracking').prop("checked") == true)) {
133
				alert("<?=$nonechecked?>");
134
				event.preventDefault();
135
			} else if (!confirm("<?=$cfmmsg?>")) {
136
				event.preventDefault();
137
			}
138
		});
139
	});
140
//]]>
141
</script>
142

    
143
<?php include("foot.inc"); ?>
(27-27/230)