setup.xml 24.2 KB
Newer Older
Ad Schellevis's avatar
Ad Schellevis committed
1
<?xml version="1.0" encoding="utf-8" ?>
2
<opnsensewizard>
Ad Schellevis's avatar
Ad Schellevis committed
3 4
<copyright>
/*
5 6 7
	Copyright (C) 2014 Deciso B.V.
	Copyright (C) 2004, 2005 Scott Ullrich
	All rights reserved.
Ad Schellevis's avatar
Ad Schellevis committed
8

9 10
	Redistribution and use in source and binary forms, with or without
	modification, are permitted provided that the following conditions are met:
Ad Schellevis's avatar
Ad Schellevis committed
11

12 13
	1. Redistributions of source code must retain the above copyright notice,
	   this list of conditions and the following disclaimer.
Ad Schellevis's avatar
Ad Schellevis committed
14

15 16 17
	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.
Ad Schellevis's avatar
Ad Schellevis committed
18

19 20 21 22 23 24 25 26 27 28
	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.
Ad Schellevis's avatar
Ad Schellevis committed
29 30
*/
</copyright>
31
<totalsteps>9</totalsteps>
Ad Schellevis's avatar
Ad Schellevis committed
32 33
<step>
	<id>1</id>
34
	<title>OPNsense Setup Wizard</title>
Ad Schellevis's avatar
Ad Schellevis committed
35
	<disableheader>true</disableheader>
36
	<description>This wizard will guide you through the initial configuration of OPNsense.&lt;br/&gt;&lt;br/&gt; The wizard may be stopped at any time by clicking the logo image at the top of the screen.</description>
Ad Schellevis's avatar
Ad Schellevis committed
37 38 39 40 41 42 43
	<fields>
		<field>
			<name>Next</name>
			<type>submit</type>
		</field>
	</fields>
	<stepbeforeformdisplay>
44 45 46 47
		if (isset($config['trigger_initial_wizard'])) {
			unset($config['trigger_initial_wizard']);
			write_config(gettext("Triggered initial wizard"));
		}
Ad Schellevis's avatar
Ad Schellevis committed
48 49 50 51 52
	</stepbeforeformdisplay>
</step>
<step>
	<id>2</id>
	<title>General Information</title>
53
	<description>On this screen you will set the general OPNsense parameters.</description>
Ad Schellevis's avatar
Ad Schellevis committed
54 55 56 57 58 59
	<fields>
		<field>
			<name>Hostname</name>
			<type>input</type>
			<bindstofield>wizardtemp->system->hostname</bindstofield>
			<description>EXAMPLE: myserver</description>
60
			<validate>^[A-Za-z0-9.|-]+$</validate>
Ad Schellevis's avatar
Ad Schellevis committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
			<message>Invalid Hostname</message>
		</field>
		<field>
			<name>Domain</name>
			<type>input</type>
			<bindstofield>wizardtemp->system->domain</bindstofield>
			<description>EXAMPLE: mydomain.com</description>
			<validate>^[a-z0-9.|-]+$</validate>
			<message>Domain name field is invalid</message>
		</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>
78
			<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>
Ad Schellevis's avatar
Ad Schellevis committed
79 80 81 82 83 84 85
			<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>
86
			<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>
Ad Schellevis's avatar
Ad Schellevis committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
			<message>Secondary DNS Server field is invalid</message>
		</field>
		<field>
			<name>Override DNS</name>
			<description>Allow DNS servers to be overridden by DHCP/PPP on WAN</description>
			<type>checkbox</type>
			<bindstofield>system->dnsallowoverride</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'])) {
111
			print_info_box("Hostname is invalid. Please press back in your browser window and correct.");
Ad Schellevis's avatar
Ad Schellevis committed
112 113 114
			die;
		}
		if(empty($_POST['domain']) || !is_domain($_POST['domain'])) {
115
			print_info_box("Domain is invalid. Please press back in your browser window and correct.");
Ad Schellevis's avatar
Ad Schellevis committed
116 117 118
			die;
		}
		if(!empty($_POST['primarydnsserver']) && !is_ipaddr($_POST['primarydnsserver'])) {
119
			print_info_box("Primary DNS server is invalid. Please press back in your browser window and correct.");
Ad Schellevis's avatar
Ad Schellevis committed
120 121 122
			die;
		}
		if(!empty($_POST['secondarydnsserver']) && !is_ipaddr($_POST['secondarydnsserver'])) {
123
			print_info_box("Second DNS server is invalid. Please press back in your browser window and correct.");
Ad Schellevis's avatar
Ad Schellevis committed
124 125 126 127 128 129
			die;
		}
		]]>
	</stepsubmitphpaction>
