Project

General

Profile

Download (4.19 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
include("head.inc");
58

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

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

    
67
$statetablehelp = sprintf(gettext('Resetting the state tables will remove all entries from the corresponding tables. This means that all open connections ' .
68
					'will be broken and will have to be re-established. This may be necessary after making substantial changes to the ' .
69
					'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
					'%sNOTE:%s Resetting the firewall state table may cause the browser session to appear hung after clicking &quot;Reset&quot;. ' .
72
					'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
					'This means that the \"sticky\" source/destination association ' .
76
					'will be cleared for all clients.%s' .
77
					'This does not clear active connection states, only source tracking.'), "<br /><br />");
78

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

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

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

    
89
$form = new Form(false);
90

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

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

    
100
if (isset($config['system']['lb_use_sticky'])) {
101
	$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

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

    
118
print $form;
119

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

    
124
<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
<?php include("foot.inc"); ?>
(23-23/225)