Project

General

Profile

Download (4.19 KB) Statistics
| Branch: | Tag: | Revision:
1 4d875b4f Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3 c5d81585 Renato Botelho
 * diag_resetstate.php
4 9da2cf1c Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 81299b5c Renato Botelho
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7 c5d81585 Renato Botelho
 * All rights reserved.
8 fd9ebcd5 Stephen Beaver
 *
9 c5d81585 Renato Botelho
 * originally based on m0n0wall (http://m0n0.ch/wall)
10
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
 * All rights reserved.
12 fd9ebcd5 Stephen Beaver
 *
13 b12ea3fb Renato Botelho
 * 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 fd9ebcd5 Stephen Beaver
 *
17 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
18 fd9ebcd5 Stephen Beaver
 *
19 b12ea3fb Renato Botelho
 * 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 fd9ebcd5 Stephen Beaver
 */
25 5b237745 Scott Ullrich
26 6b07c15a Matthew Grooms
##|+PRIV
27
##|*IDENT=page-diagnostics-resetstate
28 9599211d jim-p
##|*NAME=Diagnostics: Reset states
29
##|*DESCR=Allow access to the 'Diagnostics: Reset states' page.
30 6b07c15a Matthew Grooms
##|*MATCH=diag_resetstate.php*
31
##|-PRIV
32
33 c81ef6e2 Phil Davis
require_once("guiconfig.inc");
34 ec08d983 Ermal Lu?i
require_once("filter.inc");
35 5b237745 Scott Ullrich
36
if ($_POST) {
37
	$savemsg = "";
38 4f2192e6 sbeaver
39 5b237745 Scott Ullrich
	if ($_POST['statetable']) {
40 d390bbf7 sbeaver
		filter_flush_state_table();
41 5f601060 Phil Davis
		if ($savemsg) {
42 5b237745 Scott Ullrich
			$savemsg .= " ";
43 5f601060 Phil Davis
		}
44 f8ec8de4 Renato Botelho
		$savemsg .= gettext("The state table has been flushed successfully.");
45 5b237745 Scott Ullrich
	}
46 4f2192e6 sbeaver
47 f4c2d976 jim-p
	if ($_POST['sourcetracking']) {
48 d390bbf7 sbeaver
		mwexec("/sbin/pfctl -F Sources");
49 5f601060 Phil Davis
		if ($savemsg) {
50 8cd558b6 ayvis
			$savemsg .= " <br />";
51 5f601060 Phil Davis
		}
52 f4c2d976 jim-p
		$savemsg .= gettext("The source tracking table has been flushed successfully.");
53
	}
54 5b237745 Scott Ullrich
}
55
56 a6a6ee00 k-paulius
$pgtitle = array(gettext("Diagnostics"), gettext("States"), gettext("Reset States"));
57 b63695db Scott Ullrich
include("head.inc");
58
59 947141fd Phil Davis
if ($input_errors) {
60 4f2192e6 sbeaver
	print_input_errors($input_errors);
61 947141fd Phil Davis
}
62 4f2192e6 sbeaver
63 947141fd Phil Davis
if ($savemsg) {
64 7c945f74 k-paulius
	print_info_box($savemsg, 'success');
65 947141fd Phil Davis
}
66 4f2192e6 sbeaver
67 ff30e319 bruno
$statetablehelp = sprintf(gettext('Resetting the state tables will remove all entries from the corresponding tables. This means that all open connections ' .
68 4f2192e6 sbeaver
					'will be broken and will have to be re-established. This may be necessary after making substantial changes to the ' .
69 ff30e319 bruno
					'firewall and/or NAT rules, especially if there are IP protocol mappings (e.g. for PPTP or IPv6) with open connections.%s' .
70
					'The firewall will normally leave the state tables intact when changing rules.%s' .
71 957b7bab lukehamburg
					'%sNOTE:%s Resetting the firewall state table may cause the browser session to appear hung after clicking &quot;Reset&quot;. ' .
72 ff30e319 bruno
					'Simply refresh the page to continue.'), "<br /><br />", "<br /><br />", "<strong>", "</strong>");
73
74
$sourcetablehelp = sprintf(gettext('Resetting the source tracking table will remove all source/destination associations. ' .
75 4f2192e6 sbeaver
					'This means that the \"sticky\" source/destination association ' .
76 ff30e319 bruno
					'will be cleared for all clients.%s' .
77
					'This does not clear active connection states, only source tracking.'), "<br /><br />");
78 4f2192e6 sbeaver
79
$tab_array = array();
80
$tab_array[] = array(gettext("States"), false, "diag_dump_states.php");
81 d390bbf7 sbeaver
82 947141fd Phil Davis
if (isset($config['system']['lb_use_sticky'])) {
83 4f2192e6 sbeaver
	$tab_array[] = array(gettext("Source Tracking"), false, "diag_dump_states_sources.php");
84 947141fd Phil Davis
}
85 d390bbf7 sbeaver
86
$tab_array[] = array(gettext("Reset States"), true, "diag_resetstate.php");
87
display_top_tabs($tab_array);
88 4f2192e6 sbeaver
89 8f58b51b jim-p
$form = new Form(false);
90 4f2192e6 sbeaver
91 3726918d Stephen Beaver
$section = new Form_Section('State reset options');
92 4f2192e6 sbeaver
93
$section->addInput(new Form_Checkbox(
94
	'statetable',
95
	'State Table',
96
	'Reset the firewall state table',
97
	true
98 288a2a0f Phil Davis
))->setHelp($statetablehelp);
99 4f2192e6 sbeaver
100 288a2a0f Phil Davis
if (isset($config['system']['lb_use_sticky'])) {
101 4f2192e6 sbeaver
	$section->addInput(new Form_Checkbox(
102
		'sourcetracking',
103
		'Source Tracking',
104
		'Reset firewall source tracking',
105
		true
106
	))->setHelp($sourcetablehelp);
107
}
108
109
$form->add($section);
110 8f58b51b jim-p
111
$form->addGlobal(new Form_Button(
112
	'Submit',
113 faab522f Renato Botelho
	'Reset',
114 8f58b51b jim-p
	null,
115
	'fa-trash'
116 dba59021 Stephen Beaver
))->addClass('btn-warning');
117 8f58b51b jim-p
118 4f2192e6 sbeaver
print $form;
119 dba59021 Stephen Beaver
120
$nonechecked = gettext("Please select at least one reset option");
121
$cfmmsg = gettext("Do you really want to reset the selected states?");
122 b63695db Scott Ullrich
?>
123 4f2192e6 sbeaver
124 dba59021 Stephen Beaver
<script type="text/javascript">
125
//<![CDATA[
126
	events.push(function(){
127
128
		$('form').submit(function(event){
129
			if ( !($('#statetable').prop("checked") == true) && !($('#sourcetracking').prop("checked") == true)) {
130
				alert("<?=$nonechecked?>");
131
				event.preventDefault();
132
			} else if (!confirm("<?=$cfmmsg?>")) {
133
				event.preventDefault();
134
			}
135
		});
136
	});
137
//]]>
138
</script>
139
140 c10cb196 Stephen Beaver
<?php include("foot.inc"); ?>