</step>
<step>
130
	<id>3</id>
Ad Schellevis's avatar
Ad Schellevis committed
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
	<title>Time Server Information</title>
	<description>Please enter the time, date and time zone.</description>
	<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)) {
154
				print_info_box(gettext("NTP Time Server names may only contain the characters a-z, 0-9, '-' and '.'. Entries may be separated by spaces. Please press back in your browser window and correct."));
Ad Schellevis's avatar
Ad Schellevis committed
155 156 157 158 159 160 161
				die;
			}
		}
		]]>
	</stepsubmitphpaction>
</step>
<step>
162
	<id>4</id>
Ad Schellevis's avatar
Ad Schellevis committed
163 164 165 166 167
	<disableallfieldsbydefault>true</disableallfieldsbydefault>
	<title>Configure WAN Interface</title>
	<description>On this screen we will configure the Wide Area Network information.</description>
	<javascriptafterformdisplay>
		var selectedItem = 0;
168
		if(jQuery('#ipaddress').val() == 'dhcp') {
Ad Schellevis's avatar
Ad Schellevis committed
169
			selectedItem = 1;
170 171
			jQuery('#ipaddress').val('');
		} else if(jQuery('#ipaddress').val() == 'pppoe') {
Ad Schellevis's avatar
Ad Schellevis committed
172
			selectedItem = 2;
173 174
			jQuery('#ipaddress').val('');
		} else if(jQuery('#ipaddress').val() == 'pptp') {
Ad Schellevis's avatar
Ad Schellevis committed
175
			selectedItem = 3;
176 177 178
			jQuery('#ipaddress').val('');
		} else if(jQuery('#ipaddress').val() == 'ppp' || jQuery('#ipaddress').val() == 'l2tp') {
			jQuery('#ipaddress').val('');
Ad Schellevis's avatar
Ad Schellevis committed
179 180 181
		} else {
			selectedItem = 0;
		}
182
		jQuery('#selectedtype').prop('selectedIndex',selectedItem);
Ad Schellevis's avatar
Ad Schellevis committed
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
		enableitems(selectedItem);
	</javascriptafterformdisplay>
	<fields>
		<field>
			<name>SelectedType</name>
			<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>
			<typehint> / </typehint>
			<combinefieldsbegin>true</combinefieldsbegin>
251
			<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>
Ad Schellevis's avatar
Ad Schellevis committed
252 253 254 255 256 257 258 259 260 261 262 263 264 265
			<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>
266
			<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>
Ad Schellevis's avatar
Ad Schellevis committed
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
			<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>
			<description>Hint: this field can usually be left empty</description>
			<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>
			<typehint> / </typehint>
			<bindstofield>wizardtemp->wan->localip</bindstofield>
332
			<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>
Ad Schellevis's avatar
Ad Schellevis committed
333 334 335 336 337 338 339 340 341 342 343 344 345 346
			<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>
347
			<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>
Ad Schellevis's avatar
Ad Schellevis committed
348 349 350 351 352 353
			<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>
354
			<bindstofield>wizardtemp->wan->pptpondemand</bindstofield>
Ad Schellevis's avatar
Ad Schellevis committed
355 356 357 358
			<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>
359
			<type>input</type>
