Project

General

Profile

Download (21 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	Copyright (C) 2010 Ermal Lu?i
4
	All rights reserved.
5

    
6
	Redistribution and use in source and binary forms, with or without
7
	modification, are permitted provided that the following conditions are met:
8

    
9
	1. Redistributions of source code must retain the above copyright notice,
10
	   this list of conditions and the following disclaimer.
11

    
12
	2. Redistributions in binary form must reproduce the above copyright
13
	   notice, this list of conditions and the following disclaimer in the
14
	   documentation and/or other materials provided with the distribution.
15

    
16
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
17
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
20
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
	POSSIBILITY OF SUCH DAMAGE.
26

    
27
	pfSense_MODULE: openvpn
28
*/
29
require_once("openvpn.inc");
30

    
31
function step1_submitphpaction() {
32
	global $stepid, $config;
33
	if ($_POST['authtype'] == "local") {
34
		$stepid = 4;
35
		$config['ovpnserver']['step1']['type'] = "local";
36
	} else if ($_POST['authtype'] == "ldap") {
37
		$stepid = 0;
38
	} else if ($_POST['authtype'] == "radius") {
39
		$stepid = 2;
40
		$config['ovpnserver']['step1']['type'] = "radius";
41
		unset($config['ovpnserver']['step1']['uselist']);
42
	}
43
}
44

    
45
function step2_stepbeforeformdisplay() {
46
	global $pkg, $stepid;
47

    
48
	$fields =& $pkg['step'][1]['fields']['field'];
49

    
50
	$found = false;
51
	$authlist = auth_get_authserver_list();
52
	$fields[1]['options']['option'] = array();
53
	foreach ($authlist as $i => $auth) {
54
		if ($auth['type'] != "ldap")
55
			continue;
56
		$found = true;
57
		$opts = array();
58
		$opts['name'] = $auth['name'];
59
		$opts['value'] = $auth['name'];
60
		$fields[1]['options']['option'][] = $opts;
61
	}
62
	if ($found == false) {
63
		$stepid = 2;
64
	}
65
}
66

    
67
function step2_submitphpaction() {
68
	global $stepid;
69

    
70
	if (isset($_POST['next'])) {
71
		$_POST['uselist'] = "";
72
		$stepid +=3;
73
	}
74
}
75

    
76
function step3_submitphpaction() {
77
	global $stepid, $savemsg, $config;
78

    
79
	/* Default LDAP port is 389 for TCP and 636 for SSL */
80
	if (empty($_POST['port'])) {
81
		if ($_POST['transport'] == "tcp")
82
			$config['ovpnserver']['step2']['port'] = 389;
83
		elseif ($_POST['transport'] == "ssl")
84
			$config['ovpnserver']['step2']['port'] = 636;
85
	} elseif (!is_port($_POST['port'])) {
86
		$stepid--;
87
		$savemsg = "Please enter a valid port number.";
88
	}
89

    
90
	if (empty($_POST['name']) || empty($_POST['ip']) ||empty($_POST['transport']) ||
91
	     empty($_POST['scope']) || empty($_POST['basedn']) || empty($_POST['authscope']) || empty($_POST['nameattr'])) {
92
		$stepid--;
93
		$savemsg = "Please enter all information for authentication server.";
94
	} else if (count(($authcfg = auth_get_authserver($_POST['name']))) > 0) {
95
		$stepid--;
96
		$savemsg = "Please choose a different name because an authentication server with this name already exists.";
97
	} elseif (!is_fqdn($_POST['ip']) && !is_ipaddr($_POST['ip'])) {
98
		$stepid--;
99
		$savemsg = "Please enter a valid IP address or hostname for the authentication server.";
100
	} else {
101
		$config['ovpnserver']['step2']['uselist'] = "on";
102
		$_POST['uselist'] = "on";
103
		$stepid += 2;
104
	}
105
}
106

    
107
function step4_stepbeforeformdisplay() {
108
	global $pkg, $stepid;
109

    
110
	$fields =& $pkg['step'][3]['fields']['field'];
111

    
112
	$found = false;
113
	$authlist = auth_get_authserver_list();
114
	$fields[1]['options']['option'] = array();
115
	foreach ($authlist as $i => $auth) {
116
		if ($auth['type'] != "radius")
117
			continue;
118
		$found = true;
119
		$opts = array();
120
		$opts['name'] = $auth['name'];
121
		$opts['value'] = $auth['name'];
122
		$fields[1]['options']['option'][] = $opts;
123
	}
124
	if ($found == false)
125
		$stepid = 4;
126
}
127

    
128
function step4_submitphpaction() {
129
	global $stepid;
130

    
131
	if (isset($_POST['next'])) {
132
		$_POST['uselist'] = "";
133
		$stepid++;
134
	}
135
}
136

    
137
function step5_submitphpaction() {
138
	global $stepid, $savemsg, $config;
139

    
140
	/* Default RADIUS Auth port = 1812 */
141
	if (empty($_POST['port'])) {
142
		$config['ovpnserver']['step2']['port'] = 1812;
143
	} elseif (!is_port($_POST['port'])) {
144
		$stepid--;
145
		$savemsg = "Please enter a valid port number.";
146
	}
147

    
148
	if (empty($_POST['name']) || empty($_POST['ip']) || empty($_POST['secret'])) {
149
		$stepid--;
150
		$savemsg = "Please enter all information for authentication server.";
151
	} else if (count(($authcfg = auth_get_authserver($_POST['name']))) > 0) {
152
		$stepid--;
153
		$savemsg = "Please choose a different name because an authentication server with this name already exists.";
154
	} elseif (!is_fqdn($_POST['ip']) && !is_ipaddr($_POST['ip'])) {
155
		$stepid--;
156
		$savemsg = "Please enter a valid IP address or hostname for the authentication server.";
157
	} else {
158
		$config['ovpnserver']['step2']['uselist'] = "on";
159
		$_POST['uselist'] = "on";
160
	}
161
}
162

    
163
function step6_stepbeforeformdisplay() {
164
	global $stepid, $config;
165

    
166
	if (count($config['system']['ca']) < 1) {
167
		$stepid++;
168
	}
169
}
170

    
171
function step6_submitphpaction() {
172
	global $stepid, $config;
173

    
174
	if (isset($_POST['next'])) {
175
		$_POST['uselist'] = "";
176
		$stepid++;
177
	} else {
178
		$config['ovpnserver']['step6']['uselist'] = "on";
179
		$_POST['uselist'] = "on";
180
	}
181
}
182

    
183
function step7_submitphpaction() {
184
	global $stepid, $savemsg, $_POST, $config;
185

    
186
	$canames = array();
187
	$cacns = array();
188
	if (is_array($config['system']['ca'])) {
189
		foreach($config['system']['ca'] as $ca) {
190
			$canames[] = $ca['name'];
191
			$cainfo = cert_get_subject_hash($ca['crt']);
192
			$cacns[] = $cainfo["CN"];
193
		}
194
	}
195

    
196
	if (empty($_POST['name']) || empty($_POST['keylength']) || empty($_POST['lifetime']) ||
197
	    empty($_POST['country']) || empty($_POST['state']) || empty($_POST['city']) ||
198
	    empty($_POST['organization']) || empty($_POST['email'])) {
199
		$stepid--;
200
		$savemsg = "Please enter all information for the new Certificate Authority.";
201
	} elseif (in_array($_POST['name'], $canames) || in_array($_POST['name'], $cacns)) {
202
		$stepid--;
203
		$savemsg = "Please enter a different name for the Certicicate Authority. A Certificate Authority with that name already exists.";
204
	} elseif (strlen($_POST['country']) != 2) {
205
		$stepid--;
206
		$savemsg = "Please enter only a two-letter ISO country code";
207
	} else {
208
		$config['ovpnserver']['step6']['uselist'] = "on";
209
		$_POST['uselist'] = "on";
210
	}
211
}
212

    
213
function step8_stepbeforeformdisplay() {
214
	global $stepid, $config;
215

    
216
	if (count($config['system']['cert']) < 1 ||
217
		(count($config['system']['cert']) == 1 && stristr($config['system']['cert'][0]['name'], "webconf"))) {
218
		$stepid++;
219
	}
220
}
221

    
222
function step8_submitphpaction() {
223
	global $stepid, $_POST;
224

    
225
	if (isset($_POST['next'])) {
226
		$_POST['uselist'] = "";
227
		$stepid++;
228
	}
229
}
230

    
231
function step9_stepbeforeformdisplay() {
232
	global $config, $pkg, $stepid;
233

    
234
	$pconfig = $config['ovpnserver'];
235

    
236
	if (isset($pconfig['step6']['uselist'])) {
237
		$country = $pconfig['step6']['country'];
238
		$state = $pconfig['step6']['state'];
239
		$city = $pconfig['step6']['city'];
240
		$org = $pconfig['step6']['organization'];
241
	} else {
242
		$ca = lookup_ca($pconfig['step6']['authcertca']);
243
		$cavl = cert_get_subject_array($ca['crt']);
244
		$country = $cavl[0]['v'];
245
		$state = $cavl[1]['v'];
246
		$city = $cavl[2]['v'];
247
		$org = $cavl[3]['v'];
248
	}
249
	$fields =& $pkg['step'][$stepid]['fields']['field'];
250

    
251
	foreach ($fields as $idx => $field) {
252
		switch ($field['name']) {
253
		case 'country':
254
			$fields[$idx]['value'] = $country;
255
			break;
256
		case 'state':
257
			$fields[$idx]['value'] = $state;
258
			break;
259
		case 'city':
260
			$fields[$idx]['value'] = $city;
261
			break;
262
		case 'organization':
263
			$fields[$idx]['value'] = $org;
264
			break;
265
		}
266
	}
267
}
268

    
269
function step9_submitphpaction() {
270
	global $stepid, $savemsg, $_POST, $config;
271

    
272
	$certnames = array();
273
	$certcns = array();
274
	if (is_array($config['system']['cert'])) {
275
		foreach($config['system']['cert'] as $cert) {
276
			$certnames[] = $cert['name'];
277
			$certinfo = cert_get_subject_hash($cert['crt']);
278
			$certcns[] = $certinfo["CN"];
279
		}	
280
	}
281

    
282
	if (empty($_POST['name']) || empty($_POST['keylength']) || empty($_POST['lifetime']) ||
283
	    empty($_POST['country']) || empty($_POST['state']) || empty($_POST['city']) ||
284
	    empty($_POST['organization']) || empty($_POST['email'])) {
285
		$stepid--;
286
		$savemsg = "Please enter all information for the new certificate.";
287
	} elseif (in_array($_POST['name'], $certnames) || in_array($_POST['name'], $certcns)) {
288
		$stepid--;
289
		$savemsg = "Please enter a different name for the Certicicate. A Certificate with that name/common name already exists.";	
290
	} elseif (strlen($_POST['country']) != 2) {
291
		$stepid--;
292
		$savemsg = "Please enter only a two-letter ISO country code";
293
	} else {
294
		$config['ovpnserver']['step9']['uselist'] = "on";
295
		$_POST['uselist'] = "on";
296
	}
297
}
298

    
299
function step10_stepbeforeformdisplay() {
300
	global $pkg, $stepid, $netbios_nodetypes;
301

    
302
	foreach ($pkg['step'][$stepid]['fields']['field'] as $idx => $field) {
303
		if ($field['name'] == "crypto") {
304
			$pkg['step'][$stepid]['fields']['field'][$idx]['options']['option'] = array();
305
			$cipherlist = openvpn_get_cipherlist();
306
			foreach ($cipherlist as $name => $desc) {
307
				$opt = array();
308
				$opt['name'] = $desc;
309
				$opt['value'] = $name;
310
			$pkg['step'][$stepid]['fields']['field'][$idx]['options']['option'][] = $opt;
311
			}
312
		} else if ($field['name'] == "nbttype") {
313
			$pkg['step'][$stepid]['fields']['field'][$idx]['options']['option'] = array();
314
			foreach ($netbios_nodetypes as $type => $name) {
315
				$opt = array();
316
				$opt['name'] = $name;
317
				$opt['value'] = $type;
318
			$pkg['step'][$stepid]['fields']['field'][$idx]['options']['option'][] = $opt;
319
			}
320
		} else if ($field['name'] == "localport") {
321
			$pkg['step'][$stepid]['fields']['field'][$idx]['value'] = openvpn_port_next('UDP');
322
		}
323
	}
324
}
325

    
326
function step10_submitphpaction() {
327
	global $savemsg, $stepid;
328

    
329
	/* Default OpenVPN port to next available port if left empty. */
330
	if (empty($_POST['localport']))
331
		$pconfig["step10"]["localport"] = openvpn_port_next('UDP');
332

    
333
	/* input validation */
334
	if ($result = openvpn_validate_port($_POST['localport'], 'Local port'))
335
		$input_errors[] = $result;
336

    
337
	if ($result = openvpn_validate_cidr($_POST['tunnelnet'], 'Tunnel network'))
338
		$input_errors[] = $result;
339

    
340
	if ($result = openvpn_validate_cidr($_POST['localnet'], 'Local network'))
341
		$input_errors[] = $result;
342

    
343
	$portused = openvpn_port_used($_POST['protocol'], $_POST['localport']);
344
	if ($portused != 0)
345
		$input_errors[] = "The specified 'Local port' is in use. Please select another value";
346

    
347
	if (!isset($_POST['generatetlskey']) && isset($_POST['tlsauthentication']))
348
		if (!strstr($_POST['tlssharedkey'], "-----BEGIN OpenVPN Static key V1-----") ||
349
			!strstr($_POST['tlssharedkey'], "-----END OpenVPN Static key V1-----"))
350
			$input_errors[] = "The field 'TLS Authentication Key' does not appear to be valid";
351

    
352
	if (!empty($_POST['dnsserver1']) && !is_ipaddr(trim($_POST['dnsserver1'])))
353
		$input_errors[] = "The field 'DNS Server #1' must contain a valid IP address";
354
	if (!empty($_POST['dnsserver2']) && !is_ipaddr(trim($_POST['dnsserver2'])))
355
		$input_errors[] = "The field 'DNS Server #2' must contain a valid IP address";
356
	if (!empty($_POST['dnsserver3']) && !is_ipaddr(trim($_POST['dnsserver3'])))
357
		$input_errors[] = "The field 'DNS Server #3' must contain a valid IP address";
358
	if (!empty($_POST['dnsserver4']) && !is_ipaddr(trim($_POST['dnsserver4'])))
359
		$input_errors[] = "The field 'DNS Server #4' must contain a valid IP address";
360

    
361
	if (!empty($_POST['ntpserver1']) && !is_ipaddr(trim($_POST['ntpserver1'])))
362
		$input_errors[] = "The field 'NTP Server #1' must contain a valid IP address";
363
	if (!empty($_POST['ntpserver2']) && !is_ipaddr(trim($_POST['ntpserver2'])))
364
		$input_errors[] = "The field 'NTP Server #2' must contain a valid IP address";
365

    
366
	if (!empty($_POST['winsserver1']) && !is_ipaddr(trim($_POST['winsserver1'])))
367
		$input_errors[] = "The field 'WINS Server #1' must contain a valid IP address";
368
	if (!empty($_POST['winsserver2']) && !is_ipaddr(trim($_POST['winsserver2'])))
369
		$input_errors[] = "The field 'WINS Server #2' must contain a valid IP address";
370

    
371
	if ($_POST['concurrentcon'] && !is_numeric($_POST['concurrentcon']))
372
		$input_errors[] = "The field 'Concurrent connections' must be numeric.";
373

    
374
	if (empty($_POST['tunnelnet']))
375
		$input_errors[] = "You must specify a 'Tunnel network'.";
376

    
377
	if (count($input_errors) > 0) {
378
		$savemsg = $input_errors[0];
379
		$stepid = $stepid - 1;
380
	}
381
}
382

    
383
function step12_submitphpaction() {
384
	global $config;
385

    
386
	$pconfig = $config['ovpnserver'];
387

    
388
	if (!is_array($config['ovpnserver'])) {
389
		$message = "No configuration found please retry again.";
390
		header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=1&message={$message}");
391
		exit;
392
	}
393

    
394
	if ($pconfig['step1']['type'] == "local") {
395
		$auth = array();
396
		$auth['name'] = "Local Database";
397
		$auth['type'] = "local";
398
	} else if (isset($pconfig['step2']['uselist'])) {
399
		$auth = array();
400
		$auth['type'] = $pconfig['step1']['type'];
401
		$auth['refid'] = uniqid();
402
		$auth['name'] = $pconfig['step2']['authtype'];
403

    
404
		if ($auth['type'] == "ldap") {
405
			$auth['host'] = $pconfig['step2']['ip'];
406
			$auth['ldap_port'] = $pconfig['step2']['port'];
407
			if ($pconfig['step1']['transport'] == "tcp")
408
				$auth['ldap_urltype'] = 'TCP - Standard';
409
			else
410
				$auth['ldap_urltype'] = 'SSL - Encrypted';
411
			$auth['ldap_protver'] = 3;
412
			$auth['ldap_scope'] = $pconfig['step2']['scope'];
413
			$auth['ldap_basedn'] = $pconfig['step2']['basedn'];
414
			$auth['ldap_authcn'] = $pconfig['step2']['authscope'];
415
			$auth['ldap_binddn'] = $pconfig['step2']['userdn'];
416
			$auth['ldap_bindpw'] = $pconfig['step2']['passdn'];
417
			$auth['ldap_attr_user'] = $pconfig['step1']['nameattr'];
418
			$auth['ldap_attr_member'] = $pconfig['step1']['memberattr'];
419
			$auth['ldap_attr_group'] = $pconfig['step1']['groupattr'];
420
		} else if ($auth['type'] == "radius") {
421
			$auth['host'] = $pconfig['step2']['ip'];
422
			$auth['radius_auth_port'] = $pconfig['step2']['port'];
423
			$auth['radius_secret'] = $pconfig['step2']['password'];
424
			$auth['radius_srvcs'] = "auth";
425
		}
426
		if (!is_array($config['system']['authserver']))
427
			$config['system']['authserver'] = array();
428

    
429
		$config['system']['authserver'][] = $auth;
430
	} else if (!isset($pconfig['step2']['uselist']) && empty($pconfig['step2']['authserv'])) {
431
		$message = "Please choose an authentication server .";
432
		header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=1&message={$message}");
433
		exit;
434
	} else if (!($auth = auth_get_authserver($pconfig['step2']['authserv']))) {
435
		$message = "Not a valid authentication server has been specified.";
436
		header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=1&message={$message}");
437
		exit;
438
	}
439

    
440
	if (isset($pconfig['step6']['uselist'])) {
441
		$ca = array();
442
		$ca['refid'] = uniqid();
443
		$ca['name'] = $pconfig['step6']['certca'];
444
		$dn = array(
445
			'countryName' => $pconfig['step6']['country'],
446
			'stateOrProvinceName' => $pconfig['step6']['state'],
447
			'localityName' => $pconfig['step6']['city'],
448
			'organizationName' => $pconfig['step6']['organization'],
449
			'emailAddress' => $pconfig['step6']['email'],
450
			'commonName' => $pconfig['step6']['certca']);
451

    
452
		ca_create($ca, $pconfig['step6']['keylength'], $pconfig['step6']['lifetime'], $dn);
453
		if (!is_array($config['system']['ca']))
454
			$config['system']['ca'] = array();
455

    
456
		$config['system']['ca'][] = $ca;
457
	} else if (!isset($pconfig['step6']['uselist']) && empty($pconfig['step6']['authcertca'])) {
458
		$message = "Please choose a Certificate Authority.";
459
		header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=5&message={$message}");
460
		exit;
461
	} else if (!($ca = lookup_ca($pconfig['step6']['authcertca']))) {
462
		$message = "Not a valid Certificate Authority specified.";
463
		header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=5&message={$message}");
464
		exit;
465
	}
466

    
467
	if (isset($pconfig['step9']['uselist'])) {
468
		$cert = array();
469
		$cert['refid'] = uniqid();
470
		$cert['name'] = $pconfig['step9']['certname'];
471
		$dn = array(
472
			'countryName' => $pconfig['step9']['country'],
473
			'stateOrProvinceName' => $pconfig['step9']['state'],
474
			'localityName' => $pconfig['step9']['city'],
475
			'organizationName' => $pconfig['step9']['organization'],
476
			'emailAddress' => $pconfig['step9']['email'],
477
			'commonName' => $pconfig['step9']['certname']);
478

    
479
		cert_create($cert, $ca['refid'], $pconfig['step9']['keylength'], $pconfig['step9']['lifetime'], $dn);
480
		if (!is_array($config['system']['cert']))
481
			$config['system']['cert'] = array();
482

    
483
		$config['system']['cert'][] = $cert;
484
	} else if (!isset($pconfig['step6']['uselist']) && empty($pconfig['step9']['authcertname'])) {
485
		$message = "Please choose a Certificate.";
486
		header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=7&message={$message}");
487
		exit;
488
	} else if (!($cert = lookup_cert($pconfig['step9']['authcertname']))) {
489
		$message = "Not a valid Certificate specified.";
490
		header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=7&message={$message}");
491
		exit;
492
	}
493
	$server = array();
494
	$server['vpnid'] = openvpn_vpnid_next();
495
	switch ($auth['type']) {
496
		case "ldap":
497
			$server['authmode'] = $auth['name'];
498
			$server['mode'] = "server_user";
499
			break;
500
		case "radius":
501
			$server['authmode'] = $auth['name'];
502
			$server['mode'] = "server_user";
503
			break;
504
		default:
505
			$server['authmode'] = "Local Database";
506
			$server['mode'] = "server_tls_user";
507
			break;
508
	}
509
	$server['caref'] = $ca['refid'];
510
	$server['certref'] = $cert['refid'];
511
	$server['protocol'] = $pconfig['step10']['protocol'];
512
	$server['interface'] = $pconfig['step10']['interface'];
513
	if (isset($pconfig['step10']['localport']))
514
		$server['local_port'] = $pconfig['step10']['localport'];
515
	$server['description'] = $pconfig['step10']['descr'];
516
	$server['custom_options'] = $pconfig['step10']['advanced'];
517
	if (isset($pconfig['step10']['tlsauth'])) {
518
		if (isset($pconfig['step10']['gentlskey']))
519
			$tlskey = openvpn_create_key();
520
		else
521
			$tlskey = $pconfig['step10']['tlskey'];
522
		$server['tls'] = base64_encode($tlskey);
523
	}
524
	$server['dh_length'] = $pconfig['step10']['dhkey'];
525
	$server['tunnel_network'] = $pconfig['step10']['tunnelnet'];
526
	if (isset($pconfig['step10']['rdrgw']))
527
		$server['gwredir'] = $pconfig['step10']['rdrgw'];
528
	if (isset($pconfig['step10']['localnet']))
529
		$server['local_network'] = $pconfig['step10']['localnet'];
530
	if (isset($pconfig['step10']['concurrentcon']))
531
		$server['maxclients'] = $pconfig['step10']['concurrentcon'];
532
	if (isset($pconfig['step10']['compression']))
533
		$server['compression'] = $pconfig['step10']['compression'];
534
	if (isset($pconfig['step10']['tos']))
535
		$server['passtos'] = $pconfig['step10']['tos'];
536
	if (isset($pconfig['step10']['interclient']))
537
		$server['client2client'] = $pconfig['step10']['interclient'];
538
	if (isset($pconfig['step10']['dynip']))
539
		$server['dynamic_ip'] = $pconfig['step10']['dynip'];
540
	if (isset($pconfig['step10']['addrpool']))
541
		$server['pool_enable'] = $pconfig['step10']['addrpool'];
542
	if (isset($pconfig['step10']['defaultdomain']))
543
		$server['dns_domain'] = $pconfig['step10']['defaultdomain'];
544
	if (isset($pconfig['step10']['dns1']))
545
		$server['dns_server1'] = $pconfig['step10']['dns1'];
546
	if (isset($pconfig['step10']['dns2']))
547
		$server['dns_server2'] = $pconfig['step10']['dns2'];
548
	if (isset($pconfig['step10']['dns3']))
549
		$server['dns_server3'] = $pconfig['step10']['dns3'];
550
	if (isset($pconfig['step10']['dns4']))
551
		$server['dns_server4'] = $pconfig['step10']['dns4'];
552
	if (isset($pconfig['step10']['ntp1']))
553
		$server['ntp_server1'] = $pconfig['step10']['ntp1'];
554
	if (isset($pconfig['step10']['ntp2']))
555
		$server['ntp_server2'] = $pconfig['step10']['ntp2'];
556
	if (isset($pconfig['step10']['wins1']))
557
		$server['wins_server1'] = $pconfig['step10']['wins1'];
558
	if (isset($pconfig['step10']['wins2']))
559
		$server['wins_server2'] = $pconfig['step10']['wins2'];
560
	if (isset($pconfig['step10']['nbtenable'])) {
561
		$server['netbios_ntype'] = $pconfig['step10']['nbttype'];
562
		if (isset($pconfig['step10']['nbtscope']))
563
			$server['netbios_scope'] = $pconfig['step10']['nbtscope'];
564
		$server['netbios_enable'] = $pconfig['step10']['nbtenable'];
565
	}
566
	$server['crypto'] = $pconfig['step10']['crypto'];
567

    
568
	if (isset($pconfig['step11']['ovpnrule'])) {
569
		$rule = array();
570
		$rule['descr'] = gettext("OpenVPN {$server['description']} wizard rules.");
571
		$rule['direction'] = "in";
572
		$rule['source']['any'] = TRUE;
573
		$rule['destination']['network'] = $server['interface'] . "ip";
574
		$rule['destination']['port'] = $server['local_port'];
575
		$rule['interface'] = $server['interface'];
576
		$rule['protocol'] = $server['protocol'];
577
		$rule['type'] = "pass";
578
		$rule['enabled'] = "on";
579
		$config['filter']['rule'][] = $rule;
580
	}
581
	if (isset($pconfig['step11']['ovpnallow'])) {
582
		$rule = array();
583
		$rule['descr'] = gettext("OpenVPN {$server['description']} wizard rules.");
584
		$rule['source']['any'] = TRUE;
585
		$rule['destination']['any'] = TRUE;
586
		$rule['interface'] = "openvpn";
587
		//$rule['protocol'] = $server['protocol'];
588
		$rule['type'] = "pass";
589
		$rule['enabled'] = "on";
590
		$config['filter']['rule'][] = $rule;
591
	}
592

    
593
	if (!is_array($config['openvpn']['openvpn-server']))
594
		$config['openvpn']['openvpn-server'] = array();
595

    
596
	$config['openvpn']['openvpn-server'][] = $server;
597

    
598
	openvpn_resync('server', $server);
599
	write_config();
600
	header("Location: vpn_openvpn_server.php");
601
	exit;
602
}
603

    
604
?>
(1-1/11)