Project

General

Profile

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

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

    
33
require_once("guiconfig.inc");
34
require_once("filter.inc");
35

    
36
if ($_POST) {
37
	$savemsg = "";
38

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

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

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

    
60
if ($input_errors) {
61
	print_input_errors($input_errors);
62
}
63

    
64
if ($savemsg) {
65
	print_info_box($savemsg, 'success');
66
}
67

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

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

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

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

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

    
90
$form = new Form(false);
91

    
92
$section = new Form_Section('State reset options');
93

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

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

    
110
$form->add($section);
111

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

    
119
print $form;
120

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

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

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

    
141
<?php include("foot.inc"); ?>
(23-23/223)