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 |
edcd7535
|
Phil Davis
|
$pglinks = array("", "diag_dump_states.php", "@self");
|
58 |
b63695db
|
Scott Ullrich
|
include("head.inc");
|
59 |
|
|
|
60 |
947141fd
|
Phil Davis
|
if ($input_errors) {
|
61 |
4f2192e6
|
sbeaver
|
print_input_errors($input_errors);
|
62 |
947141fd
|
Phil Davis
|
}
|
63 |
4f2192e6
|
sbeaver
|
|
64 |
947141fd
|
Phil Davis
|
if ($savemsg) {
|
65 |
7c945f74
|
k-paulius
|
print_info_box($savemsg, 'success');
|
66 |
947141fd
|
Phil Davis
|
}
|
67 |
4f2192e6
|
sbeaver
|
|
68 |
ff30e319
|
bruno
|
$statetablehelp = sprintf(gettext('Resetting the state tables will remove all entries from the corresponding tables. This means that all open connections ' .
|
69 |
4f2192e6
|
sbeaver
|
'will be broken and will have to be re-established. This may be necessary after making substantial changes to the ' .
|
70 |
702fa4d0
|
Phil Davis
|
'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 "Reset". ' .
|
73 |
ff30e319
|
bruno
|
'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 |
4ede308c
|
Phil Davis
|
'This means that the "sticky" source/destination association ' .
|
77 |
ff30e319
|
bruno
|
'will be cleared for all clients.%s' .
|
78 |
|
|
'This does not clear active connection states, only source tracking.'), "<br /><br />");
|
79 |
4f2192e6
|
sbeaver
|
|
80 |
|
|
$tab_array = array();
|
81 |
|
|
$tab_array[] = array(gettext("States"), false, "diag_dump_states.php");
|
82 |
d390bbf7
|
sbeaver
|
|
83 |
947141fd
|
Phil Davis
|
if (isset($config['system']['lb_use_sticky'])) {
|
84 |
4f2192e6
|
sbeaver
|
$tab_array[] = array(gettext("Source Tracking"), false, "diag_dump_states_sources.php");
|
85 |
947141fd
|
Phil Davis
|
}
|
86 |
d390bbf7
|
sbeaver
|
|
87 |
|
|
$tab_array[] = array(gettext("Reset States"), true, "diag_resetstate.php");
|
88 |
|
|
display_top_tabs($tab_array);
|
89 |
4f2192e6
|
sbeaver
|
|
90 |
8f58b51b
|
jim-p
|
$form = new Form(false);
|
91 |
4f2192e6
|
sbeaver
|
|
92 |
3726918d
|
Stephen Beaver
|
$section = new Form_Section('State reset options');
|
93 |
4f2192e6
|
sbeaver
|
|
94 |
|
|
$section->addInput(new Form_Checkbox(
|
95 |
|
|
'statetable',
|
96 |
|
|
'State Table',
|
97 |
|
|
'Reset the firewall state table',
|
98 |
41a5ff1d
|
jim-p
|
false
|
99 |
288a2a0f
|
Phil Davis
|
))->setHelp($statetablehelp);
|
100 |
4f2192e6
|
sbeaver
|
|
101 |
288a2a0f
|
Phil Davis
|
if (isset($config['system']['lb_use_sticky'])) {
|
102 |
4f2192e6
|
sbeaver
|
$section->addInput(new Form_Checkbox(
|
103 |
|
|
'sourcetracking',
|
104 |
|
|
'Source Tracking',
|
105 |
|
|
'Reset firewall source tracking',
|
106 |
41a5ff1d
|
jim-p
|
false
|
107 |
4f2192e6
|
sbeaver
|
))->setHelp($sourcetablehelp);
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
$form->add($section);
|
111 |
8f58b51b
|
jim-p
|
|
112 |
|
|
$form->addGlobal(new Form_Button(
|
113 |
|
|
'Submit',
|
114 |
faab522f
|
Renato Botelho
|
'Reset',
|
115 |
8f58b51b
|
jim-p
|
null,
|
116 |
|
|
'fa-trash'
|
117 |
dba59021
|
Stephen Beaver
|
))->addClass('btn-warning');
|
118 |
8f58b51b
|
jim-p
|
|
119 |
4f2192e6
|
sbeaver
|
print $form;
|
120 |
dba59021
|
Stephen Beaver
|
|
121 |
|
|
$nonechecked = gettext("Please select at least one reset option");
|
122 |
|
|
$cfmmsg = gettext("Do you really want to reset the selected states?");
|
123 |
b63695db
|
Scott Ullrich
|
?>
|
124 |
4f2192e6
|
sbeaver
|
|
125 |
dba59021
|
Stephen Beaver
|
<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 |
c10cb196
|
Stephen Beaver
|
<?php include("foot.inc"); ?>
|