Ad Schellevis's avatar
Ad Schellevis committed
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
			<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). You should generally leave this option turned on, unless your WAN network lies in such a private address space, too.</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. Bogons are prefixes that should never appear in the Internet routing table, and obviously should not appear as the source address in any packets you receive.</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[
394
		if (isset($config['gateways']['gateway_item']))
Ad Schellevis's avatar
Ad Schellevis committed
395 396 397 398 399 400 401 402
			foreach ($config['gateways']['gateway_item'] as $gw)
				if ($gw['name'] == 'WANGW' || (!empty($config['wizardtemp']['wangateway']) && $gw['gateway'] == $config['wizardtemp']['wangateway']))
					$config['wizardtemp']['wangateway'] = $gw['gateway'];
		]]>
	</stepbeforeformdisplay>
	<stepsubmitphpaction>
		<![CDATA[
		if(!empty($_POST['mtu']) && ($_POST['mtu'] < 576)) {
403
			print_info_box("MTU Must be at least 576 (Per RFC 791). Please press back in your browser window and correct.");
Ad Schellevis's avatar
Ad Schellevis committed
404 405 406
			die;
		}
		if(!empty($_POST['macaddress']) && !is_macaddr($_POST['macaddress'])) {
407
			print_info_box("Invalid MAC Address. Please press back in your browser window and correct.");
Ad Schellevis's avatar
Ad Schellevis committed
408 409 410 411
			die;
		}
		if(!empty($_POST['ipaddress']) && ($_POST['selectedtype'] == "Static")) {
			if (!is_ipaddr($_POST['ipaddress'])) {
412
				print_info_box("Invalid WAN IP Address. Please press back in your browser window and correct.");
Ad Schellevis's avatar
Ad Schellevis committed
413 414 415 416 417
				die;
			}
			if ($_POST['subnetmask'] < 31 &&
			    ($_POST['ipaddress'] == gen_subnet($_POST['ipaddress'], $_POST['subnetmask']) ||
			     $_POST['ipaddress'] == gen_subnet_max($_POST['ipaddress'], $_POST['subnetmask']))) {
418
				print_info_box("Invalid WAN IP Address. Please press back in your browser window and correct.");
Ad Schellevis's avatar
Ad Schellevis committed
419 420 421 422
				die;
			}
		}
		if(!empty($_POST['dhcphostname']) && !is_hostname($_POST['dhcphostname'])) {
423
			print_info_box("Invalid DHCP Hostname. Please press back in your browser window and correct.");
Ad Schellevis's avatar
Ad Schellevis committed
424 425 426
			die;
		}
		if(!empty($_POST['pptplocalipaddress']) && !is_ipaddr($_POST['pptplocalipaddress'])) {
427
			print_info_box("Invalid PPTP Local IP Address. Please press back in your browser window and correct.");
Ad Schellevis's avatar
Ad Schellevis committed
428 429 430
			die;
		}
		if(!empty($_POST['pptpremoteipaddress']) && !is_ipaddr($_POST['pptpremoteipaddress'])) {
431
			print_info_box("Invalid PPTP Remopte IP Address. Please press back in your browser window and correct.");
Ad Schellevis's avatar
Ad Schellevis committed
432 433 434 435
			die;
		}
		$type = $_POST['selectedtype'];

436 437 438 439
		if (!is_array($config['ppps'])) {
			$config['ppps'] = array();
		}
		if (!is_array($config['ppps']['ppp'])) {
Ad Schellevis's avatar
Ad Schellevis committed
440
			$config['ppps']['ppp'] = array();
441 442 443 444 445 446 447 448 449
		}
		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]);
Ad Schellevis's avatar
Ad Schellevis committed
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
				}
			}
		}

		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[
480 481 482
			if ($_POST['selectedtype'] != "Static") {
				$_POST['ipaddress'] = $_POST['selectedtype'];
				$config['interfaces']['wan']['ipaddr'] = $_POST['selectedtype'];
Ad Schellevis's avatar
Ad Schellevis committed
483 484 485 486 487
			}
		]]>
	</stepsubmitbeforesave>
</step>
<step>
488
	<id>5</id>
Ad Schellevis's avatar
Ad Schellevis committed
489 490 491 492 493 494 495
	<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>
496
			<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>
497
			<description>(leave empty for none)</description>
Ad Schellevis's avatar
Ad Schellevis committed
498 499 500 501 502 503 504 505 506 507 508 509 510 511
			<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[
512 513
		if (!empty(trim($_POST['lanipaddress']))) {
			if (!is_ipaddr($_POST['lanipaddress'])) {
514
				print_info_box("Invalid LAN IP Address. Please press back in your browser window and correct.");
515 516 517 518 519 520
				die;
			}

			if ($_POST['subnetmask'] < 31 &&
			    ($_POST['lanipaddress'] == gen_subnet($_POST['lanipaddress'], $_POST['subnetmask']) ||
			     $_POST['lanipaddress'] == gen_subnet_max($_POST['lanipaddress'], $_POST['subnetmask']))) {
521
				print_info_box("Invalid LAN IP Address. Please press back in your browser window and correct.");
522 523 524 525 526 527 528 529 530 531 532 533 534 535
				die;
			}

			$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']);
			}
Ad Schellevis's avatar
Ad Schellevis committed
536 537 538 539 540
		}
		]]>
	</stepsubmitphpaction>
</step>
<step>
541
	<id>6</id>
