diff --git a/src/www/system_advanced_firewall.php b/src/www/system_advanced_firewall.php index c38ab9f54..eaa2c185d 100644 --- a/src/www/system_advanced_firewall.php +++ b/src/www/system_advanced_firewall.php @@ -1,32 +1,32 @@ . - All rights reserved. + Copyright (C) 2014-2015 Deciso B.V. + Copyright (C) 2005-2007 Scott Ullrich + Copyright (C) 2008 Shrew Soft Inc + Copyright (C) 2003-2004 Manuel Kasper . + All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. */ require_once("guiconfig.inc"); @@ -42,171 +42,167 @@ function default_table_entries_size() } -$pconfig['disablefilter'] = $config['system']['disablefilter']; -$pconfig['rfc959workaround'] = $config['system']['rfc959workaround']; -$pconfig['scrubnodf'] = $config['system']['scrubnodf']; -$pconfig['scrubrnid'] = $config['system']['scrubrnid']; -$pconfig['tcpidletimeout'] = $config['filter']['tcpidletimeout']; -$pconfig['optimization'] = $config['filter']['optimization']; -$pconfig['adaptivestart'] = $config['system']['adaptivestart']; -$pconfig['adaptiveend'] = $config['system']['adaptiveend']; -$pconfig['maximumstates'] = $config['system']['maximumstates']; -$pconfig['aliasesresolveinterval'] = $config['system']['aliasesresolveinterval']; -$old_aliasesresolveinterval = $config['system']['aliasesresolveinterval']; -$pconfig['checkaliasesurlcert'] = isset($config['system']['checkaliasesurlcert']); -$pconfig['maximumtableentries'] = $config['system']['maximumtableentries']; -$pconfig['disablereplyto'] = isset($config['system']['disablereplyto']); -$pconfig['disablenegate'] = isset($config['system']['disablenegate']); -$pconfig['bogonsinterval'] = $config['system']['bogons']['interval']; -$pconfig['disablenatreflection'] = $config['system']['disablenatreflection']; -$pconfig['enablebinatreflection'] = $config['system']['enablebinatreflection']; -$pconfig['reflectiontimeout'] = $config['system']['reflectiontimeout']; -$pconfig['bypassstaticroutes'] = isset($config['filter']['bypassstaticroutes']); -$pconfig['disablescrub'] = isset($config['system']['disablescrub']); -$pconfig['ftp-proxy-client'] = isset($config['system']['ftp-proxy']['client']); -$pconfig['disablevpnrules'] = isset($config['system']['disablevpnrules']); - -if ($_POST) { - unset($input_errors); +if ($_SERVER['REQUEST_METHOD'] === 'GET') { + $pconfig = array(); + $pconfig['disablefilter'] = !empty($config['system']['disablefilter']); + $pconfig['scrubnodf'] = !empty($config['system']['scrubnodf']); + $pconfig['scrubrnid'] = !empty($config['system']['scrubrnid']); + $pconfig['optimization'] = isset($config['system']['optimization']) ? $config['system']['optimization'] : "normal"; + $pconfig['maximumstates'] = isset($config['system']['maximumstates']) ? $config['system']['maximumstates'] : null; + $pconfig['adaptivestart'] = isset($config['system']['adaptivestart']) ? $config['system']['adaptivestart'] : null; + $pconfig['adaptiveend'] = isset($config['system']['adaptiveend']) ? $config['system']['adaptiveend'] : null; + $pconfig['aliasesresolveinterval'] = isset($config['system']['aliasesresolveinterval']) ? $config['system']['aliasesresolveinterval'] : null; + $pconfig['checkaliasesurlcert'] = isset($config['system']['checkaliasesurlcert']); + $pconfig['maximumtableentries'] = !empty($config['system']['maximumtableentries']) ? $config['system']['maximumtableentries'] : null ; + $pconfig['disablereplyto'] = isset($config['system']['disablereplyto']); + $pconfig['disablenegate'] = isset($config['system']['disablenegate']); + $pconfig['bogonsinterval'] = !empty($config['system']['bogons']['interval']) ? $config['system']['bogons']['interval'] : null; + if (!isset($config['system']['disablenatreflection']) && !isset($config['system']['enablenatreflectionpurenat'])) { + $pconfig['natreflection'] = "proxy"; + } elseif (isset($config['system']['enablenatreflectionpurenat'])) { + $pconfig['natreflection'] = "purenat"; + } else { + $pconfig['natreflection'] = "disable"; + } + $pconfig['enablebinatreflection'] = !empty($config['system']['enablebinatreflection']); + $pconfig['enablenatreflectionhelper'] = isset($config['system']['enablenatreflectionhelper']) ? $config['system']['enablenatreflectionhelper'] : null; + $pconfig['reflectiontimeout'] = !empty($config['system']['reflectiontimeout']) ? $config['system']['reflectiontimeout'] : null; + $pconfig['bypassstaticroutes'] = isset($config['filter']['bypassstaticroutes']); + $pconfig['disablescrub'] = isset($config['system']['disablescrub']); + $pconfig['ftp-proxy-client'] = isset($config['system']['ftp-proxy']['client']); + $pconfig['disablevpnrules'] = isset($config['system']['disablevpnrules']); +} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { $pconfig = $_POST; + $old_aliasesresolveinterval = $config['system']['aliasesresolveinterval']; + $input_errors = array(); /* input validation */ - if ((empty($_POST['adaptivestart']) && !empty($_POST['adaptiveend'])) || (!empty($_POST['adaptivestart']) && empty($_POST['adaptiveend']))) { + if ((empty($pconfig['adaptivestart']) && !empty($pconfig['adaptiveend'])) || (!empty($pconfig['adaptivestart']) && empty($pconfig['adaptiveend']))) { $input_errors[] = gettext("The Firewall Adaptive values must be set together."); } - if (!empty($_POST['adaptivestart']) && !is_numericint($_POST['adaptivestart'])) { + if (!empty($pconfig['adaptivestart']) && !is_numericint($pconfig['adaptivestart'])) { $input_errors[] = gettext("The Firewall Adaptive Start value must be an integer."); } - if (!empty($_POST['adaptiveend']) && !is_numericint($_POST['adaptiveend'])) { + if (!empty($pconfig['adaptiveend']) && !is_numericint($pconfig['adaptiveend'])) { $input_errors[] = gettext("The Firewall Adaptive End value must be an integer."); } - if ($_POST['maximumstates'] && !is_numericint($_POST['maximumstates'])) { + if (!empty($pconfig['maximumstates']) && !is_numericint($pconfig['maximumstates'])) { $input_errors[] = gettext("The Firewall Maximum States value must be an integer."); } - if ($_POST['aliasesresolveinterval'] && !is_numericint($_POST['aliasesresolveinterval'])) { + if (!empty($pconfig['aliasesresolveinterval']) && !is_numericint($pconfig['aliasesresolveinterval'])) { $input_errors[] = gettext("The Aliases Hostname Resolve Interval value must be an integer."); } - if ($_POST['maximumtableentries'] && !is_numericint($_POST['maximumtableentries'])) { + if (!empty($pconfig['maximumtableentries']) && !is_numericint($pconfig['maximumtableentries'])) { $input_errors[] = gettext("The Firewall Maximum Table Entries value must be an integer."); } - if ($_POST['tcpidletimeout'] && !is_numericint($_POST['tcpidletimeout'])) { - $input_errors[] = gettext("The TCP idle timeout must be an integer."); - } - if ($_POST['reflectiontimeout'] && !is_numericint($_POST['reflectiontimeout'])) { + if (!empty($pconfig['reflectiontimeout']) && !is_numericint($pconfig['reflectiontimeout'])) { $input_errors[] = gettext("The Reflection timeout must be an integer."); } - - ob_flush(); - flush(); - - if (!$input_errors) { - if ($_POST['disablefilter'] == "yes") { + if (count($input_errors) == 0) { + if (!empty($pconfig['disablefilter'])) { $config['system']['disablefilter'] = "enabled"; - } else { + } elseif (isset($config['system']['disablefilter'])) { unset($config['system']['disablefilter']); } - if ($_POST['disablevpnrules'] == "yes") { + if (!empty($pconfig['disablevpnrules'])) { $config['system']['disablevpnrules'] = true; - } else { + } elseif (isset($config['system']['disablevpnrules'])) { unset($config['system']['disablevpnrules']); } - if ($_POST['rfc959workaround'] == "yes") { - $config['system']['rfc959workaround'] = "enabled"; - } else { - unset($config['system']['rfc959workaround']); - } - if ($_POST['scrubnodf'] == "yes") { + if (!empty($pconfig['scrubnodf'])) { $config['system']['scrubnodf'] = "enabled"; - } else { + } elseif (isset($config['system']['scrubnodf'])) { unset($config['system']['scrubnodf']); } - if ($_POST['scrubrnid'] == "yes") { + if (!empty($pconfig['scrubrnid'])) { $config['system']['scrubrnid'] = "enabled"; - } else { + } elseif (isset($config['system']['scrubrnid'])) { unset($config['system']['scrubrnid']); } - if (!empty($_POST['adaptiveend'])) { - $config['system']['adaptiveend'] = $_POST['adaptiveend']; - } else { + if (!empty($pconfig['adaptiveend'])) { + $config['system']['adaptiveend'] = $pconfig['adaptiveend']; + } elseif (isset($config['system']['adaptiveend'])) { unset($config['system']['adaptiveend']); } - if (!empty($_POST['adaptivestart'])) { - $config['system']['adaptivestart'] = $_POST['adaptivestart']; - } else { + if (!empty($pconfig['adaptivestart'])) { + $config['system']['adaptivestart'] = $pconfig['adaptivestart']; + } elseif (isset($config['system']['adaptivestart'])) { unset($config['system']['adaptivestart']); } - if ($_POST['checkaliasesurlcert'] == "yes") { + if (!empty($pconfig['checkaliasesurlcert'])) { $config['system']['checkaliasesurlcert'] = true; - } else { + } elseif (isset($config['system']['checkaliasesurlcert'])) { unset($config['system']['checkaliasesurlcert']); } - $config['system']['optimization'] = $_POST['optimization']; - $config['system']['maximumstates'] = $_POST['maximumstates']; - $config['system']['aliasesresolveinterval'] = $_POST['aliasesresolveinterval']; - $config['system']['maximumtableentries'] = $_POST['maximumtableentries']; - - if ($_POST['natreflection'] == "proxy") { + if ($pconfig['natreflection'] == "proxy") { unset($config['system']['disablenatreflection']); unset($config['system']['enablenatreflectionpurenat']); - } elseif ($_POST['natreflection'] == "purenat") { + } elseif ($pconfig['natreflection'] == "purenat") { unset($config['system']['disablenatreflection']); $config['system']['enablenatreflectionpurenat'] = "yes"; } else { $config['system']['disablenatreflection'] = "yes"; - unset($config['system']['enablenatreflectionpurenat']); + if (isset($config['system']['enablenatreflectionpurenat'])) { + unset($config['system']['enablenatreflectionpurenat']); + } } - if ($_POST['enablebinatreflection'] == "yes") { + if (!empty($pconfig['enablebinatreflection'])) { $config['system']['enablebinatreflection'] = "yes"; - } else { + } elseif (isset($config['system']['enablebinatreflection'])) { unset($config['system']['enablebinatreflection']); } - if ($_POST['disablereplyto'] == "yes") { - $config['system']['disablereplyto'] = $_POST['disablereplyto']; - } else { + if (!empty($pconfig['disablereplyto'])) { + $config['system']['disablereplyto'] = $pconfig['disablereplyto']; + } elseif (isset($config['system']['disablereplyto'])) { unset($config['system']['disablereplyto']); } - if ($_POST['disablenegate'] == "yes") { - $config['system']['disablenegate'] = $_POST['disablenegate']; - } else { + if (!empty($pconfig['disablenegate'])) { + $config['system']['disablenegate'] = $pconfig['disablenegate']; + } elseif (isset($config['system']['disablenegate'])) { unset($config['system']['disablenegate']); } - if ($_POST['enablenatreflectionhelper'] == "yes") { + if (!empty($pconfig['enablenatreflectionhelper'])) { $config['system']['enablenatreflectionhelper'] = "yes"; - } else { + } elseif (isset($config['system']['enablenatreflectionhelper'])) { unset($config['system']['enablenatreflectionhelper']); } - $config['system']['reflectiontimeout'] = $_POST['reflectiontimeout']; + $config['system']['optimization'] = $pconfig['optimization']; + $config['system']['maximumstates'] = $pconfig['maximumstates']; + $config['system']['aliasesresolveinterval'] = $pconfig['aliasesresolveinterval']; + $config['system']['maximumtableentries'] = $pconfig['maximumtableentries']; + $config['system']['reflectiontimeout'] = $pconfig['reflectiontimeout']; - if ($_POST['bypassstaticroutes'] == "yes") { - $config['filter']['bypassstaticroutes'] = $_POST['bypassstaticroutes']; - } elseif (isset($config['filter']['bypassstaticroutes'])) + if (!empty($pconfig['bypassstaticroutes'])) { + $config['filter']['bypassstaticroutes'] = $pconfig['bypassstaticroutes']; + } elseif (isset($config['filter']['bypassstaticroutes'])) { unset($config['filter']['bypassstaticroutes']); + } - if ($_POST['disablescrub'] == "yes") { - $config['system']['disablescrub'] = $_POST['disablescrub']; - } else { + if (!empty($pconfig['disablescrub'])) { + $config['system']['disablescrub'] = $pconfig['disablescrub']; + } elseif (isset($config['system']['disablescrub'])) { unset($config['system']['disablescrub']); } - if ($_POST['ftp-proxy-client'] == 'yes') { + if (!empty($pconfig['ftp-proxy-client'])) { $config['system']['ftp-proxy']['client'] = true; - } else { + } elseif (isset($config['system']['ftp-proxy']['client'])) { unset($config['system']['ftp-proxy']['client']); } - if ($_POST['bogonsinterval'] != $config['system']['bogons']['interval']) { - switch ($_POST['bogonsinterval']) { + if ($pconfig['bogonsinterval'] != $config['system']['bogons']['interval']) { + switch ($pconfig['bogonsinterval']) { case 'daily': install_cron_job("/usr/local/etc/rc.update_bogons", true, "1", "3", "*", "*", "*"); break; @@ -218,7 +214,7 @@ if ($_POST) { default: install_cron_job("/usr/local/etc/rc.update_bogons", true, "1", "3", "1", "*", "*"); } - $config['system']['bogons']['interval'] = $_POST['bogonsinterval']; + $config['system']['bogons']['interval'] = $pconfig['bogonsinterval']; } write_config(); @@ -238,378 +234,369 @@ if ($_POST) { } } +legacy_html_escape_form_data($pconfig); + $pgtitle = array(gettext("System"),gettext("Settings"),gettext("Firewall and NAT")); include("head.inc"); - ?> - - - - - - + +
-
- -
- 0) { - print_input_errors($input_errors); - } - if (isset($savemsg)) { - print_info_box($savemsg); - } - ?> -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + +
- /> -
- -
- /> -
- -
- -
- - -
- -
- /> - -
-
-
- ', '' - )?> -
-
- /> - -
-
- -
- -
- -
- -
-
- -
- -
- -
- -
- -
- -
- - - +
+ 0) { + print_input_errors($input_errors); + } + if (isset($savemsg)) { + print_info_box($savemsg); + } ?> - - +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1) :?> + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1) : -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ + +
+ /> + +
+ /> + +
+ + +
+ /> + +
+ /> + +
+ + + + + + + + + + + + + +
+ + + +
+ +
+ + +
+ + +
+ /> + +
+ /> + +
+ /> + +
+ /> + +
+ + +
+ /> + +
+ + +
+ + +
+ + +
+ /> + +
+ /> + +
+ /> + +
- /> - -
- -
-
- /> - -
- - -
- /> - -
- -
-
- /> - -
- -
-
- -
- -
- -
- /> - -
- -
-
- -
- -
- -
- -

- -

- -

- -
-
- -

- -
- /> - -

- -

- -
- /> - -
- -

- -
- /> - -
- -
 " />
- -
- -
- +
" />
+ +
+
+
+
-