1 |
4d875b4f
|
Scott Ullrich
|
<?php
|
2 |
5b237745
|
Scott Ullrich
|
/*
|
3 |
aaec5634
|
Renato Botelho
|
* diag_resetstate.php
|
4 |
9da2cf1c
|
Stephen Beaver
|
*
|
5 |
aaec5634
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
2a2396a6
|
Renato Botelho
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
7 |
aaec5634
|
Renato Botelho
|
* All rights reserved.
|
8 |
fd9ebcd5
|
Stephen Beaver
|
*
|
9 |
aaec5634
|
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 |
aaec5634
|
Renato Botelho
|
* Redistribution and use in source and binary forms, with or without
|
14 |
|
|
* modification, are permitted provided that the following conditions are met:
|
15 |
fd9ebcd5
|
Stephen Beaver
|
*
|
16 |
aaec5634
|
Renato Botelho
|
* 1. Redistributions of source code must retain the above copyright notice,
|
17 |
|
|
* this list of conditions and the following disclaimer.
|
18 |
fd9ebcd5
|
Stephen Beaver
|
*
|
19 |
aaec5634
|
Renato Botelho
|
* 2. Redistributions in binary form must reproduce the above copyright
|
20 |
|
|
* notice, this list of conditions and the following disclaimer in
|
21 |
|
|
* the documentation and/or other materials provided with the
|
22 |
|
|
* distribution.
|
23 |
fd9ebcd5
|
Stephen Beaver
|
*
|
24 |
aaec5634
|
Renato Botelho
|
* 3. All advertising materials mentioning features or use of this software
|
25 |
|
|
* must display the following acknowledgment:
|
26 |
|
|
* "This product includes software developed by the pfSense Project
|
27 |
|
|
* for use in the pfSense® software distribution. (http://www.pfsense.org/).
|
28 |
fd9ebcd5
|
Stephen Beaver
|
*
|
29 |
aaec5634
|
Renato Botelho
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
30 |
|
|
* endorse or promote products derived from this software without
|
31 |
|
|
* prior written permission. For written permission, please contact
|
32 |
|
|
* coreteam@pfsense.org.
|
33 |
fd9ebcd5
|
Stephen Beaver
|
*
|
34 |
aaec5634
|
Renato Botelho
|
* 5. Products derived from this software may not be called "pfSense"
|
35 |
|
|
* nor may "pfSense" appear in their names without prior written
|
36 |
|
|
* permission of the Electric Sheep Fencing, LLC.
|
37 |
fd9ebcd5
|
Stephen Beaver
|
*
|
38 |
aaec5634
|
Renato Botelho
|
* 6. Redistributions of any form whatsoever must retain the following
|
39 |
|
|
* acknowledgment:
|
40 |
0da0d43e
|
Phil Davis
|
*
|
41 |
aaec5634
|
Renato Botelho
|
* "This product includes software developed by the pfSense Project
|
42 |
|
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
43 |
fd9ebcd5
|
Stephen Beaver
|
*
|
44 |
aaec5634
|
Renato Botelho
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
45 |
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
46 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
47 |
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
48 |
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
49 |
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
50 |
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
51 |
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
52 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
53 |
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
54 |
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
55 |
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
56 |
fd9ebcd5
|
Stephen Beaver
|
*/
|
57 |
5b237745
|
Scott Ullrich
|
|
58 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
59 |
|
|
##|*IDENT=page-diagnostics-resetstate
|
60 |
9599211d
|
jim-p
|
##|*NAME=Diagnostics: Reset states
|
61 |
|
|
##|*DESCR=Allow access to the 'Diagnostics: Reset states' page.
|
62 |
6b07c15a
|
Matthew Grooms
|
##|*MATCH=diag_resetstate.php*
|
63 |
|
|
##|-PRIV
|
64 |
|
|
|
65 |
aceaf18c
|
Phil Davis
|
require_once("guiconfig.inc");
|
66 |
ec08d983
|
Ermal Lu?i
|
require_once("filter.inc");
|
67 |
5b237745
|
Scott Ullrich
|
|
68 |
|
|
if ($_POST) {
|
69 |
|
|
$savemsg = "";
|
70 |
4f2192e6
|
sbeaver
|
|
71 |
5b237745
|
Scott Ullrich
|
if ($_POST['statetable']) {
|
72 |
d390bbf7
|
sbeaver
|
filter_flush_state_table();
|
73 |
5f601060
|
Phil Davis
|
if ($savemsg) {
|
74 |
5b237745
|
Scott Ullrich
|
$savemsg .= " ";
|
75 |
5f601060
|
Phil Davis
|
}
|
76 |
f8ec8de4
|
Renato Botelho
|
$savemsg .= gettext("The state table has been flushed successfully.");
|
77 |
5b237745
|
Scott Ullrich
|
}
|
78 |
4f2192e6
|
sbeaver
|
|
79 |
f4c2d976
|
jim-p
|
if ($_POST['sourcetracking']) {
|
80 |
d390bbf7
|
sbeaver
|
mwexec("/sbin/pfctl -F Sources");
|
81 |
5f601060
|
Phil Davis
|
if ($savemsg) {
|
82 |
8cd558b6
|
ayvis
|
$savemsg .= " <br />";
|
83 |
5f601060
|
Phil Davis
|
}
|
84 |
f4c2d976
|
jim-p
|
$savemsg .= gettext("The source tracking table has been flushed successfully.");
|
85 |
|
|
}
|
86 |
5b237745
|
Scott Ullrich
|
}
|
87 |
|
|
|
88 |
a6a6ee00
|
k-paulius
|
$pgtitle = array(gettext("Diagnostics"), gettext("States"), gettext("Reset States"));
|
89 |
b63695db
|
Scott Ullrich
|
include("head.inc");
|
90 |
|
|
|
91 |
947141fd
|
Phil Davis
|
if ($input_errors) {
|
92 |
4f2192e6
|
sbeaver
|
print_input_errors($input_errors);
|
93 |
947141fd
|
Phil Davis
|
}
|
94 |
4f2192e6
|
sbeaver
|
|
95 |
947141fd
|
Phil Davis
|
if ($savemsg) {
|
96 |
7c945f74
|
k-paulius
|
print_info_box($savemsg, 'success');
|
97 |
947141fd
|
Phil Davis
|
}
|
98 |
4f2192e6
|
sbeaver
|
|
99 |
ff30e319
|
bruno
|
$statetablehelp = sprintf(gettext('Resetting the state tables will remove all entries from the corresponding tables. This means that all open connections ' .
|
100 |
4f2192e6
|
sbeaver
|
'will be broken and will have to be re-established. This may be necessary after making substantial changes to the ' .
|
101 |
ff30e319
|
bruno
|
'firewall and/or NAT rules, especially if there are IP protocol mappings (e.g. for PPTP or IPv6) with open connections.%s' .
|
102 |
|
|
'The firewall will normally leave the state tables intact when changing rules.%s' .
|
103 |
90968c49
|
lukehamburg
|
'%sNOTE:%s Resetting the firewall state table may cause the browser session to appear hung after clicking "Reset". ' .
|
104 |
ff30e319
|
bruno
|
'Simply refresh the page to continue.'), "<br /><br />", "<br /><br />", "<strong>", "</strong>");
|
105 |
|
|
|
106 |
|
|
$sourcetablehelp = sprintf(gettext('Resetting the source tracking table will remove all source/destination associations. ' .
|
107 |
4f2192e6
|
sbeaver
|
'This means that the \"sticky\" source/destination association ' .
|
108 |
ff30e319
|
bruno
|
'will be cleared for all clients.%s' .
|
109 |
|
|
'This does not clear active connection states, only source tracking.'), "<br /><br />");
|
110 |
4f2192e6
|
sbeaver
|
|
111 |
|
|
$tab_array = array();
|
112 |
|
|
$tab_array[] = array(gettext("States"), false, "diag_dump_states.php");
|
113 |
d390bbf7
|
sbeaver
|
|
114 |
947141fd
|
Phil Davis
|
if (isset($config['system']['lb_use_sticky'])) {
|
115 |
4f2192e6
|
sbeaver
|
$tab_array[] = array(gettext("Source Tracking"), false, "diag_dump_states_sources.php");
|
116 |
947141fd
|
Phil Davis
|
}
|
117 |
d390bbf7
|
sbeaver
|
|
118 |
|
|
$tab_array[] = array(gettext("Reset States"), true, "diag_resetstate.php");
|
119 |
|
|
display_top_tabs($tab_array);
|
120 |
4f2192e6
|
sbeaver
|
|
121 |
8f58b51b
|
jim-p
|
$form = new Form(false);
|
122 |
4f2192e6
|
sbeaver
|
|
123 |
df57a1cf
|
Stephen Beaver
|
$section = new Form_Section('State reset options');
|
124 |
4f2192e6
|
sbeaver
|
|
125 |
|
|
$section->addInput(new Form_Checkbox(
|
126 |
|
|
'statetable',
|
127 |
|
|
'State Table',
|
128 |
|
|
'Reset the firewall state table',
|
129 |
|
|
true
|
130 |
288a2a0f
|
Phil Davis
|
))->setHelp($statetablehelp);
|
131 |
4f2192e6
|
sbeaver
|
|
132 |
288a2a0f
|
Phil Davis
|
if (isset($config['system']['lb_use_sticky'])) {
|
133 |
4f2192e6
|
sbeaver
|
$section->addInput(new Form_Checkbox(
|
134 |
|
|
'sourcetracking',
|
135 |
|
|
'Source Tracking',
|
136 |
|
|
'Reset firewall source tracking',
|
137 |
|
|
true
|
138 |
|
|
))->setHelp($sourcetablehelp);
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
$form->add($section);
|
142 |
8f58b51b
|
jim-p
|
|
143 |
|
|
$form->addGlobal(new Form_Button(
|
144 |
|
|
'Submit',
|
145 |
faab522f
|
Renato Botelho
|
'Reset',
|
146 |
8f58b51b
|
jim-p
|
null,
|
147 |
|
|
'fa-trash'
|
148 |
247c0d9a
|
Stephen Beaver
|
))->addClass('btn-warning');
|
149 |
8f58b51b
|
jim-p
|
|
150 |
4f2192e6
|
sbeaver
|
print $form;
|
151 |
247c0d9a
|
Stephen Beaver
|
|
152 |
|
|
$nonechecked = gettext("Please select at least one reset option");
|
153 |
|
|
$cfmmsg = gettext("Do you really want to reset the selected states?");
|
154 |
b63695db
|
Scott Ullrich
|
?>
|
155 |
4f2192e6
|
sbeaver
|
|
156 |
247c0d9a
|
Stephen Beaver
|
<script type="text/javascript">
|
157 |
|
|
//<![CDATA[
|
158 |
|
|
events.push(function(){
|
159 |
|
|
|
160 |
|
|
$('form').submit(function(event){
|
161 |
|
|
if ( !($('#statetable').prop("checked") == true) && !($('#sourcetracking').prop("checked") == true)) {
|
162 |
|
|
alert("<?=$nonechecked?>");
|
163 |
|
|
event.preventDefault();
|
164 |
|
|
} else if (!confirm("<?=$cfmmsg?>")) {
|
165 |
|
|
event.preventDefault();
|
166 |
|
|
}
|
167 |
|
|
});
|
168 |
|
|
});
|
169 |
|
|
//]]>
|
170 |
|
|
</script>
|
171 |
|
|
|
172 |
c10cb196
|
Stephen Beaver
|
<?php include("foot.inc"); ?>
|