Ad Schellevis's avatar
Ad Schellevis committed
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
	<title>Set Admin WebGUI Password</title>
	<description>On this screen we will set the admin password, which is used to access the WebGUI and also SSH services if you wish to enable them.</description>
	<fields>
		<field>
			<name>Admin Password</name>
			<type>password</type>
		</field>
		<field>
			<name>Admin Password AGAIN</name>
			<type>password</type>
		</field>
		<field>
			<name>Next</name>
			<type>submit</type>
		</field>
	</fields>
	<stepsubmitphpaction>
	if($_POST['adminpassword'] != "") {
		if($_POST['adminpassword'] == $_POST['adminpasswordagain']) {
			$admin_user =&amp; getUserEntryByUID(0);
			local_user_set_password($admin_user, $_POST['adminpassword']);
			local_user_set($admin_user);
			write_config();
		} else {
566
			print_info_box("Passwords do not match!  Please press back in your browser window and correct.");
Ad Schellevis's avatar
Ad Schellevis committed
567 568 569 570 571 572
			die;
		}
	}
	</stepsubmitphpaction>
</step>
<step>
573
	<id>7</id>
Ad Schellevis's avatar
Ad Schellevis committed
574 575
	<title>Reload configuration</title>
	<disableheader>true</disableheader>
576
	<description>Click 'Reload' to reload OPNsense with new changes.</description>
Ad Schellevis's avatar
Ad Schellevis committed
577 578 579 580 581 582 583 584 585 586 587
	<fields>
		<field>
			<name>Reload</name>
			<type>submit</type>
		</field>
	</fields>
	<stepafterformdisplay>
		<![CDATA[
		$config['system']['hostname'] = $config['wizardtemp']['system']['hostname'];
		$config['system']['domain'] = $config['wizardtemp']['system']['domain'];
		if (!empty($config['wizardtemp']['wangateway'])) {
588 589 590
			if (!is_array($config['gateways'])) {
				$config['gateways'] = array();
			}
591
			if (!isset($config['gateways']['gateway_item'])) {
Ad Schellevis's avatar
Ad Schellevis committed
592
				$config['gateways']['gateway_item'] = array();
593
			}
Ad Schellevis's avatar
Ad Schellevis committed
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620
			$found = false;
			$defaultgw_found = false;
			foreach ($config['gateways']['gateway_item'] as & $gw) {
				if ($gw['interface'] != "wan")
					continue;
				if (isset($gw['defaultgw']))
					$defaultgw_found = true;
				if ($gw['name'] == 'WANGW' || (!empty($config['wizardtemp']['wangateway']) && $gw['gateway'] == $config['wizardtemp']['wangateway'])) {
					$found = true;
					$gw['gateway'] = $config['wizardtemp']['wangateway'];
					$config['interfaces']['wan']['gateway'] = $gw['name'];
				}
			}
			if (!$found) {
				$newgw = array();
				$newgw['interface'] = "wan";
				$newgw['gateway'] = $config['wizardtemp']['wangateway'];
				$newgw['name'] = "WANGW";
				$newgw['weight'] = 1;
				$newgw['descr'] = "WAN Gateway";
				$newgw['defaultgw'] = !$defaultgw_found;
				$config['gateways']['gateway_item'][] = $newgw;
				$config['interfaces']['wan']['gateway'] = "WANGW";
			}
		}
		unset($config['wizardtemp']);
		write_config();
621
		]]>
622 623 624 625 626 627 628
	</stepafterformdisplay>
</step>
<step>
	<id>8</id>
	<title>Reload in progress</title>
	<description>
		A reload is now in progress.  Please wait. &lt;p&gt;
629
		&lt;meta http-equiv="refresh" content="5; url=wizard.php?xml=setup&amp;stepid=8" &gt;
630 631 632 633 634
		&lt;p&gt;
		The wizard will redirect to the next step once the reload is completed.
	</description>
	<stepafterformdisplay>
		<![CDATA[
Ad Schellevis's avatar
Ad Schellevis committed
635 636 637 638 639
		reload_all();
		]]>
	</stepafterformdisplay>
</step>
<step>
640
	<id>9</id>
Ad Schellevis's avatar
Ad Schellevis committed
641 642 643
	<title>Wizard completed.</title>
	<description>
	<![CDATA[
644
		Congratulations!  OPNsense is now configured.<p/>
Ad Schellevis's avatar
Ad Schellevis committed
645
		Please consider donating to the project to help us with our overhead costs.<p/>
646
		See <a target='_new' href='https://opnsense.org/'>OPNsense.org</a> to donate or purchase services offered by the OPNsense team.<p/>
647
		Click <a href='$myurl'>here</a> to continue on to OPNsense webConfigurator.
Ad Schellevis's avatar
Ad Schellevis committed
648 649 650
	]]>
	</description>
</step>
651
</opnsensewizard>