mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 00:07:26 +00:00
wizard: reimplement system setup (#8378)
* wizard: reimplement system setup, for https://github.com/opnsense/core/issues/8352 This commit implements our replacement for the setup wizard. The questions are roughly the same as in the legacy version. Some less relevant options have been removed (pppoe ondemand for example) and isc-dhcpd has been replaced with dnsmasq. Only standard tools have been used, a memory model to validate the data and simple input forms in tabs. The in memory model acts as a wrapper around a legacy configuration data and a couple of component models to apply the requested settings. Some legacy settings using isset() have been altered to use their empty() equivalent. * wizard: as we're changing to dnsmasq as default, we need to make sure the console setup configures the same (https://github.com/opnsense/core/issues/8352) Fix some small php arnings in the process, but further than that just rewrite the dhcpd console handling to use dnsmasq instead of isc. Eventually we will need to rewrite the console tools as well, but let's try to keep this compatible with minimal impact. * wizard: change other occurrences of isset($config['dnsallowoverride']) for https://github.com/opnsense/core/issues/8352 * wizard: sort listtags() and some other minor review comments for https://github.com/opnsense/core/issues/8352
This commit is contained in:
parent
d32ec31f79
commit
592a62b0df
15
plist
15
plist
@ -247,6 +247,7 @@
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/Api/HasyncController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/Api/HasyncStatusController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/Api/InitialSetupController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/Api/MenuController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/Api/ServiceController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/Api/SnapshotsController.php
|
||||
@ -259,6 +260,7 @@
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/HasyncController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/HasyncStatusController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/IndexController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/InitialSetupController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/LicenseController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/RebootController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/ServiceController.php
|
||||
@ -267,6 +269,10 @@
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/forms/hasyncSettings.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/forms/snapshot.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/forms/tunable.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/forms/wizard_general_info.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/forms/wizard_network_lan.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/forms/wizard_network_wan.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Core/forms/wizard_root_password.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Cron/Api/ServiceController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Cron/IndexController.php
|
||||
@ -686,6 +692,8 @@
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Core/Firmware.xml
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Core/Hasync.php
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Core/Hasync.xml
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Core/InitialSetup.php
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Core/InitialSetup.xml
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Core/Menu/Menu.xml
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Core/Migrations/M1_0_0.php
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Core/Migrations/M1_0_1.php
|
||||
@ -904,6 +912,7 @@
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Core/halt.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Core/hasync.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Core/hasync_status.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Core/initial_setup.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Core/license.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Core/not_found.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Core/reboot.volt
|
||||
@ -1309,6 +1318,7 @@
|
||||
/usr/local/opnsense/scripts/system/crl_fetch.py
|
||||
/usr/local/opnsense/scripts/system/flush_config_history
|
||||
/usr/local/opnsense/scripts/system/get_locales.php
|
||||
/usr/local/opnsense/scripts/system/get_timezones.php
|
||||
/usr/local/opnsense/scripts/system/ha_xmlrpc_exec.php
|
||||
/usr/local/opnsense/scripts/system/list_shells.py
|
||||
/usr/local/opnsense/scripts/system/nameservers.php
|
||||
@ -2407,7 +2417,6 @@
|
||||
/usr/local/share/man/man8/opnsense-log.8.gz
|
||||
/usr/local/share/man/man8/opnsense-shell.8.gz
|
||||
/usr/local/share/man/man8/opnsense-version.8.gz
|
||||
/usr/local/wizard/system.xml
|
||||
/usr/local/www/authgui.inc
|
||||
/usr/local/www/crash_reporter.php
|
||||
/usr/local/www/csrf.inc
|
||||
@ -2440,9 +2449,6 @@
|
||||
/usr/local/www/interfaces_wireless.php
|
||||
/usr/local/www/interfaces_wireless_edit.php
|
||||
/usr/local/www/javascript/opnsense_legacy.js
|
||||
/usr/local/www/javascript/wizard/autosuggest.js
|
||||
/usr/local/www/javascript/wizard/disablekeys.js
|
||||
/usr/local/www/javascript/wizard/suggestions.js
|
||||
/usr/local/www/reporting_settings.php
|
||||
/usr/local/www/services_dhcp.php
|
||||
/usr/local/www/services_dhcp_edit.php
|
||||
@ -2470,7 +2476,6 @@
|
||||
/usr/local/www/vpn_ipsec_phase2.php
|
||||
/usr/local/www/vpn_openvpn_client.php
|
||||
/usr/local/www/vpn_openvpn_server.php
|
||||
/usr/local/www/wizard.php
|
||||
/usr/local/www/xmlrpc.php
|
||||
@sample /usr/local/etc/bogons.sample
|
||||
@sample /usr/local/etc/bogonsv6.sample
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
TREES= bin etc libexec man opnsense root sbin wizard www
|
||||
TREES= bin etc libexec man opnsense root sbin www
|
||||
ROOT= /usr/local
|
||||
ROOT_man= /usr/local/share
|
||||
ROOT_root= /
|
||||
|
||||
@ -93,18 +93,19 @@
|
||||
<track6-prefix-id>0</track6-prefix-id>
|
||||
</lan>
|
||||
</interfaces>
|
||||
<dhcpd>
|
||||
<lan>
|
||||
<enable/>
|
||||
<range>
|
||||
<from>192.168.1.100</from>
|
||||
<to>192.168.1.199</to>
|
||||
</range>
|
||||
</lan>
|
||||
</dhcpd>
|
||||
<unbound>
|
||||
<enable>1</enable>
|
||||
</unbound>
|
||||
<dnsmasq>
|
||||
<enable>1</enable>
|
||||
<port>0</port>
|
||||
<interface>lan</interface>
|
||||
<dhcp_ranges>
|
||||
<interface>lan</interface>
|
||||
<start_addr>192.168.1.100</start_addr>
|
||||
<end_addr>192.168.1.199</end_addr>
|
||||
</dhcp_ranges>
|
||||
</dnsmasq>
|
||||
<snmpd>
|
||||
<syslocation/>
|
||||
<syscontact/>
|
||||
|
||||
@ -394,10 +394,22 @@ EOD;
|
||||
$config['interfaces']['lan']['subnetv6'] = '64';
|
||||
}
|
||||
|
||||
config_read_array('dhcpd', 'lan', 'range');
|
||||
$config['dhcpd']['lan']['enable'] = true;
|
||||
$config['dhcpd']['lan']['range']['from'] = '192.168.1.100';
|
||||
$config['dhcpd']['lan']['range']['to'] = '192.168.1.199';
|
||||
if (isset($config['dhcpd']['lan'])) {
|
||||
unset($config['dhcpd']['lan']);
|
||||
}
|
||||
|
||||
config_read_array('dnsmasq', 'dhcp_ranges');
|
||||
foreach ($config['dnsmasq']['dhcp_ranges'] as $idx => $range) {
|
||||
if ($range['interface'] == 'lan') {
|
||||
unset($config['dnsmasq']['dhcp_ranges'][$idx]);
|
||||
}
|
||||
}
|
||||
$config['dnsmasq']['enable'] = '1';
|
||||
$config['dnsmasq']['dhcp_ranges'][] = [
|
||||
'interface' => 'lan',
|
||||
'start_addr' => '192.168.1.100',
|
||||
'end_addr' => '192.168.1.200'
|
||||
];
|
||||
|
||||
config_read_array('nat', 'outbound');
|
||||
$config['nat']['outbound']['mode'] = 'automatic';
|
||||
|
||||
@ -310,13 +310,13 @@ function filter_core_rules_system($fw, $defaults)
|
||||
['from' => "<bogons>", 'direction' => 'in', 'interface' => $intf, 'ipprotocol' => 'inet',
|
||||
'descr' => "Block bogon IPv4 networks from " . $intfinfo['descr'],
|
||||
'#ref' => "interfaces.php?if=" . $intf . "#blockbogons",
|
||||
'disabled' => !isset($intfinfo['blockbogons'])],
|
||||
'disabled' => empty($intfinfo['blockbogons'])],
|
||||
$bogontmpl
|
||||
);
|
||||
$fw->registerFilterRule(
|
||||
5,
|
||||
['from' => "<bogonsv6>", 'direction' => 'in', 'interface' => $intf, 'ipprotocol' => 'inet6',
|
||||
'disabled' => $ipv6_disabled || !isset($intfinfo['blockbogons']),
|
||||
'disabled' => $ipv6_disabled || empty($intfinfo['blockbogons']),
|
||||
'#ref' => "interfaces.php?if=" . $intf . "#blockbogons",
|
||||
'descr' => "Block bogon IPv6 networks from " . $intfinfo['descr']],
|
||||
$bogontmpl
|
||||
@ -326,7 +326,7 @@ function filter_core_rules_system($fw, $defaults)
|
||||
['direction' => 'in', 'interface' => $intf, 'ipprotocol' => 'inet',
|
||||
'#ref' => "interfaces.php?if=" . $intf . "#blockpriv",
|
||||
'descr' => "Block private networks from " . $intfinfo['descr'],
|
||||
'disabled' => !isset($intfinfo['blockpriv'])],
|
||||
'disabled' => empty($intfinfo['blockpriv'])],
|
||||
$privtmpl
|
||||
);
|
||||
$fw->registerFilterRule(
|
||||
@ -334,7 +334,7 @@ function filter_core_rules_system($fw, $defaults)
|
||||
['direction' => 'in', 'interface' => $intf, 'ipprotocol' => 'inet6',
|
||||
'#ref' => "interfaces.php?if=" . $intf . "#blockpriv",
|
||||
'descr' => "Block private networks from " . $intfinfo['descr'], 'from' => 'fc00::/7',
|
||||
'disabled' => $ipv6_disabled || !isset($intfinfo['blockpriv'])],
|
||||
'disabled' => $ipv6_disabled || empty($intfinfo['blockpriv'])],
|
||||
$privtmpl
|
||||
);
|
||||
}
|
||||
|
||||
@ -1104,7 +1104,7 @@ EOD;
|
||||
$mpdconf .= " set ipcp no vjcomp\n";
|
||||
}
|
||||
|
||||
if (isset($config['system']['dnsallowoverride'])) {
|
||||
if (!empty($config['system']['dnsallowoverride'])) {
|
||||
$mpdconf .= " set ipcp enable req-pri-dns\n";
|
||||
$mpdconf .= " set ipcp enable req-sec-dns\n";
|
||||
}
|
||||
|
||||
@ -328,7 +328,7 @@ function get_searchdomains()
|
||||
$master_list[] = $syscfg['dnssearchdomain'];
|
||||
}
|
||||
|
||||
if (isset($syscfg['dnsallowoverride'])) {
|
||||
if (!empty($syscfg['dnsallowoverride'])) {
|
||||
/* return domains as required by configuration */
|
||||
$list = shell_safe('/usr/local/sbin/ifctl -sl');
|
||||
if (!empty($list)) {
|
||||
@ -372,7 +372,7 @@ function get_nameservers($interface = null, $with_gateway = false)
|
||||
if (!empty($list)) {
|
||||
$dns_lists[] = $list;
|
||||
}
|
||||
} elseif (isset($syscfg['dnsallowoverride'])) {
|
||||
} elseif (!empty($syscfg['dnsallowoverride'])) {
|
||||
/* return dynamic servers as required by configuration */
|
||||
$list = shell_safe('/usr/local/sbin/ifctl -nl');
|
||||
if (!empty($list)) {
|
||||
|
||||
@ -33,7 +33,7 @@ function listtags()
|
||||
'acls', 'alias', 'aliasurl', 'allowedip', 'allowedhostname', 'authserver',
|
||||
'bridged', 'build_port_path',
|
||||
'ca', 'cacert', 'cert', 'crl', 'clone', 'config', 'container', 'columnitem',
|
||||
'disk', 'dnsserver', 'dnsupdate', 'domainoverrides',
|
||||
'dhcp_ranges', 'disk', 'dnsserver', 'dnsupdate', 'domainoverrides',
|
||||
'element', 'encryption-algorithm-option',
|
||||
'field', 'fieldname',
|
||||
'gateway_item', 'gateway_group', 'gif', 'gre', 'group',
|
||||
@ -50,7 +50,7 @@ function listtags()
|
||||
'tab', 'timerange', 'tunnel',
|
||||
'user',
|
||||
'vip', 'virtual_server', 'vlan',
|
||||
'winsserver', 'wolentry', 'widget',
|
||||
'winsserver', 'wolentry', 'widget'
|
||||
);
|
||||
|
||||
return array_flip($ret);
|
||||
|
||||
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (c) 2025 Deciso B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace OPNsense\Core\Api;
|
||||
|
||||
use OPNsense\Base\ApiMutableModelControllerBase;
|
||||
use OPNsense\Core\Backend;
|
||||
use OPNsense\Core\Config;
|
||||
|
||||
/**
|
||||
* Class InitialSetupController
|
||||
* @package OPNsense\Core
|
||||
*/
|
||||
class InitialSetupController extends ApiMutableModelControllerBase
|
||||
{
|
||||
protected static $internalModelName = 'wizard';
|
||||
protected static $internalModelClass = 'OPNsense\Core\InitialSetup';
|
||||
|
||||
public function configureAction()
|
||||
{
|
||||
$result = parent::setAction();
|
||||
if ($result['result'] == 'saved') {
|
||||
$result = $this->getModel()->updateConfig();
|
||||
(new Backend())->configdRun("service reload delay", true);
|
||||
return $result;
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2025 Deciso B.V.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OPNsense\Core;
|
||||
|
||||
class InitialSetupController extends \OPNsense\Base\IndexController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->all_tabs = [
|
||||
'step_0' => [
|
||||
'title' => gettext('Welcome'),
|
||||
'message' => gettext(
|
||||
'This wizard will guide you through the initial system configuration. '.
|
||||
'The wizard may be stopped at any time by clicking the logo image at the top of the screen.'
|
||||
)
|
||||
],
|
||||
'step_1' => [
|
||||
'title' => gettext('General Information'),
|
||||
'form' => $this->getForm('wizard_general_info')
|
||||
],
|
||||
'step_2' => [
|
||||
'title' => gettext('Network [WAN]'),
|
||||
'form' => $this->getForm('wizard_network_wan')
|
||||
],
|
||||
'step_3' => [
|
||||
'title' => gettext('Network [LAN]'),
|
||||
'form' => $this->getForm('wizard_network_lan')
|
||||
],
|
||||
'step_4' => [
|
||||
'title' => gettext('Set initial password'),
|
||||
'form' => $this->getForm('wizard_root_password')
|
||||
],
|
||||
'step_final' => [
|
||||
'title' => gettext('Finish'),
|
||||
'message' => gettext(
|
||||
'This is the last step in the wizard, click apply to reconfigure the firewall.'
|
||||
)
|
||||
],
|
||||
];
|
||||
$this->view->pick('OPNsense/Core/initial_setup');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>wizard.hostname</id>
|
||||
<label>Hostname</label>
|
||||
<type>text</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.domain</id>
|
||||
<label>Domain</label>
|
||||
<type>text</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.language</id>
|
||||
<label>Language</label>
|
||||
<type>dropdown</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.dns_servers</id>
|
||||
<label>DNS Servers</label>
|
||||
<type>select_multiple</type>
|
||||
<style>tokenize</style>
|
||||
<allownew>true</allownew>
|
||||
<help>Set primary domain name server IPv4 or IPv6 address. Repeat this option to set secondary DNS server addresses.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.dnsallowoverride</id>
|
||||
<label>Override DNS</label>
|
||||
<type>checkbox</type>
|
||||
<help>Allow DNS servers to be overridden by DHCP/PPP on WAN</help>
|
||||
</field>
|
||||
<field>
|
||||
<type>header</type>
|
||||
<label>DNS [Unbound]</label>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.unbound.enabled</id>
|
||||
<label>Enable Resolver</label>
|
||||
<type>checkbox</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.unbound.dnssec</id>
|
||||
<label>Enable DNSSEC Support</label>
|
||||
<type>checkbox</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.unbound.dnssecstripped</id>
|
||||
<label>Harden DNSSEC data</label>
|
||||
<type>checkbox</type>
|
||||
<help>DNSSEC data is required for trust-anchored zones. If such data is absent, the zone becomes bogus. If this is disabled and no DNSSEC data is received, then the zone is made insecure.</help>
|
||||
</field>
|
||||
<field>
|
||||
<type>header</type>
|
||||
<label><![CDATA[Time & Timezone]]></label>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.timeservers</id>
|
||||
<label>Time Servers</label>
|
||||
<type>select_multiple</type>
|
||||
<style>tokenize</style>
|
||||
<allownew>true</allownew>
|
||||
<help>Hostnames of the timeservers to use to acquire time for this firewall.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.timezone</id>
|
||||
<label>Timezone</label>
|
||||
<type>dropdown</type>
|
||||
</field>
|
||||
</form>
|
||||
@ -0,0 +1,20 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>wizard.interfaces.lan.disable</id>
|
||||
<label>Disable LAN</label>
|
||||
<type>checkbox</type>
|
||||
<help>Disable LAN, usually only relevant in "wan" only scenarios.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.interfaces.lan.ipaddr</id>
|
||||
<label>IP Address</label>
|
||||
<type>text</type>
|
||||
<help>Ip address and cidr to configure on this interface, e.g. 192.168.1.1/24.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.interfaces.lan.configure_dhcp</id>
|
||||
<label>Configure DHCP server</label>
|
||||
<type>checkbox</type>
|
||||
<help>Configure DHCP server for this network, when disabled dhcp services will not be available on this network after finishing the wizard.</help>
|
||||
</field>
|
||||
</form>
|
||||
@ -0,0 +1,83 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>wizard.interfaces.wan.ipv4_type</id>
|
||||
<label>Type</label>
|
||||
<type>dropdown</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.interfaces.wan.spoofmac</id>
|
||||
<label>MAC (spoofed)</label>
|
||||
<type>text</type>
|
||||
<help>Usually this option is left empty, unless your provider requires you to connect using a specific mac address.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.interfaces.wan.mtu</id>
|
||||
<label>MTU</label>
|
||||
<type>text</type>
|
||||
<help>Set the MTU of the WAN interface. If you leave this field blank, an MTU of 1492 bytes for PPPoE and 1500 bytes for all other connection types will be assumed.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.interfaces.wan.mss</id>
|
||||
<label>MSS</label>
|
||||
<type>text</type>
|
||||
<help>If you enter a value in this field, then MSS clamping for TCP connections to the value entered above minus 40 (TCP/IP header size) will be in effect. If you leave this field blank, an MSS of 1492 bytes for PPPoE and 1500 bytes for all other connection types will be assumed. This should match the above MTU value in most all cases.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.interfaces.wan.ipaddr</id>
|
||||
<label>IP Address</label>
|
||||
<type>text</type>
|
||||
<style>wan_options wan_options_static</style>
|
||||
<help>Ip address and cidr to configure on this interface, e.g. 192.168.1.1/24.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.interfaces.wan.gateway</id>
|
||||
<label>Gateway</label>
|
||||
<type>text</type>
|
||||
<style>wan_options wan_options_static</style>
|
||||
<help>Gateway address to use, e.g. 192.168.1.254.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.interfaces.wan.dhcphostname</id>
|
||||
<label>DHCP hostname</label>
|
||||
<type>text</type>
|
||||
<style>wan_options wan_options_dhcp</style>
|
||||
<help>The value in this field is sent as the DHCP client identifier and hostname when requesting a DHCP lease. Some ISPs may require this (for client identification).</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.interfaces.wan.pppoe_username</id>
|
||||
<label>PPPoE Username</label>
|
||||
<type>text</type>
|
||||
<style>wan_options wan_options_pppoe</style>
|
||||
<help></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.interfaces.wan.pppoe_password</id>
|
||||
<label>PPPoE Password</label>
|
||||
<type>password</type>
|
||||
<style>wan_options wan_options_pppoe</style>
|
||||
<help></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.interfaces.wan.pppoe_provider</id>
|
||||
<label>PPPoE Service name</label>
|
||||
<type>text</type>
|
||||
<style>wan_options wan_options_pppoe</style>
|
||||
<help></help>
|
||||
</field>
|
||||
<field>
|
||||
<type>header</type>
|
||||
<label><![CDATA[Default policies]]></label>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.interfaces.wan.blockpriv</id>
|
||||
<label>Block RFC1918 Private Networks</label>
|
||||
<type>checkbox</type>
|
||||
<help>When set, this option blocks traffic from IP addresses that are reserved for private networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as well as loopback addresses (127/8) and Carrier-grade NAT addresses (100.64/10). This option should only be set for WAN interfaces that use the public IP address space.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.interfaces.wan.blockbogons</id>
|
||||
<label>Block bogon networks</label>
|
||||
<type>checkbox</type>
|
||||
<help>When set, this option blocks traffic from IP addresses that are reserved (but not RFC 1918) or not yet assigned by IANA.</help>
|
||||
</field>
|
||||
</form>
|
||||
@ -0,0 +1,13 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>wizard.password</id>
|
||||
<label>Root Password</label>
|
||||
<type>password</type>
|
||||
<help>Leave empty to keep current one</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>wizard.password_confirm</id>
|
||||
<label>Root Password Confirmation</label>
|
||||
<type>password</type>
|
||||
</field>
|
||||
</form>
|
||||
@ -365,7 +365,8 @@
|
||||
<page-wizard-system>
|
||||
<name>System Setup Wizard</name>
|
||||
<patterns>
|
||||
<pattern>wizard.php?xml=system</pattern>
|
||||
<pattern>ui/core/initial_setup</pattern>
|
||||
<pattern>api/core/initial_setup/*</pattern>
|
||||
</patterns>
|
||||
</page-wizard-system>
|
||||
<page-services-dhcpserver-editstaticmapping>
|
||||
|
||||
384
src/opnsense/mvc/app/models/OPNsense/Core/InitialSetup.php
Normal file
384
src/opnsense/mvc/app/models/OPNsense/Core/InitialSetup.php
Normal file
@ -0,0 +1,384 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2025 Deciso B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace OPNsense\Core;
|
||||
|
||||
use OPNsense\Base\BaseModel;
|
||||
use OPNsense\Base\Messages\Message;
|
||||
use OPNsense\Core\Config;
|
||||
use OPNsense\Auth\User;
|
||||
use OPNsense\Firewall\Util;
|
||||
use OPNsense\Dnsmasq\Dnsmasq;
|
||||
use OPNsense\Routing\Gateways;
|
||||
|
||||
|
||||
/**
|
||||
* wrapper model class to update various configuration parts in a controlled way for the setup wizard
|
||||
*/
|
||||
class InitialSetup extends BaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $path dot seperated path to collect
|
||||
* @param bool $isBoolean return as boolean value 0/1
|
||||
* @return string
|
||||
*/
|
||||
private function getConfigItem(string $path, bool $isBoolean=false)
|
||||
{
|
||||
$node = Config::getInstance()->object();
|
||||
foreach(explode('.', $path) as $item) {
|
||||
if (isset($node->$item)) {
|
||||
$node = $node->$item;
|
||||
} else {
|
||||
return $isBoolean ? '0' : '';
|
||||
}
|
||||
}
|
||||
if (count($node) > 1) {
|
||||
$tmp = [];
|
||||
foreach ($node as $item) {
|
||||
$tmp[] = (string)$item;
|
||||
}
|
||||
return implode(',', $tmp);
|
||||
}
|
||||
if ($isBoolean && (string)$node == '') {
|
||||
return '0';
|
||||
} else {
|
||||
return (string)$node;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* setup initial values, read from configuration
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
$this->hostname = $this->getConfigItem('system.hostname');
|
||||
$this->domain = $this->getConfigItem('system.domain');
|
||||
$this->language = $this->getConfigItem('system.language');
|
||||
if ($this->language->isEmpty()) {
|
||||
$this->language = 'en_US';
|
||||
}
|
||||
$this->dns_servers = $this->getConfigItem('system.dnsserver');
|
||||
$this->timeservers = str_replace(' ', ',', $this->getConfigItem('system.timeservers'));
|
||||
$this->timezone = $this->getConfigItem('system.timezone');
|
||||
if ($this->timezone->isEmpty()) {
|
||||
$this->timezone = 'Etc/UTC';
|
||||
}
|
||||
$this->unbound->enabled = $this->getConfigItem('OPNsense.unboundplus.general.enabled', true);
|
||||
$this->unbound->dnssec = $this->getConfigItem('OPNsense.unboundplus.general.dnssec', true);
|
||||
$this->unbound->dnssecstripped = $this->getConfigItem('OPNsense.unboundplus.advanced.dnssecstripped');
|
||||
if (str_starts_with($this->getConfigItem('interfaces.wan.if'), 'pppoe')) {
|
||||
$ipv4_type = 'pppoe';
|
||||
} elseif ($this->getConfigItem('interfaces.wan.ipaddr') == 'dhcp') {
|
||||
$ipv4_type = 'dhcp';
|
||||
} else {
|
||||
$ipv4_type = 'static';
|
||||
}
|
||||
$this->interfaces->wan->ipv4_type = $ipv4_type;
|
||||
$this->interfaces->wan->spoofmac = $this->getConfigItem('interfaces.wan.spoofmac');
|
||||
$this->interfaces->wan->mtu = $this->getConfigItem('interfaces.wan.mtu');
|
||||
$this->interfaces->wan->mss = $this->getConfigItem('interfaces.wan.mss');
|
||||
$this->interfaces->wan->dhcphostname = $this->getConfigItem('interfaces.wan.dhcphostname');
|
||||
$this->interfaces->wan->blockpriv = $this->getConfigItem('interfaces.wan.blockpriv', true);
|
||||
$this->interfaces->wan->blockbogons = $this->getConfigItem('interfaces.wan.blockbogons', true);
|
||||
|
||||
if ($ipv4_type == 'static') {
|
||||
$this->interfaces->wan->ipaddr = sprintf(
|
||||
"%s/%s",
|
||||
$this->getConfigItem('interfaces.wan.ipaddr'),
|
||||
$this->getConfigItem('interfaces.wan.subnet')
|
||||
);
|
||||
} elseif ($ipv4_type == 'pppoe') {
|
||||
$pppoeif = $this->getConfigItem('interfaces.wan.if');
|
||||
foreach (Config::getInstance()->object()->ppps->children() as $ppp) {
|
||||
if ($ppp->if == $pppoeif) {
|
||||
$this->interfaces->wan->pppoe_username = (string)$ppp->username;
|
||||
if (!empty((string)$ppp->password)) {
|
||||
$this->interfaces->wan->pppoe_password = base64_decode((string)$ppp->password);
|
||||
}
|
||||
$this->interfaces->wan->pppoe_provider = (string)$ppp->provider;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->interfaces->lan->ipaddr = sprintf(
|
||||
"%s/%s",
|
||||
$this->getConfigItem('interfaces.lan.ipaddr'),
|
||||
$this->getConfigItem('interfaces.lan.subnet')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function performValidation($validateFullModel = false)
|
||||
{
|
||||
$messages = parent::performValidation($validateFullModel);
|
||||
if ((string)$this->password != (string)$this->password_confirm) {
|
||||
$messages->appendMessage(
|
||||
new Message(
|
||||
gettext("The passwords do not match."),
|
||||
"password"
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($this->interfaces->wan->ipv4_type == 'pppoe') {
|
||||
/* PPPoE requires credentials */
|
||||
if ($this->interfaces->wan->pppoe_username->isEmpty()) {
|
||||
$messages->appendMessage(
|
||||
new Message(
|
||||
gettext("A username is required."),
|
||||
"interfaces.wan.pppoe_username"
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($this->interfaces->wan->pppoe_password->isEmpty()) {
|
||||
$messages->appendMessage(
|
||||
new Message(
|
||||
gettext("A password is required."),
|
||||
"interfaces.wan.pppoe_password"
|
||||
)
|
||||
);
|
||||
}
|
||||
} elseif ($this->interfaces->wan->ipv4_type == 'static') {
|
||||
if (!empty($this->interfaces->wan->gateway) &&
|
||||
!Util::isIPInCIDR($this->interfaces->wan->gateway, $this->interfaces->wan->ipaddr)
|
||||
) {
|
||||
$messages->appendMessage(
|
||||
new Message(
|
||||
gettext("Please make sure the gateway address is reachable from the choosen subnet."),
|
||||
"interfaces.wan.gateway"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->interfaces->lan->disable == '0') {
|
||||
$cnt = count(iterator_to_array(Util::cidrRangeIterator($this->interfaces->lan->ipaddr)));
|
||||
if (!$this->interfaces->lan->configure_dhcp->isEmpty() && $cnt < 50) {
|
||||
$messages->appendMessage(
|
||||
new Message(
|
||||
gettext("Automatic DHCP server configuration is only supported for networks larger than /27."),
|
||||
"interfaces.lan.configure_dhcp"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* flush general settings from in-memory model back to config
|
||||
*/
|
||||
private function flush_general()
|
||||
{
|
||||
$target = Config::getInstance()->object();
|
||||
/* system settings */
|
||||
$target->system->timeservers = str_replace(',', ' ', (string)$this->timeservers);
|
||||
$target->system->timezone = (string)$this->timezone;
|
||||
unset($target->system->dnsserver);
|
||||
foreach ( explode(',', (string)$this->dns_servers) as $dnsserver) {
|
||||
$target->system->addChild('dnsserver', $dnsserver);
|
||||
}
|
||||
$target->system->dnsallowoverride = (string)$this->dnsallowoverride;
|
||||
$target->system->language = (string)$this->language;
|
||||
$target->system->hostname = (string)$this->hostname;
|
||||
$target->system->domain = (string)$this->domain;
|
||||
|
||||
/* configure unbound dns */
|
||||
$target->OPNsense->unboundplus->general->enabled = (string)$this->unbound->enabled;
|
||||
$target->OPNsense->unboundplus->general->dnssec = (string)$this->unbound->dnssec;
|
||||
$target->OPNsense->unboundplus->advanced->dnssecstripped = (string)$this->unbound->dnssecstripped;
|
||||
}
|
||||
|
||||
/**
|
||||
* flush wan interface configuration from in-memory model back to config
|
||||
*/
|
||||
private function flush_network_wan()
|
||||
{
|
||||
$target = Config::getInstance()->object();
|
||||
/* configure wan */
|
||||
$gateways = new Gateways();
|
||||
foreach ($gateways->gateway_item->iterateItems() as $uuid => $node) {
|
||||
if ($node->interface == 'wan' && $node->ipprotocol == 'inet') {
|
||||
$gateways->gateway_item->del($uuid);
|
||||
}
|
||||
}
|
||||
|
||||
$wanif = $this->getConfigItem('interfaces.wan.if');
|
||||
if ($this->interfaces->wan->ipv4_type == 'pppoe') {
|
||||
/* PPPoE configuration will nest interfaces, make sure we can still update the interface once configured */
|
||||
if (!isset($target->ppps)) {
|
||||
$target->addChild('ppps');
|
||||
}
|
||||
$pppoe_idx = -1;
|
||||
$max_ptpid = 0;
|
||||
for ($idx = 0 ; $idx < count($target->ppps->ppp); ++$idx) {
|
||||
if ($target->ppps->ppp[$idx]->if == $wanif) {
|
||||
$pppoe_idx = $idx;
|
||||
}
|
||||
$max_ptpid = max($max_ptpid, $target->ppps->ppp[$idx]->ptpid);
|
||||
}
|
||||
|
||||
if ($pppoe_idx == -1) {
|
||||
/* add pppoe on top of current configured wan */
|
||||
$node = $target->ppps->addChild('ppp');
|
||||
$node->addChild('ports', $wanif);
|
||||
$node->addChild('ptpid', (string)($max_ptpid + 1));
|
||||
$node->addChild('if', 'pppoe' . $node->ptpid);
|
||||
$target->interfaces->wan->if = (string)$node->if;
|
||||
} else {
|
||||
$node = $target->ppps->ppp[$pppoe_idx];
|
||||
}
|
||||
$node->type = 'pppoe';
|
||||
$node->username = (string)$this->interfaces->wan->pppoe_username;
|
||||
$node->password = base64_encode((string)$this->interfaces->wan->pppoe_password);
|
||||
|
||||
}
|
||||
unset($target->interfaces->wan->dhcphostname);
|
||||
if (in_array($this->interfaces->wan->ipv4_type, ['pppoe', 'dhcp'])) {
|
||||
$target->interfaces->wan->ipaddr = (string)$this->interfaces->wan->ipv4_type;
|
||||
$target->interfaces->wan->subnet = '';
|
||||
if ($this->interfaces->wan->ipv4_type == 'dhcp') {
|
||||
$target->interfaces->wan->dhcphostname = (string)$this->interfaces->wan->dhcphostname;
|
||||
}
|
||||
} else {
|
||||
$parts = explode('/', $this->interfaces->wan->ipaddr);
|
||||
$target->interfaces->wan->ipaddr = $parts[0];
|
||||
$target->interfaces->wan->subnet = $parts[1];
|
||||
if (!$this->interfaces->wan->gateway->isEmpty()) {
|
||||
$gateways->createOrUpdateGateway([
|
||||
'interface' => 'wan',
|
||||
'gateway' => (string)$this->interfaces->wan->gateway,
|
||||
'name' => 'WAN_GW',
|
||||
'weight' => 1,
|
||||
'monitor_disable' => 1,
|
||||
'descr' => "WAN Gateway",
|
||||
'defaultgw' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
$target->interfaces->wan->enable = '1';
|
||||
$target->interfaces->wan->spoofmac = (string)$this->interfaces->wan->spoofmac;
|
||||
$target->interfaces->wan->mtu = (string)$this->interfaces->wan->mtu;
|
||||
$target->interfaces->wan->mss = (string)$this->interfaces->wan->mss;
|
||||
$target->interfaces->wan->blockpriv = (string)$this->interfaces->wan->blockpriv;
|
||||
$target->interfaces->wan->blockbogons = (string)$this->interfaces->wan->blockbogons;
|
||||
$gateways->serializeToConfig(false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* flush lan interface configuration from in-memory model back to config
|
||||
*/
|
||||
private function flush_network_lan()
|
||||
{
|
||||
$target = Config::getInstance()->object();
|
||||
/* configure lan */
|
||||
if (!isset($target->interfaces->lan)) {
|
||||
$target->interfaces->addChild('lan');
|
||||
}
|
||||
$target->interfaces->lan->enable = $this->interfaces->lan->disable->isEmpty() ? '1' : '0';
|
||||
$dnsmasq = new Dnsmasq();
|
||||
foreach ($dnsmasq->dhcp_ranges->iterateItems() as $uuid => $node) {
|
||||
if ($node->interface == 'lan') {
|
||||
/* always remove lan dhcp ranges */
|
||||
$dnsmasq->dhcp_ranges->del($uuid);
|
||||
}
|
||||
}
|
||||
if ($target->interfaces->lan->enable == '1') {
|
||||
$parts = explode('/', $this->interfaces->lan->ipaddr);
|
||||
$target->interfaces->lan->ipaddr = $parts[0];
|
||||
$target->interfaces->lan->subnet = $parts[1];
|
||||
// configure_dhcp
|
||||
if (!$this->interfaces->lan->configure_dhcp->isEmpty()) {
|
||||
$avail_addrs = iterator_to_array(Util::cidrRangeIterator($this->interfaces->lan->ipaddr));
|
||||
if (!$dnsmasq->interface->isEmpty() && !in_array('lan', explode(',', $dnsmasq->interface))) {
|
||||
$dnsmasq->interface = (string)$dnsmasq->interface . ',lan';
|
||||
}
|
||||
$dnsmasq->port = '0';
|
||||
$dnsmasq->enable = '1';
|
||||
$dhcprange = $dnsmasq->dhcp_ranges->Add();
|
||||
$dhcprange->interface = 'lan';
|
||||
$dhcprange->start_addr = $avail_addrs[40];
|
||||
$dhcprange->end_addr = $avail_addrs[count($avail_addrs)-10];
|
||||
}
|
||||
}
|
||||
$dnsmasq->serializeToConfig(false, true);
|
||||
/* forcefully disable isc dhcpd when enabled */
|
||||
if (isset($target->dhcpd)) {
|
||||
foreach ($target->dhcpd->children() as $node) {
|
||||
unset($node->enable);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* reset root password when offered
|
||||
*/
|
||||
private function flush_initial_pass()
|
||||
{
|
||||
/* update root password */
|
||||
if (!$this->password->isEmpty()) {
|
||||
$usermdl = new User();
|
||||
$rootuser = $usermdl->getUserByName('root');
|
||||
if ($rootuser) {
|
||||
$hash = $usermdl->generatePasswordHash((string)$this->password);
|
||||
if ($hash !== false && strpos($hash, '$') === 0) {
|
||||
$rootuser->password = $hash;
|
||||
$usermdl->serializeToConfig(false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* remove initial wizard tag
|
||||
*/
|
||||
private function unset_initial_wizard()
|
||||
{
|
||||
unset(Config::getInstance()->object()->trigger_initial_wizard);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* update configuration
|
||||
*/
|
||||
public function updateConfig()
|
||||
{
|
||||
$this->flush_general();
|
||||
$this->flush_network_wan();
|
||||
$this->flush_network_lan();
|
||||
$this->flush_initial_pass();
|
||||
$this->unset_initial_wizard();
|
||||
|
||||
Config::getInstance()->save();
|
||||
return ['status' => 'done'];
|
||||
}
|
||||
}
|
||||
100
src/opnsense/mvc/app/models/OPNsense/Core/InitialSetup.xml
Normal file
100
src/opnsense/mvc/app/models/OPNsense/Core/InitialSetup.xml
Normal file
@ -0,0 +1,100 @@
|
||||
<model>
|
||||
<mount>:memory:</mount>
|
||||
<version>1.0.0</version>
|
||||
<description>Initial setup wizard</description>
|
||||
<items>
|
||||
<hostname type="HostnameField">
|
||||
<IsDNSName>N</IsDNSName>
|
||||
<IpAllowed>N</IpAllowed>
|
||||
<Required>Y</Required>
|
||||
</hostname>
|
||||
<domain type="HostnameField">
|
||||
<IsDNSName>N</IsDNSName>
|
||||
<IpAllowed>N</IpAllowed>
|
||||
<Required>Y</Required>
|
||||
</domain>
|
||||
<language type="JsonKeyValueStoreField">
|
||||
<ConfigdPopulateAct>system list locales</ConfigdPopulateAct>
|
||||
<Required>Y</Required>
|
||||
</language>
|
||||
<dns_servers type="NetworkField">
|
||||
<NetMaskAllowed>N</NetMaskAllowed>
|
||||
<FieldSeparator>,</FieldSeparator>
|
||||
<asList>Y</asList>
|
||||
</dns_servers>
|
||||
<dnsallowoverride type="BooleanField">
|
||||
<Required>Y</Required>
|
||||
</dnsallowoverride>
|
||||
<unbound>
|
||||
<enabled type="BooleanField">
|
||||
<Required>Y</Required>
|
||||
</enabled>
|
||||
<dnssec type="BooleanField">
|
||||
<Required>Y</Required>
|
||||
</dnssec>
|
||||
<dnssecstripped type="BooleanField">
|
||||
<Required>Y</Required>
|
||||
</dnssecstripped>
|
||||
</unbound>
|
||||
<timeservers type="HostnameField">
|
||||
<AsList>Y</AsList>
|
||||
<FieldSeparator>,</FieldSeparator>
|
||||
<IsDNSName>Y</IsDNSName>
|
||||
</timeservers>
|
||||
<timezone type="JsonKeyValueStoreField">
|
||||
<ConfigdPopulateAct>system list timezones</ConfigdPopulateAct>
|
||||
<Required>Y</Required>
|
||||
</timezone>
|
||||
<interfaces>
|
||||
<wan>
|
||||
<ipv4_type type="OptionField">
|
||||
<Required>Y</Required>
|
||||
<Default>static</Default>
|
||||
<OptionValues>
|
||||
<static>Static</static>
|
||||
<dhcp>DHCP</dhcp>
|
||||
<pppoe>PPPoE</pppoe>
|
||||
</OptionValues>
|
||||
</ipv4_type>
|
||||
<spoofmac type="MacAddressField"/>
|
||||
<mtu type="IntegerField">
|
||||
<MinimumValue>576</MinimumValue>
|
||||
<MaximumValue>65535</MaximumValue>
|
||||
</mtu>
|
||||
<mss type="IntegerField">
|
||||
<MinimumValue>576</MinimumValue>
|
||||
<MaximumValue>65535</MaximumValue>
|
||||
</mss>
|
||||
<ipaddr type="NetworkField">
|
||||
<NetMaskRequired>Y</NetMaskRequired>
|
||||
<ValidationMessage>Please specify a valid address and cidr mask to use.</ValidationMessage>
|
||||
</ipaddr>
|
||||
<gateway type="NetworkField">
|
||||
<NetMaskAllowed>N</NetMaskAllowed>
|
||||
</gateway>
|
||||
<dhcphostname type="HostnameField">
|
||||
<IsDNSName>Y</IsDNSName>
|
||||
<IpAllowed>N</IpAllowed>
|
||||
</dhcphostname>
|
||||
<pppoe_username type="TextField"/>
|
||||
<pppoe_password type="TextField"/>
|
||||
<pppoe_provider type="TextField"/>
|
||||
<blockpriv type="BooleanField"/>
|
||||
<blockbogons type="BooleanField"/>
|
||||
</wan>
|
||||
<lan>
|
||||
<ipaddr type="NetworkField">
|
||||
<NetMaskRequired>Y</NetMaskRequired>
|
||||
<ValidationMessage>Please specify a valid address and cidr mask to use.</ValidationMessage>
|
||||
</ipaddr>
|
||||
<disable type="BooleanField"/>
|
||||
<configure_dhcp type="BooleanField">
|
||||
<Required>Y</Required>
|
||||
<Default>1</Default>
|
||||
</configure_dhcp>
|
||||
</lan>
|
||||
</interfaces>
|
||||
<password type="TextField"/>
|
||||
<password_confirm type="TextField"/>
|
||||
</items>
|
||||
</model>
|
||||
@ -72,7 +72,7 @@
|
||||
<Revocation url="/ui/trust/crl"/>
|
||||
<Settings url="/ui/trust/settings"/>
|
||||
</Trust>
|
||||
<Wizard url="/wizard.php?xml=system" cssClass="fa fa-magic fa-fw"/>
|
||||
<Wizard url="/ui/core/initial_setup" cssClass="fa fa-magic fa-fw"/>
|
||||
<LogFiles order="150" VisibleName="Log Files" cssClass="fa fa-eye fa-fw">
|
||||
<Audit url="/ui/diagnostics/log/core/audit"/>
|
||||
<Backend url="/ui/diagnostics/log/core/configd"/>
|
||||
|
||||
92
src/opnsense/mvc/app/views/OPNsense/Core/initial_setup.volt
Normal file
92
src/opnsense/mvc/app/views/OPNsense/Core/initial_setup.volt
Normal file
@ -0,0 +1,92 @@
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
mapDataToFormUI({'frm_wizard':"/api/core/initial_setup/get"}).done(function(data){
|
||||
formatTokenizersUI();
|
||||
$('.selectpicker').selectpicker('refresh');
|
||||
});
|
||||
/* next pane */
|
||||
$(".action_next").click(function(){
|
||||
let target = $("#tab_" + $(this).data('next_index'));
|
||||
let this_form = $(this).closest('.tab-pane').find('form');
|
||||
saveFormToEndpoint("/api/core/initial_setup/set", 'form_root', function(){
|
||||
target.parent().removeClass('hidden');
|
||||
target.click();
|
||||
},
|
||||
true,
|
||||
function (data) {
|
||||
let failed_here = false;
|
||||
if (data.validations && this_form) {
|
||||
let validations = Object.keys(data.validations);
|
||||
this_form.find('input, select').each(function(){
|
||||
if (validations.includes($(this).attr('id'))) {
|
||||
failed_here = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!failed_here) {
|
||||
target.parent().removeClass('hidden');
|
||||
target.click();
|
||||
}
|
||||
});
|
||||
});
|
||||
$("#wizard\\.interfaces\\.wan\\.ipv4_type").change(function(){
|
||||
$(".wan_options").closest('tr').hide();
|
||||
$(".wan_options_" + $(this).val()).closest('tr').show();
|
||||
});
|
||||
|
||||
$("#apply").click(function(){
|
||||
let this_button = $(this);
|
||||
if (this_button.hasClass('running')) {
|
||||
return;
|
||||
} else {
|
||||
this_button.find('.reload_progress').addClass("fa fa-spinner fa-pulse");
|
||||
this_button.addClass('running');
|
||||
saveFormToEndpoint("/api/core/initial_setup/configure", 'form_root', function(data){
|
||||
this_button.removeClass('running');
|
||||
this_button.find('.reload_progress').removeClass("fa fa-spinner fa-pulse");
|
||||
/* redirect to index for finish page */
|
||||
window.location = '/index.php?wizard_done';
|
||||
},
|
||||
false,
|
||||
function (data) {
|
||||
this_button.removeClass('running');
|
||||
this_button.find('.reload_progress').removeClass("fa fa-spinner fa-pulse");
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
|
||||
{% for tabid, tab in all_tabs%}
|
||||
<li class="{% if loop.first %}active{% else %}hidden{% endif %}"><a data-toggle="tab" id="tab_{{loop.index}}" href="#{{tabid}}">{{ tab['title'] }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div class="tab-content content-box" id="form_root">
|
||||
{% for tabid, tab in all_tabs%}
|
||||
<div id="{{tabid}}" class="tab-pane fade in {% if loop.first %}active{% endif %}" style="padding-top:10px;">
|
||||
<div class="col-md-12">
|
||||
{% if tab['message'] is defined %}
|
||||
<div class="well">
|
||||
{{ tab['message'] }}
|
||||
</div>
|
||||
{% elseif tab['form'] is defined %}
|
||||
{{ partial("layout_partials/base_form",['fields': tab['form'], 'id': 'frm_wizard-' ~ tabid ])}}
|
||||
<br/>
|
||||
{% endif %}
|
||||
|
||||
{% if not loop.last %}
|
||||
<button class="btn btn-primary action_next" id="btn_next_{{loop.index}}" data-next_index="{{loop.index + 1}}">
|
||||
<b>{{ lang._('Next') }}</b>
|
||||
</button>
|
||||
{% else %}
|
||||
<button class="btn btn-primary" id="apply">
|
||||
<b>{{ lang._('Apply') }}</b><i class="reload_progress"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
<br/><br/>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
@ -112,8 +112,8 @@ function get_interface_config_description($iface)
|
||||
$if = $c['if'];
|
||||
$result = $if;
|
||||
$result2 = array();
|
||||
$ipaddr = $c['ipaddr'];
|
||||
$ipaddrv6 = $c['ipaddrv6'];
|
||||
$ipaddr = $c['ipaddr'] ?? '';
|
||||
$ipaddrv6 = $c['ipaddrv6'] ?? '';
|
||||
if (is_ipaddr($ipaddr)) {
|
||||
$result2[] = 'static';
|
||||
} elseif (!empty($ipaddr)) {
|
||||
@ -301,6 +301,11 @@ function console_configure_ip_address($version)
|
||||
{
|
||||
global $config, $interface, $restart_dhcpd, $ifaceassigned, $fp;
|
||||
|
||||
$isintdhcp = false;
|
||||
$restart_dhcpd = false;
|
||||
$gwname = null;
|
||||
$nameserver = null;
|
||||
$intbits = '';
|
||||
$label_IPvX = ($version === 6) ? 'IPv6' : 'IPv4';
|
||||
$maxbits = ($version === 6) ? 128 : 32;
|
||||
$label_DHCP = ($version === 6) ? 'DHCP6' : 'DHCP';
|
||||
@ -329,7 +334,6 @@ function console_configure_ip_address($version)
|
||||
$ifaceassigned = $ifppp;
|
||||
}
|
||||
$intip = ($version === 6) ? 'dhcp6' : 'dhcp';
|
||||
$intbits = '';
|
||||
$isintdhcp = true;
|
||||
$restart_dhcpd = true;
|
||||
echo "\n";
|
||||
@ -475,6 +479,15 @@ function console_configure_dhcpd($version = 4)
|
||||
$label_IPvX = ($version === 6) ? "IPv6" : "IPv4";
|
||||
$dhcpd = ($version === 6) ? "dhcpdv6" : "dhcpd";
|
||||
|
||||
if ($version === 4) {
|
||||
config_read_array('dnsmasq', 'dhcp_ranges');
|
||||
foreach ($config['dnsmasq']['dhcp_ranges'] as $idx => $range) {
|
||||
if ($range['interface'] == $interface) {
|
||||
unset($config['dnsmasq']['dhcp_ranges'][$idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (prompt_for_enable_dhcp_server($version)) {
|
||||
$subnet_start = ($version === 6) ? gen_subnetv6($intip6, $intbits6) : gen_subnet($intip, $intbits);
|
||||
$subnet_end = ($version === 6) ? gen_subnetv6_max($intip6, $intbits6) : gen_subnet_max($intip, $intbits);
|
||||
@ -512,13 +525,25 @@ function console_configure_dhcpd($version = 4)
|
||||
} while (!$is_ipaddr || !$is_inrange);
|
||||
} while ($not_inorder);
|
||||
$restart_dhcpd = true;
|
||||
$config[$dhcpd][$interface]['enable'] = true;
|
||||
$config[$dhcpd][$interface]['range']['from'] = $dhcpstartip;
|
||||
$config[$dhcpd][$interface]['range']['to'] = $dhcpendip;
|
||||
if ($version === 4) {
|
||||
$config['dnsmasq']['enable'] = '1';
|
||||
$config['dnsmasq']['dhcp_ranges'][] = [
|
||||
'interface' => $interface,
|
||||
'start_addr' => $dhcpstartip,
|
||||
'end_addr' => $dhcpendip
|
||||
];
|
||||
} else {
|
||||
$config['dhcpdv6'][$interface]['enable'] = true;
|
||||
$config['dhcpdv6'][$interface]['range']['from'] = $dhcpstartip;
|
||||
$config['dhcpdv6'][$interface]['range']['to'] = $dhcpendip;
|
||||
}
|
||||
echo "\n";
|
||||
} else {
|
||||
if (isset($config[$dhcpd][$interface]['enable'])) {
|
||||
unset($config[$dhcpd][$interface]['enable']);
|
||||
if ($version === 6 && isset($config['dhcpdv6'][$interface]['enable'])) {
|
||||
unset($config['dhcpdv6'][$interface]['enable']);
|
||||
$restart_dhcpd = true;
|
||||
} elseif ($version === 4) {
|
||||
/* XXX: not disabling dnsmasq as there might be other consumers */
|
||||
$restart_dhcpd = true;
|
||||
}
|
||||
}
|
||||
@ -552,14 +577,14 @@ if (console_prompt_for_yn('Restore web GUI access defaults?', 'n')) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($config['interfaces']['lan']) {
|
||||
if ($config['dhcpd']) {
|
||||
if ($config['dhcpd']['wan']) {
|
||||
if (!empty($config['interfaces']['lan'])) {
|
||||
if (isset($config['dhcpd'])) {
|
||||
if (isset($config['dhcpd']['wan'])) {
|
||||
unset($config['dhcpd']['wan']);
|
||||
}
|
||||
}
|
||||
if ($config['dhcpdv6']) {
|
||||
if ($config['dhcpdv6']['wan']) {
|
||||
if (isset($config['dhcpdv6'])) {
|
||||
if (isset($config['dhcpdv6']['wan'])) {
|
||||
unset($config['dhcpdv6']['wan']);
|
||||
}
|
||||
}
|
||||
@ -590,6 +615,7 @@ filter_configure_sync(true);
|
||||
|
||||
if ($restart_dhcpd) {
|
||||
plugins_configure('dhcp', true);
|
||||
plugins_configure('dns', true); /* dnsmasq dhcp */
|
||||
}
|
||||
|
||||
if ($restart_webgui) {
|
||||
|
||||
36
src/opnsense/scripts/system/get_timezones.php
Executable file
36
src/opnsense/scripts/system/get_timezones.php
Executable file
@ -0,0 +1,36 @@
|
||||
#!/usr/local/bin/php
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2025 Deciso B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
require_once 'system.inc';
|
||||
|
||||
$result = [];
|
||||
foreach (get_zoneinfo() as $tz) {
|
||||
$result[$tz]= $tz;
|
||||
}
|
||||
echo json_encode($result);
|
||||
@ -148,6 +148,12 @@ type:script_output
|
||||
message:list locales
|
||||
cache_ttl:300
|
||||
|
||||
[list.timezones]
|
||||
command:/usr/local/opnsense/scripts/system/get_timezones.php
|
||||
parameters:
|
||||
type:script_output
|
||||
message:list timezones
|
||||
|
||||
[list.shells]
|
||||
command:/usr/local/opnsense/scripts/system/list_shells.py
|
||||
parameters:
|
||||
|
||||
@ -1,658 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<wizard>
|
||||
<copyright><![CDATA[
|
||||
/*
|
||||
Copyright (C) 2015-2017 Franco Fichtner <franco@opnsense.org>
|
||||
Copyright (C) 2014 Deciso B.V.
|
||||
Copyright (C) 2004-2005 Scott Ullrich <sullrich@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
*/
|
||||
]]></copyright>
|
||||
<totalsteps>9</totalsteps>
|
||||
<step>
|
||||
<id>1</id>
|
||||
<title>General Setup</title>
|
||||
<fields>
|
||||
<field>
|
||||
<type>text</type>
|
||||
<description>This wizard will guide you through the initial system configuration. The wizard may be stopped at any time by clicking the logo image at the top of the screen.</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>Next</name>
|
||||
<type>submit</type>
|
||||
</field>
|
||||
</fields>
|
||||
<stepsubmitbeforesave>
|
||||
if (isset($config['wizardtemp'])) {
|
||||
unset($config['wizardtemp']);
|
||||
}
|
||||
</stepsubmitbeforesave>
|
||||
<stepbeforeformdisplay>
|
||||
if (isset($config['trigger_initial_wizard'])) {
|
||||
unset($config['trigger_initial_wizard']);
|
||||
write_config('Triggered initial wizard');
|
||||
}
|
||||
</stepbeforeformdisplay>
|
||||
</step>
|
||||
<step>
|
||||
<id>2</id>
|
||||
<title>General Information</title>
|
||||
<fields>
|
||||
<field>
|
||||
<name>General Information</name>
|
||||
<type>listtopic</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>Hostname</name>
|
||||
<type>input</type>
|
||||
<bindstofield>wizardtemp->system->hostname</bindstofield>
|
||||
<validate>^[A-Za-z0-9.|-]+$</validate>
|
||||
<message>Invalid Hostname</message>
|
||||
</field>
|
||||
<field>
|
||||
<name>Domain</name>
|
||||
<type>input</type>
|
||||
<bindstofield>wizardtemp->system->domain</bindstofield>
|
||||
<validate>^[a-z0-9.|-]+$</validate>
|
||||
<message>Domain name field is invalid</message>
|
||||
</field>
|
||||
<field>
|
||||
<name>Language</name>
|
||||
<type>language_select</type>
|
||||
<bindstofield>system->language</bindstofield>
|
||||
</field>
|
||||
<field>
|
||||
<name>Primary DNS Server</name>
|
||||
<type>input</type>
|
||||
<bindstofield>system->dnsserver</bindstofield>
|
||||
<!-- we must unset the fields because this is an array. -->
|
||||
<unsetfield>yes</unsetfield>
|
||||
<arraynum>0</arraynum>
|
||||
<validate>^(?:[0]*(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:[0]*(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9]))$</validate>
|
||||
<message>Primary DNS Server field is invalid</message>
|
||||
</field>
|
||||
<field>
|
||||
<name>Secondary DNS Server</name>
|
||||
<type>input</type>
|
||||
<bindstofield>system->dnsserver</bindstofield>
|
||||
<arraynum>1</arraynum>
|
||||
<validate>^(?:[0]*(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:[0]*(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9]))$</validate>
|
||||
<message>Secondary DNS Server field is invalid</message>
|
||||
</field>
|
||||
<field>
|
||||
<name>Override DNS</name>
|
||||
<typehint>Allow DNS servers to be overridden by DHCP/PPP on WAN</typehint>
|
||||
<type>checkbox</type>
|
||||
<bindstofield>system->dnsallowoverride</bindstofield>
|
||||
</field>
|
||||
<field>
|
||||
<name>Unbound DNS</name>
|
||||
<type>listtopic</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>Enable Resolver</name>
|
||||
<type>checkbox</type>
|
||||
<value>yes</value>
|
||||
<bindstofield>OPNsense->unboundplus->general->enabled</bindstofield>
|
||||
</field>
|
||||
<field>
|
||||
<name>Enable DNSSEC Support</name>
|
||||
<type>checkbox</type>
|
||||
<value></value>
|
||||
<bindstofield>OPNsense->unboundplus->general->dnssec</bindstofield>
|
||||
</field>
|
||||
<field>
|
||||
<name>Harden DNSSEC data</name>
|
||||
<type>checkbox</type>
|
||||
<value></value>
|
||||
<bindstofield>OPNsense->unboundplus->advanced->dnssecstripped</bindstofield>
|
||||
</field>
|
||||
<field>
|
||||
<name>Next</name>
|
||||
<type>submit</type>
|
||||
</field>
|
||||
</fields>
|
||||
<stepbeforeformdisplay><![CDATA[
|
||||
$config['wizardtemp'] = array();
|
||||
$config['wizardtemp']['system'] = array();
|
||||
$config['wizardtemp']['system']['hostname'] = $config['system']['hostname'];
|
||||
$config['wizardtemp']['system']['domain'] = $config['system']['domain'];
|
||||
]]></stepbeforeformdisplay>
|
||||
<stepsubmitphpaction><![CDATA[
|
||||
if (empty($_POST['hostname']) || !is_hostname($_POST['hostname'])) {
|
||||
$input_errors[] = gettext('Hostname is invalid.');
|
||||
}
|
||||
if (empty($_POST['domain']) || !is_domain($_POST['domain'])) {
|
||||
$input_errors[] = gettext('Domain is invalid.');
|
||||
}
|
||||
if (!empty($_POST['primarydnsserver']) && !is_ipaddrv4($_POST['primarydnsserver'])) {
|
||||
$input_errors[] = gettext('Primary DNS server is invalid.');
|
||||
}
|
||||
if (!empty($_POST['secondarydnsserver']) && !is_ipaddrv4($_POST['secondarydnsserver'])) {
|
||||
$input_errors[] = gettext('Second DNS server is invalid.');
|
||||
}
|
||||
if (!empty($input_errors)) {
|
||||
$stepid--;
|
||||
} else {
|
||||
$config['dnsmasq']['enable'] = '0';
|
||||
}
|
||||
]]></stepsubmitphpaction>
|
||||
</step>
|
||||
<step>
|
||||
<id>3</id>
|
||||
<title>Time Server Information</title>
|
||||
<fields>
|
||||
<field>
|
||||
<name>Time server hostname</name>
|
||||
<description>Enter the hostname (FQDN) of the time server.</description>
|
||||
<type>input</type>
|
||||
<bindstofield>system->timeservers</bindstofield>
|
||||
</field>
|
||||
<field>
|
||||
<name>Timezone</name>
|
||||
<type>timezone_select</type>
|
||||
<bindstofield>system->timezone</bindstofield>
|
||||
</field>
|
||||
<field>
|
||||
<name>Next</name>
|
||||
<type>submit</type>
|
||||
</field>
|
||||
</fields>
|
||||
<stepsubmitphpaction><![CDATA[
|
||||
foreach (explode(' ', $_POST['timeserverhostname']) as $ts) {
|
||||
if (!is_domain($ts)) {
|
||||
$input_errors[] = gettext("NTP Time Server names may only contain the characters a-z, 0-9, '-' and '.'. Entries may be separated by spaces.");
|
||||
}
|
||||
}
|
||||
if (!empty($input_errors)) {
|
||||
$stepid--;
|
||||
}
|
||||
]]></stepsubmitphpaction>
|
||||
</step>
|
||||
<step>
|
||||
<id>4</id>
|
||||
<disableallfieldsbydefault>true</disableallfieldsbydefault>
|
||||
<title>Configure WAN Interface</title>
|
||||
<javascriptafterformdisplay>
|
||||
var selectedItem = 0;
|
||||
if (jQuery('#ipaddress').val() == 'dhcp') {
|
||||
selectedItem = 1;
|
||||
jQuery('#ipaddress').val('');
|
||||
} else if (jQuery('#ipaddress').val() == 'pppoe') {
|
||||
selectedItem = 2;
|
||||
jQuery('#ipaddress').val('');
|
||||
} else if (jQuery('#ipaddress').val() == 'pptp') {
|
||||
selectedItem = 3;
|
||||
jQuery('#ipaddress').val('');
|
||||
} else if (jQuery('#ipaddress').val() == 'ppp' || jQuery('#ipaddress').val() == 'l2tp') {
|
||||
jQuery('#ipaddress').val('');
|
||||
} else {
|
||||
selectedItem = 0;
|
||||
}
|
||||
jQuery('#selectedtype').prop('selectedIndex',selectedItem);
|
||||
enableitems(selectedItem);
|
||||
</javascriptafterformdisplay>
|
||||
<fields>
|
||||
<field>
|
||||
<name>SelectedType</name>
|
||||
<displayname>IPv4 Configuration Type</displayname>
|
||||
<type>select</type>
|
||||
<donotdisable>true</donotdisable>
|
||||
<options>
|
||||
<option>
|
||||
<name>Static</name>
|
||||
<value>Static</value>
|
||||
<enablefields>ipaddress,subnetmask,upstreamgateway</enablefields>
|
||||
</option>
|
||||
<option>
|
||||
<name>DHCP</name>
|
||||
<value>dhcp</value>
|
||||
<enablefields>dhcphostname</enablefields>
|
||||
</option>
|
||||
<option>
|
||||
<name>PPPoE</name>
|
||||
<value>pppoe</value>
|
||||
<enablefields>pppoeusername,pppoepassword,pppoeservicename,pppoedialondemand,pppoeidletimeout</enablefields>
|
||||
</option>
|
||||
<option>
|
||||
<name>PPTP</name>
|
||||
<value>pptp</value>
|
||||
<enablefields>pptpusername,pptppassword,pptplocalipaddress,pptplocalsubnet,pptpremoteipaddress,pptpdialondemand,pptpidletimeout</enablefields>
|
||||
</option>
|
||||
</options>
|
||||
</field>
|
||||
<field>
|
||||
<name>General configuration</name>
|
||||
<type>listtopic</type>
|
||||
</field>
|
||||
<field>
|
||||
<donotdisable>true</donotdisable>
|
||||
<name>MAC Address</name>
|
||||
<bindstofield>interfaces->wan->spoofmac</bindstofield>
|
||||
<type>input</type>
|
||||
<description>This field can be used to modify ("spoof") the MAC address of the WAN interface (may be required with some cable connections). Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx or leave blank.</description>
|
||||
<validate>^([0-9a-f]{2}([:-]||$)){6}$</validate>
|
||||
<message>MAC Address field is invalid</message>
|
||||
</field>
|
||||
<field>
|
||||
<donotdisable>true</donotdisable>
|
||||
<name>MTU</name>
|
||||
<type>input</type>
|
||||
<bindstofield>interfaces->wan->mtu</bindstofield>
|
||||
<description>Set the MTU of the WAN interface. If you leave this field blank, an MTU of 1492 bytes for PPPoE and 1500 bytes for all other connection types will be assumed.</description>
|
||||
</field>
|
||||
<field>
|
||||
<donotdisable>true</donotdisable>
|
||||
<name>MSS</name>
|
||||
<type>input</type>
|
||||
<bindstofield>interfaces->wan->mss</bindstofield>
|
||||
<description>If you enter a value in this field, then MSS clamping for TCP connections to the value entered above minus 40 (TCP/IP header size) will be in effect. If you leave this field blank, an MSS of 1492 bytes for PPPoE and 1500 bytes for all other connection types will be assumed. This should match the above MTU value in most all cases.</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>Static IP Configuration</name>
|
||||
<type>listtopic</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>IP Address</name>
|
||||
<bindstofield>interfaces->wan->ipaddr</bindstofield>
|
||||
<type>input</type>
|
||||
<combinefieldsbegin>true</combinefieldsbegin>
|
||||
<validate>^(?:[0]*(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:[0]*(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9]))$</validate>
|
||||
<message>IP Address field is invalid</message>
|
||||
</field>
|
||||
<field>
|
||||
<combinefieldsend>true</combinefieldsend>
|
||||
<dontdisplayname>true</dontdisplayname>
|
||||
<dontcombinecells>true</dontcombinecells>
|
||||
<name>Subnet Mask</name>
|
||||
<bindstofield>interfaces->wan->subnet</bindstofield>
|
||||
<type>subnet_select</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>Upstream Gateway</name>
|
||||
<bindstofield>wizardtemp->wangateway</bindstofield>
|
||||
<type>input</type>
|
||||
<validate>^(?:[0]*(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:[0]*(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9]))$</validate>
|
||||
<message>Gateway IP Address field is invalid</message>
|
||||
</field>
|
||||
<field>
|
||||
<name>DHCP client configuration</name>
|
||||
<type>listtopic</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>DHCP Hostname</name>
|
||||
<type>input</type>
|
||||
<bindstofield>interfaces->wan->dhcphostname</bindstofield>
|
||||
<description>The value in this field is sent as the DHCP client identifier and hostname when requesting a DHCP lease. Some ISPs may require this (for client identification).</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>PPPoE configuration</name>
|
||||
<type>listtopic</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>PPPoE Username</name>
|
||||
<type>input</type>
|
||||
<bindstofield>wizardtemp->wan->username</bindstofield>
|
||||
</field>
|
||||
<field>
|
||||
<name>PPPoE Password</name>
|
||||
<type>input</type>
|
||||
<bindstofield>wizardtemp->wan->password</bindstofield>
|
||||
</field>
|
||||
<field>
|
||||
<name>PPPoE Service name</name>
|
||||
<type>input</type>
|
||||
<bindstofield>wizardtemp->wan->provider</bindstofield>
|
||||
</field>
|
||||
<field>
|
||||
<name>PPPoE Dial on demand</name>
|
||||
<typehint>Enable Dial-On-Demand mode</typehint>
|
||||
<type>checkbox</type>
|
||||
<description>This option causes the interface to operate in dial-on-demand mode, allowing you to have a virtual full time connection. The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected.</description>
|
||||
<bindstofield>wizardtemp->wan->ondemand</bindstofield>
|
||||
</field>
|
||||
<field>
|
||||
<name>PPPoE Idle timeout</name>
|
||||
<type>input</type>
|
||||
<description>If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. An idle timeout of zero disables this feature.</description>
|
||||
<bindstofield>wizardtemp->wan->idletimeout</bindstofield>
|
||||
</field>
|
||||
<field>
|
||||
<name>PPTP configuration</name>
|
||||
<type>listtopic</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>PPTP Username</name>
|
||||
<type>input</type>
|
||||
<bindstofield>wizardtemp->wan->pptpusername</bindstofield>
|
||||
</field>
|
||||
<field>
|
||||
<name>PPTP Password</name>
|
||||
<type>input</type>
|
||||
<bindstofield>wizardtemp->wan->pptppassword</bindstofield>
|
||||
</field>
|
||||
<field>
|
||||
<combinefieldsbegin>true</combinefieldsbegin>
|
||||
<name>PPTP Local IP Address</name>
|
||||
<type>input</type>
|
||||
<bindstofield>wizardtemp->wan->localip</bindstofield>
|
||||
<validate>^(?:[0]*(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:[0]*(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9]))$</validate>
|
||||
<message>PPTP Local IP Address field is invalid</message>
|
||||
</field>
|
||||
<field>
|
||||
<combinefieldsend>true</combinefieldsend>
|
||||
<dontdisplayname>true</dontdisplayname>
|
||||
<dontcombinecells>true</dontcombinecells>
|
||||
<name>pptplocalsubnet</name>
|
||||
<bindstofield>wizardtemp->wan->subnet</bindstofield>
|
||||
<type>subnet_select</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>PPTP Remote IP Address</name>
|
||||
<bindstofield>wizardtemp->wan->gateway</bindstofield>
|
||||
<type>input</type>
|
||||
<validate>^(?:[0]*(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:[0]*(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9]))$</validate>
|
||||
<message>PPTP Remote IP Address field is invalid</message>
|
||||
</field>
|
||||
<field>
|
||||
<name>PPTP Dial on demand</name>
|
||||
<typehint>Enable Dial-On-Demand mode</typehint>
|
||||
<type>checkbox</type>
|
||||
<bindstofield>wizardtemp->wan->pptpondemand</bindstofield>
|
||||
<description>This option causes the interface to operate in dial-on-demand mode, allowing you to have a virtual full time connection. The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected.</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>PPTP Idle timeout</name>
|
||||
<type>input</type>
|
||||
<bindstofield>wizardtemp->wan->pptpidletimeout</bindstofield>
|
||||
<description>If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. An idle timeout of zero disables this feature.</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>RFC1918 Networks</name>
|
||||
<type>listtopic</type>
|
||||
</field>
|
||||
<field>
|
||||
<donotdisable>true</donotdisable>
|
||||
<name>Block RFC1918 Private Networks</name>
|
||||
<description>When set, this option blocks traffic from IP addresses that are reserved for private networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as well as loopback addresses (127/8) and Carrier-grade NAT addresses (100.64/10). This option should only be set for WAN interfaces that use the public IP address space.</description>
|
||||
<type>checkbox</type>
|
||||
<bindstofield>interfaces->wan->blockpriv</bindstofield>
|
||||
<typehint>Block private networks from entering via WAN</typehint>
|
||||
</field>
|
||||
<field>
|
||||
<name>Block bogon networks</name>
|
||||
<type>listtopic</type>
|
||||
</field>
|
||||
<field>
|
||||
<donotdisable>true</donotdisable>
|
||||
<name>Block bogon networks</name>
|
||||
<description>When set, this option blocks traffic from IP addresses that are reserved (but not RFC 1918) or not yet assigned by IANA.</description>
|
||||
<type>checkbox</type>
|
||||
<bindstofield>interfaces->wan->blockbogons</bindstofield>
|
||||
<typehint>Block non-Internet routed networks from entering via WAN</typehint>
|
||||
</field>
|
||||
<field>
|
||||
<name>Next</name>
|
||||
<type>submit</type>
|
||||
</field>
|
||||
</fields>
|
||||
<stepbeforeformdisplay><![CDATA[
|
||||
foreach ((new \OPNsense\Routing\Gateways())->gatewayIterator() as $gw) {
|
||||
if (empty($config['wizardtemp']['wangateway']) && $gw['name'] == 'WAN_GW') {
|
||||
$config['wizardtemp']['wangateway'] = $gw['gateway'];
|
||||
}
|
||||
}
|
||||
]]></stepbeforeformdisplay>
|
||||
<stepsubmitphpaction><![CDATA[
|
||||
if (!empty($_POST['mtu']) && ($_POST['mtu'] < 576)) {
|
||||
$input_errors[] = gettext('MTU Must be at least 576 (Per RFC 791).');
|
||||
}
|
||||
if (!empty($_POST['macaddress']) && !is_macaddr($_POST['macaddress'])) {
|
||||
$input_errors[] = gettext('Invalid MAC address.');
|
||||
}
|
||||
if (!empty($_POST['ipaddress']) && ($_POST['selectedtype'] == "Static")) {
|
||||
if (!is_ipaddrv4($_POST['ipaddress'])) {
|
||||
$input_errors[] = gettext('Invalid WAN IP address.');
|
||||
}
|
||||
if ($_POST['subnetmask'] < 31 &&
|
||||
($_POST['ipaddress'] == gen_subnet($_POST['ipaddress'], $_POST['subnetmask']) ||
|
||||
$_POST['ipaddress'] == gen_subnet_max($_POST['ipaddress'], $_POST['subnetmask']))) {
|
||||
$input_errors[] = gettext('Invalid WAN IP address.');
|
||||
}
|
||||
}
|
||||
if (!empty($_POST['dhcphostname']) && !is_hostname($_POST['dhcphostname'])) {
|
||||
$input_errors[] = gettext('Invalid DHCP hostname.');
|
||||
}
|
||||
if (!empty($_POST['pptplocalipaddress']) && !is_ipaddrv4($_POST['pptplocalipaddress'])) {
|
||||
$input_errors[] = gettext('Invalid PPTP Local IP address.');
|
||||
}
|
||||
if (!empty($_POST['pptpremoteipaddress']) && !is_ipaddrv4($_POST['pptpremoteipaddress'])) {
|
||||
$input_errors[] = gettext('Invalid PPTP Remote IP address.');
|
||||
}
|
||||
if (!empty($input_errors)) {
|
||||
$stepid--;
|
||||
} else {
|
||||
$type = $_POST['selectedtype'];
|
||||
|
||||
config_read_array('ppps', 'ppp');
|
||||
|
||||
foreach ($config['ppps']['ppp'] as $pppid => $ppp) {
|
||||
if ($ppp['ptpid'] == "0") {
|
||||
if ((substr($config['interfaces']['wan']['if'],0,5) == "pppoe") || (substr($config['interfaces']['wan']['if'],0,4) == "pptp")) {
|
||||
$oldif = explode(",", $ppp['ports']);
|
||||
$config['interfaces']['wan']['if'] = $oldif[0];
|
||||
}
|
||||
if ($type == "pppoe" || $type == "pptp") {
|
||||
unset($config['ppps']['ppp'][$pppid]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($type == "pppoe" || $type == "pptp") {
|
||||
if ($type == "pptp") {
|
||||
$config['wizardtemp']['wan']['username'] = $config['wizardtemp']['wan']['pptpusername'];
|
||||
$config['wizardtemp']['wan']['password'] = $config['wizardtemp']['wan']['pptppassword'];
|
||||
$config['wizardtemp']['wan']['ondemand'] = $config['wizardtemp']['wan']['pptpondemand'];
|
||||
$config['wizardtemp']['wan']['idletimeout'] = $config['wizardtemp']['wan']['pptpidletimeout'];
|
||||
unset($config['wizardtemp']['wan']['pptpusername']);
|
||||
unset($config['wizardtemp']['wan']['pptppassword']);
|
||||
unset($config['wizardtemp']['wan']['pptpondemand']);
|
||||
unset($config['wizardtemp']['wan']['pptpidletimeout']);
|
||||
}
|
||||
$config['wizardtemp']['wan']['password'] = base64_encode($config['wizardtemp']['wan']['password']);
|
||||
$tmp = array();
|
||||
$tmp['ptpid'] = "0";
|
||||
$tmp['type'] = $type;
|
||||
$tmp['if'] = $type . "0";
|
||||
$tmp['ports'] = $config['interfaces']['wan']['if'];
|
||||
$config['ppps']['ppp'][] = array_merge($tmp, $config['wizardtemp']['wan']);
|
||||
unset($tmp);
|
||||
$config['interfaces']['wan']['if'] = $type."0";
|
||||
}
|
||||
unset($config['wizardtemp']['wan']);
|
||||
}
|
||||
]]></stepsubmitphpaction>
|
||||
<stepsubmitbeforesave><![CDATA[
|
||||
if ($_POST['selectedtype'] != "Static") {
|
||||
$_POST['ipaddress'] = $_POST['selectedtype'];
|
||||
$config['interfaces']['wan']['ipaddr'] = $_POST['selectedtype'];
|
||||
}
|
||||
]]></stepsubmitbeforesave>
|
||||
</step>
|
||||
<step>
|
||||
<id>5</id>
|
||||
<title>Configure LAN Interface</title>
|
||||
<description>On this screen we will configure the Local Area Network information.</description>
|
||||
<fields>
|
||||
<field>
|
||||
<name>LAN IP Address</name>
|
||||
<type>input</type>
|
||||
<bindstofield>interfaces->lan->ipaddr</bindstofield>
|
||||
<validate>^(?:[0]*(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:[0]*(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9]))$</validate>
|
||||
<description>(leave empty for none)</description>
|
||||
<message>LAN IP Address field is invalid</message>
|
||||
</field>
|
||||
<field>
|
||||
<name>Subnet Mask</name>
|
||||
<type>subnet_select</type>
|
||||
<bindstofield>interfaces->lan->subnet</bindstofield>
|
||||
</field>
|
||||
<field>
|
||||
<name>Next</name>
|
||||
<type>submit</type>
|
||||
</field>
|
||||
</fields>
|
||||
<stepsubmitphpaction><![CDATA[
|
||||
if (!empty(trim($_POST['lanipaddress']))) {
|
||||
if (!is_ipaddrv4($_POST['lanipaddress'])) {
|
||||
$input_errors[] = gettext('Invalid LAN IP address.');
|
||||
}
|
||||
|
||||
if ($_POST['subnetmask'] < 31 &&
|
||||
($_POST['lanipaddress'] == gen_subnet($_POST['lanipaddress'], $_POST['subnetmask']) ||
|
||||
$_POST['lanipaddress'] == gen_subnet_max($_POST['lanipaddress'], $_POST['subnetmask']))) {
|
||||
$input_errors[] = gettext('Invalid LAN IP address.');
|
||||
}
|
||||
|
||||
if (!empty($input_errors)) {
|
||||
$stepid--;
|
||||
} elseif (!empty($config['dhcpd']['lan']['range']['from'])) {
|
||||
$ft = explode(".", $_POST['lanipaddress']);
|
||||
$ft_ip = $ft[0] . "." . $ft[1] . "." . $ft[2] . ".";
|
||||
$config['dhcpd']['lan']['range']['from'] = $ft_ip . "10";
|
||||
$highestip = gen_subnet_max($_POST['lanipaddress'], $config['interfaces']['lan']['subnet']);
|
||||
$hi = explode(".", $highestip);
|
||||
$highestip = $hi[3]-10;
|
||||
$config['dhcpd']['lan']['range']['to'] = $ft_ip . $highestip;
|
||||
}
|
||||
} else {
|
||||
if (isset($config['interfaces']['lan'])) {
|
||||
unset($config['interfaces']['lan']);
|
||||
}
|
||||
}
|
||||
]]></stepsubmitphpaction>
|
||||
</step>
|
||||
<step>
|
||||
<id>6</id>
|
||||
<title>Set Root Password</title>
|
||||
<fields>
|
||||
<field>
|
||||
<name>Root Password</name>
|
||||
<type>password</type>
|
||||
<description>(leave empty to keep current one)</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>Root Password Confirmation</name>
|
||||
<type>password</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>Next</name>
|
||||
<type>submit</type>
|
||||
</field>
|
||||
</fields>
|
||||
<stepsubmitphpaction><![CDATA[
|
||||
if (!empty($_POST['rootpassword']) || !empty($_POST['rootpasswordconfirmation'])) {
|
||||
if ($_POST['rootpassword'] == $_POST['rootpasswordconfirmation']) {
|
||||
$admin_user = &getUserEntryByUID(0);
|
||||
local_user_set_password($admin_user, $_POST['rootpassword']);
|
||||
local_user_set($admin_user);
|
||||
} else {
|
||||
$input_errors[] = gettext('The passwords do not match.');
|
||||
}
|
||||
}
|
||||
if (!empty($input_errors)) {
|
||||
$stepid--;
|
||||
}
|
||||
]]></stepsubmitphpaction>
|
||||
</step>
|
||||
<step>
|
||||
<id>7</id>
|
||||
<title>Reload Configuration</title>
|
||||
<fields>
|
||||
<field>
|
||||
<type>text</type>
|
||||
<description>Click 'Reload' to apply the changes.</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>Reload</name>
|
||||
<type>submit</type>
|
||||
</field>
|
||||
</fields>
|
||||
<stepafterformdisplay><![CDATA[
|
||||
$gateways = new \OPNsense\Routing\Gateways();
|
||||
$found = $defaultgw_found = false;
|
||||
|
||||
foreach ($gateways->gatewayIterator() as $gw) {
|
||||
if (!empty($gw['defaultgw'])) {
|
||||
$defaultgw_found = true;
|
||||
}
|
||||
|
||||
if ($gw['name'] == 'WAN_GW' && !empty($gw['uuid'])) {
|
||||
$gateways->createOrUpdateGateway(['gateway' => $config['wizardtemp']['wangateway']], $gw['uuid']);
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$gateways->createOrUpdateGateway([
|
||||
'interface' => 'wan',
|
||||
'gateway' => $config['wizardtemp']['wangateway'],
|
||||
'name' => 'WAN_GW',
|
||||
'weight' => 1,
|
||||
'monitor_disable' => 1,
|
||||
'descr' => "WAN Gateway",
|
||||
'defaultgw' => !$defaultgw_found,
|
||||
]);
|
||||
}
|
||||
|
||||
/* Assignments to $config only after this went through! */
|
||||
$config = OPNsense\Core\Config::getInstance()->toArray(listtags());
|
||||
|
||||
$config['system']['hostname'] = $config['wizardtemp']['system']['hostname'];
|
||||
$config['system']['domain'] = $config['wizardtemp']['system']['domain'];
|
||||
$config['interfaces']['wan']['gateway'] = 'WAN_GW';
|
||||
unset($config['wizardtemp']);
|
||||
|
||||
write_config();
|
||||
]]></stepafterformdisplay>
|
||||
</step>
|
||||
<step>
|
||||
<id>8</id>
|
||||
<title>Reload in progress</title>
|
||||
<fields>
|
||||
<field>
|
||||
<type>text</type>
|
||||
<description>A reload is now in progress. The wizard will redirect you to the dashboard once the reload is completed.</description>
|
||||
</field>
|
||||
<field>
|
||||
<type>refresh</type>
|
||||
<time>5</time>
|
||||
<page>index.php?wizard_done</page>
|
||||
</field>
|
||||
</fields>
|
||||
<stepafterformdisplay><![CDATA[
|
||||
configd_run('service reload delay', true);
|
||||
]]></stepafterformdisplay>
|
||||
</step>
|
||||
</wizard>
|
||||
@ -93,7 +93,7 @@ if (isset($config['trigger_initial_wizard']) || isset($_GET['wizard_done'])):
|
||||
</section>
|
||||
<?php
|
||||
if (isset($config['trigger_initial_wizard'])): ?>
|
||||
<meta http-equiv="refresh" content="5;url=/wizard.php?xml=system">
|
||||
<meta http-equiv="refresh" content="5;url=/ui/core/initial_setup">
|
||||
<?php endif ;
|
||||
include("foot.inc"); endif;
|
||||
else:
|
||||
|
||||
@ -431,8 +431,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
}
|
||||
$pconfig['enable'] = isset($a_interfaces[$if]['enable']);
|
||||
$pconfig['lock'] = isset($a_interfaces[$if]['lock']);
|
||||
$pconfig['blockpriv'] = isset($a_interfaces[$if]['blockpriv']);
|
||||
$pconfig['blockbogons'] = isset($a_interfaces[$if]['blockbogons']);
|
||||
$pconfig['blockpriv'] = !empty($a_interfaces[$if]['blockpriv']);
|
||||
$pconfig['blockbogons'] = !empty($a_interfaces[$if]['blockbogons']);
|
||||
$pconfig['gateway_interface'] = isset($a_interfaces[$if]['gateway_interface']);
|
||||
$pconfig['promisc'] = isset($a_interfaces[$if]['promisc']);
|
||||
$pconfig['dhcpoverridemtu'] = empty($a_interfaces[$if]['dhcphonourmtu']) ? true : null;
|
||||
|
||||
@ -1,335 +0,0 @@
|
||||
|
||||
/**
|
||||
* An autosuggest textbox control.
|
||||
* @class
|
||||
* @scope public
|
||||
*/
|
||||
function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
|
||||
oProvider /*:SuggestionProvider*/) {
|
||||
|
||||
/**
|
||||
* The currently selected suggestions.
|
||||
* @scope private
|
||||
*/
|
||||
this.cur /*:int*/ = -1;
|
||||
|
||||
/**
|
||||
* The dropdown list layer.
|
||||
* @scope private
|
||||
*/
|
||||
this.layer = null;
|
||||
|
||||
/**
|
||||
* Suggestion provider for the autosuggest feature.
|
||||
* @scope private.
|
||||
*/
|
||||
this.provider /*:SuggestionProvider*/ = oProvider;
|
||||
|
||||
/**
|
||||
* The textbox to capture.
|
||||
* @scope private
|
||||
*/
|
||||
this.textbox /*:HTMLInputElement*/ = oTextbox;
|
||||
|
||||
//initialize the control
|
||||
this.init();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Autosuggests one or more suggestions for what the user has typed.
|
||||
* If no suggestions are passed in, then no autosuggest occurs.
|
||||
* @scope private
|
||||
* @param aSuggestions An array of suggestion strings.
|
||||
* @param bTypeAhead If the control should provide a type ahead suggestion.
|
||||
*/
|
||||
AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/,
|
||||
bTypeAhead /*:boolean*/) {
|
||||
|
||||
//make sure there's at least one suggestion
|
||||
if (aSuggestions.length > 0) {
|
||||
if (bTypeAhead) {
|
||||
this.typeAhead(aSuggestions[0]);
|
||||
}
|
||||
|
||||
this.showSuggestions(aSuggestions);
|
||||
} else {
|
||||
this.hideSuggestions();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates the dropdown layer to display multiple suggestions.
|
||||
* @scope private
|
||||
*/
|
||||
AutoSuggestControl.prototype.createDropDown = function () {
|
||||
|
||||
var oThis = this;
|
||||
|
||||
//create the layer and assign styles
|
||||
this.layer = document.createElement("div");
|
||||
this.layer.className = "suggestions";
|
||||
this.layer.style.visibility = "hidden";
|
||||
this.layer.style.width = this.textbox.offsetWidth;
|
||||
|
||||
//when the user clicks on the a suggestion, get the text (innerHTML)
|
||||
//and place it into a textbox
|
||||
this.layer.onmousedown =
|
||||
this.layer.onmouseup =
|
||||
this.layer.onmouseover = function (oEvent) {
|
||||
oEvent = oEvent || window.event;
|
||||
let oTarget = oEvent.target || oEvent.srcElement;
|
||||
|
||||
if (oEvent.type == "mousedown") {
|
||||
oThis.textbox.value = oTarget.firstChild.nodeValue;
|
||||
oThis.hideSuggestions();
|
||||
} else if (oEvent.type == "mouseover") {
|
||||
oThis.highlightSuggestion(oTarget);
|
||||
} else {
|
||||
oThis.textbox.focus();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
document.body.appendChild(this.layer);
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the left coordinate of the textbox.
|
||||
* @scope private
|
||||
* @return The left coordinate of the textbox in pixels.
|
||||
*/
|
||||
AutoSuggestControl.prototype.getLeft = function () /*:int*/ {
|
||||
|
||||
var oNode = this.textbox;
|
||||
var iLeft = 0;
|
||||
|
||||
while(oNode.tagName != "BODY") {
|
||||
iLeft += oNode.offsetLeft;
|
||||
oNode = oNode.offsetParent;
|
||||
}
|
||||
|
||||
return iLeft;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the top coordinate of the textbox.
|
||||
* @scope private
|
||||
* @return The top coordinate of the textbox in pixels.
|
||||
*/
|
||||
AutoSuggestControl.prototype.getTop = function () /*:int*/ {
|
||||
|
||||
var oNode = this.textbox;
|
||||
var iTop = 0;
|
||||
|
||||
while(oNode.tagName != "BODY") {
|
||||
iTop += oNode.offsetTop;
|
||||
oNode = oNode.offsetParent;
|
||||
}
|
||||
|
||||
return iTop;
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles three keydown events.
|
||||
* @scope private
|
||||
* @param oEvent The event object for the keydown event.
|
||||
*/
|
||||
AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) {
|
||||
|
||||
switch(oEvent.keyCode) {
|
||||
case 38: //up arrow
|
||||
this.previousSuggestion();
|
||||
break;
|
||||
case 40: //down arrow
|
||||
this.nextSuggestion();
|
||||
break;
|
||||
case 13: //enter
|
||||
this.hideSuggestions();
|
||||
break;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles keyup events.
|
||||
* @scope private
|
||||
* @param oEvent The event object for the keyup event.
|
||||
*/
|
||||
AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) {
|
||||
|
||||
var iKeyCode = oEvent.keyCode;
|
||||
|
||||
//for backspace (8) and delete (46), shows suggestions without typeahead
|
||||
if (iKeyCode == 8 || iKeyCode == 46) {
|
||||
this.provider.requestSuggestions(this, false);
|
||||
|
||||
//make sure not to interfere with non-character keys
|
||||
} else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) {
|
||||
//ignore
|
||||
} else {
|
||||
//request suggestions from the suggestion provider with typeahead
|
||||
this.provider.requestSuggestions(this, true);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Hides the suggestion dropdown.
|
||||
* @scope private
|
||||
*/
|
||||
AutoSuggestControl.prototype.hideSuggestions = function () {
|
||||
this.layer.style.visibility = "hidden";
|
||||
};
|
||||
|
||||
/**
|
||||
* Highlights the given node in the suggestions dropdown.
|
||||
* @scope private
|
||||
* @param oSuggestionNode The node representing a suggestion in the dropdown.
|
||||
*/
|
||||
AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) {
|
||||
|
||||
for (var i=0; i < this.layer.childNodes.length; i++) {
|
||||
var oNode = this.layer.childNodes[i];
|
||||
if (oNode == oSuggestionNode) {
|
||||
oNode.className = "current";
|
||||
} else if (oNode.className == "current") {
|
||||
oNode.className = "";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Initializes the textbox with event handlers for
|
||||
* auto suggest functionality.
|
||||
* @scope private
|
||||
*/
|
||||
AutoSuggestControl.prototype.init = function () {
|
||||
|
||||
//save a reference to this object
|
||||
var oThis = this;
|
||||
|
||||
//assign the onkeyup event handler
|
||||
this.textbox.onkeyup = function (oEvent) {
|
||||
|
||||
//check for the proper location of the event object
|
||||
if (!oEvent) {
|
||||
oEvent = window.event;
|
||||
}
|
||||
|
||||
//call the handleKeyUp() method with the event object
|
||||
oThis.handleKeyUp(oEvent);
|
||||
};
|
||||
|
||||
//assign onkeydown event handler
|
||||
this.textbox.onkeydown = function (oEvent) {
|
||||
|
||||
//check for the proper location of the event object
|
||||
if (!oEvent) {
|
||||
oEvent = window.event;
|
||||
}
|
||||
|
||||
//call the handleKeyDown() method with the event object
|
||||
oThis.handleKeyDown(oEvent);
|
||||
};
|
||||
|
||||
//assign onblur event handler (hides suggestions)
|
||||
this.textbox.onblur = function () {
|
||||
oThis.hideSuggestions();
|
||||
};
|
||||
|
||||
//create the suggestions dropdown
|
||||
this.createDropDown();
|
||||
};
|
||||
|
||||
/**
|
||||
* Highlights the next suggestion in the dropdown and
|
||||
* places the suggestion into the textbox.
|
||||
* @scope private
|
||||
*/
|
||||
AutoSuggestControl.prototype.nextSuggestion = function () {
|
||||
var cSuggestionNodes = this.layer.childNodes;
|
||||
|
||||
if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) {
|
||||
var oNode = cSuggestionNodes[++this.cur];
|
||||
this.highlightSuggestion(oNode);
|
||||
this.textbox.value = oNode.firstChild.nodeValue;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Highlights the previous suggestion in the dropdown and
|
||||
* places the suggestion into the textbox.
|
||||
* @scope private
|
||||
*/
|
||||
AutoSuggestControl.prototype.previousSuggestion = function () {
|
||||
var cSuggestionNodes = this.layer.childNodes;
|
||||
|
||||
if (cSuggestionNodes.length > 0 && this.cur > 0) {
|
||||
var oNode = cSuggestionNodes[--this.cur];
|
||||
this.highlightSuggestion(oNode);
|
||||
this.textbox.value = oNode.firstChild.nodeValue;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Selects a range of text in the textbox.
|
||||
* @scope public
|
||||
* @param iStart The start index (base 0) of the selection.
|
||||
* @param iLength The number of characters to select.
|
||||
*/
|
||||
AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*:int*/) {
|
||||
|
||||
//use text ranges for Internet Explorer
|
||||
if (this.textbox.createTextRange) {
|
||||
var oRange = this.textbox.createTextRange();
|
||||
oRange.moveStart("character", iStart);
|
||||
oRange.moveEnd("character", iLength - this.textbox.value.length);
|
||||
oRange.select();
|
||||
|
||||
//use setSelectionRange() for Mozilla
|
||||
} else if (this.textbox.setSelectionRange) {
|
||||
this.textbox.setSelectionRange(iStart, iLength);
|
||||
}
|
||||
|
||||
//set focus back to the textbox
|
||||
this.textbox.focus();
|
||||
};
|
||||
|
||||
/**
|
||||
* Builds the suggestion layer contents, moves it into position,
|
||||
* and displays the layer.
|
||||
* @scope private
|
||||
* @param aSuggestions An array of suggestions for the control.
|
||||
*/
|
||||
AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) {
|
||||
|
||||
var oDiv = null;
|
||||
this.layer.innerHTML = ""; //clear contents of the layer
|
||||
|
||||
for (var i=0; i < aSuggestions.length; i++) {
|
||||
oDiv = document.createElement("div");
|
||||
oDiv.appendChild(document.createTextNode(aSuggestions[i]));
|
||||
this.layer.appendChild(oDiv);
|
||||
}
|
||||
|
||||
this.layer.style.left = this.getLeft() + "px";
|
||||
this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px";
|
||||
this.layer.style.visibility = "visible";
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Inserts a suggestion into the textbox, highlighting the
|
||||
* suggested part of the text.
|
||||
* @scope private
|
||||
* @param sSuggestion The suggestion for the textbox.
|
||||
*/
|
||||
AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) {
|
||||
|
||||
//check for support of typeahead functionality
|
||||
if (this.textbox.createTextRange || this.textbox.setSelectionRange){
|
||||
var iLen = this.textbox.value.length;
|
||||
this.textbox.value = sSuggestion;
|
||||
this.selectRange(iLen, sSuggestion.length);
|
||||
}
|
||||
};
|
||||
@ -1,6 +0,0 @@
|
||||
function kH(e) {
|
||||
var pK = document.all? window.event.keyCode:e.which;
|
||||
return pK != 13;
|
||||
}
|
||||
document.onkeypress = kH;
|
||||
if (document.layers) document.captureEvents(Event.KEYPRESS);
|
||||
@ -1,33 +0,0 @@
|
||||
|
||||
/**
|
||||
* Provides suggestions for state names (USA).
|
||||
* @class
|
||||
* @scope public
|
||||
*/
|
||||
function StateSuggestions(text) {
|
||||
this.states = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request suggestions for the given autosuggest control.
|
||||
* @scope protected
|
||||
* @param oAutoSuggestControl The autosuggest control to provide suggestions for.
|
||||
*/
|
||||
StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
|
||||
bTypeAhead /*:boolean*/) {
|
||||
var aSuggestions = [];
|
||||
var sTextboxValue = oAutoSuggestControl.textbox.value;
|
||||
|
||||
if (sTextboxValue.length > 0){
|
||||
|
||||
//search for matching states
|
||||
for (var i=0; i < this.states.length; i++) {
|
||||
if (this.states[i].toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0) {
|
||||
aSuggestions.push(this.states[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//provide suggestions to the control
|
||||
oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
|
||||
};
|
||||
@ -89,8 +89,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
$config['system']['dnsserver'][] = $v4_server[0];
|
||||
$config['system']['dnsserver'][] = $v4_server[1];
|
||||
}
|
||||
if (isset($config['system']['dnsallowoverride'])) {
|
||||
unset($config['system']['dnsallowoverride']);
|
||||
if (!empty($config['system']['dnsallowoverride'])) {
|
||||
$config['system']['dnsallowoverride'] = false;
|
||||
}
|
||||
} else {
|
||||
$config['system']['dnsserver'] = array();
|
||||
|
||||
@ -54,7 +54,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
$savemsg = htmlspecialchars(gettext($_GET['savemsg']));
|
||||
}
|
||||
|
||||
$pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']);
|
||||
$pconfig['dnsallowoverride'] = !empty($config['system']['dnsallowoverride']);
|
||||
if (!empty($config['system']['dnsallowoverride_exclude'])) {
|
||||
$pconfig['dnsallowoverride_exclude'] = explode(',', $config['system']['dnsallowoverride_exclude']);
|
||||
} else {
|
||||
@ -199,11 +199,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
if (!empty($pconfig['dnsallowoverride'])) {
|
||||
$config['system']['dnsallowoverride'] = true;
|
||||
$config['system']['dnsallowoverride_exclude'] = implode(',', $pconfig['dnsallowoverride_exclude']);
|
||||
} elseif (isset($config['system']['dnsallowoverride'])) {
|
||||
unset($config['system']['dnsallowoverride']);
|
||||
if (isset($config['system']['dnsallowoverride_exclude'])) {
|
||||
unset($config['system']['dnsallowoverride_exclude']);
|
||||
}
|
||||
} elseif (isset($config['system']['dnsallowoverride_exclude'])) {
|
||||
unset($config['system']['dnsallowoverride_exclude']);
|
||||
}
|
||||
|
||||
if ($pconfig['dnslocalhost'] == 'yes') {
|
||||
|
||||
1014
src/www/wizard.php
1014
src/www/wizard.php
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user