Project

General

Profile

Download (49.5 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php 
2
/*
3
	vpn_openvpn_server.php
4

    
5
	Copyright (C) 2008 Shrew Soft Inc.
6
	All rights reserved. 
7

    
8
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10
	
11
	1. Redistributions of source code must retain the above copyright notice,
12
	   this list of conditions and the following disclaimer.
13
	
14
	2. Redistributions in binary form must reproduce the above copyright
15
	   notice, this list of conditions and the following disclaimer in the
16
	   documentation and/or other materials provided with the distribution.
17
	
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29

    
30
##|+PRIV
31
##|*IDENT=page-openvpn-server
32
##|*NAME=OpenVPN: Server page
33
##|*DESCR=Allow access to the 'OpenVPN: Server' page.
34
##|*MATCH=vpn_openvpn_server.php*
35
##|-PRIV
36

    
37
require("guiconfig.inc");
38
require_once("openvpn.inc");
39

    
40
$pgtitle = array(gettext("OpenVPN"), gettext("Server"));
41
$statusurl = "status_openvpn.php";
42
$logurl = "diag_logs_openvpn.php";
43

    
44
if (!is_array($config['openvpn']['openvpn-server']))
45
	$config['openvpn']['openvpn-server'] = array();
46

    
47
$a_server = &$config['openvpn']['openvpn-server'];
48

    
49
$id = $_GET['id'];
50
if (isset($_POST['id']))
51
	$id = $_POST['id'];
52

    
53
$act = $_GET['act'];
54
if (isset($_POST['act']))
55
	$act = $_POST['act'];
56

    
57
if ($_GET['act'] == "del") {
58

    
59
	if (!$a_server[$id]) {
60
		pfSenseHeader("vpn_openvpn_server.php");
61
		exit;
62
	}
63

    
64
	openvpn_delete('server', $a_server[$id]);
65
	unset($a_server[$id]);
66
	write_config();
67
	$savemsg = gettext("Server successfully deleted")."<br/>";
68
}
69

    
70
if($_GET['act']=="new"){
71
	$pconfig['autokey_enable'] = "yes";
72
	$pconfig['tlsauth_enable'] = "yes";
73
	$pconfig['autotls_enable'] = "yes";
74
	$pconfig['dh_length'] = 1024;
75
	$pconfig['interface'] = "wan";
76
	$pconfig['local_port'] = openvpn_port_next('UDP');
77
	$pconfig['pool_enable'] = "yes";
78
}
79

    
80
if($_GET['act']=="edit"){
81

    
82
	if (isset($id) && $a_server[$id]) {
83

    
84
		$pconfig['disable'] = isset($a_server[$id]['disable']);
85
		$pconfig['mode'] = $a_server[$id]['mode'];
86
		$pconfig['protocol'] = $a_server[$id]['protocol'];
87
		$pconfig['authmode'] = $a_server[$id]['authmode'];
88
		$pconfig['interface'] = $a_server[$id]['interface'];
89
		if (!empty($a_server[$id]['ipaddr'])) {
90
			$pconfig['interface'] = $pconfig['interface'] . '|' . $a_server[$id]['ipaddr'];
91
		}
92
		$pconfig['local_port'] = $a_server[$id]['local_port'];
93
		$pconfig['description'] = $a_server[$id]['description'];
94
		$pconfig['custom_options'] = $a_server[$id]['custom_options'];
95

    
96
		if ($pconfig['mode'] != "p2p_shared_key") {
97
			if ($a_server[$id]['tls']) {
98
				$pconfig['tlsauth_enable'] = "yes";
99
				$pconfig['tls'] = base64_decode($a_server[$id]['tls']);
100
			}
101
			$pconfig['caref'] = $a_server[$id]['caref'];
102
			$pconfig['crlref'] = $a_server[$id]['crlref'];
103
			$pconfig['certref'] = $a_server[$id]['certref'];
104
			$pconfig['dh_length'] = $a_server[$id]['dh_length'];
105
			if ($pconfig['mode'] == "server_tls_user")
106
				$pconfig['strictusercn'] = $a_server[$id]['strictusercn'];
107
		} else
108
			$pconfig['shared_key'] = base64_decode($a_server[$id]['shared_key']);
109
		$pconfig['crypto'] = $a_server[$id]['crypto'];
110

    
111
		$pconfig['tunnel_network'] = $a_server[$id]['tunnel_network'];
112
		$pconfig['remote_network'] = $a_server[$id]['remote_network'];
113
		$pconfig['gwredir'] = $a_server[$id]['gwredir'];
114
		$pconfig['local_network'] = $a_server[$id]['local_network'];
115
		$pconfig['maxclients'] = $a_server[$id]['maxclients'];
116
		$pconfig['compression'] = $a_server[$id]['compression'];
117
		$pconfig['passtos'] = $a_server[$id]['passtos'];
118
		$pconfig['client2client'] = $a_server[$id]['client2client'];
119

    
120
		$pconfig['dynamic_ip'] = $a_server[$id]['dynamic_ip'];
121
		$pconfig['pool_enable'] = $a_server[$id]['pool_enable'];
122

    
123
		$pconfig['dns_domain'] = $a_server[$id]['dns_domain'];
124
		if ($pconfig['dns_domain'])
125
			$pconfig['dns_domain_enable'] = true;
126

    
127
		$pconfig['dns_server1'] = $a_server[$id]['dns_server1'];
128
		$pconfig['dns_server2'] = $a_server[$id]['dns_server2'];
129
		$pconfig['dns_server3'] = $a_server[$id]['dns_server3'];
130
		$pconfig['dns_server4'] = $a_server[$id]['dns_server4'];
131
		if ($pconfig['dns_server1'] ||
132
			$pconfig['dns_server2'] ||
133
			$pconfig['dns_server3'] ||
134
			$pconfig['dns_server4'])
135
			$pconfig['dns_server_enable'] = true;
136

    
137
		$pconfig['ntp_server1'] = $a_server[$id]['ntp_server1'];
138
		$pconfig['ntp_server2'] = $a_server[$id]['ntp_server2'];
139
		if ($pconfig['ntp_server1'] ||
140
			$pconfig['ntp_server2'])
141
			$pconfig['ntp_server_enable'] = true;
142

    
143
		$pconfig['netbios_enable'] = $a_server[$id]['netbios_enable'];
144
		$pconfig['netbios_ntype'] = $a_server[$id]['netbios_ntype'];
145
		$pconfig['netbios_scope'] = $a_server[$id]['netbios_scope'];
146

    
147
		$pconfig['wins_server1'] = $a_server[$id]['wins_server1'];
148
		$pconfig['wins_server2'] = $a_server[$id]['wins_server2'];
149
		if ($pconfig['wins_server1'] ||
150
			$pconfig['wins_server2'])
151
			$pconfig['wins_server_enable'] = true;
152

    
153
		$pconfig['nbdd_server1'] = $a_server[$id]['nbdd_server1'];
154
		if ($pconfig['nbdd_server1'])
155
			$pconfig['nbdd_server_enable'] = true;
156

    
157
		// just in case the modes switch
158
		$pconfig['autokey_enable'] = "yes";
159
		$pconfig['autotls_enable'] = "yes";
160
	}
161
}
162

    
163
if ($_POST) {
164

    
165
	unset($input_errors);
166
	$pconfig = $_POST;
167

    
168
	if (isset($id) && $a_server[$id])
169
		$vpnid = $a_server[$id]['vpnid'];
170
	else
171
		$vpnid = 0;
172

    
173
	if ($pconfig['mode'] != "p2p_shared_key")
174
		$tls_mode = true;
175
	else
176
		$tls_mode = false;
177

    
178
	if (!empty($pconfig['authmode'])) {
179
		foreach ($pconfig['authmode'] as $pauthmode) {
180
			if ($pauthmode != "Local Database" && $pconfig['mode'] == "server_tls_user") 
181
				$input_errors[] = gettext("Only 'Local authentication database'  is allowed with") . " " . $openvpn_server_modes[$pconfig['mode']];
182
		}
183
	}
184

    
185
	if (empty($pconfig['authmode']) && (($pconfig['mode'] == "server_user") || ($pconfig['mode'] == "server_tls_user")))
186
		$input_errors[] = gettext("You must select a Backend for Authentication if the server mode requires User Auth.");
187

    
188
	/* input validation */
189
	if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
190
		$input_errors[] = $result;
191

    
192
	if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'Tunnel network'))
193
		$input_errors[] = $result;
194

    
195
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'Remote network'))
196
		$input_errors[] = $result;
197

    
198
	if ($result = openvpn_validate_cidr($pconfig['local_network'], 'Local network'))
199
		$input_errors[] = $result;
200

    
201
	$portused = openvpn_port_used($pconfig['protocol'], $pconfig['local_port']);
202
	if (($portused != $vpnid) && ($portused != 0))
203
		$input_errors[] = gettext("The specified 'Local port' is in use. Please select another value");
204

    
205
	if ($pconfig['autokey_enable'])
206
		$pconfig['shared_key'] = openvpn_create_key();
207

    
208
	if (!$tls_mode && !$pconfig['autokey_enable'])
209
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
210
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
211
			$input_errors[] = gettext("The field 'Shared Key' does not appear to be valid");
212

    
213
	if ($tls_mode && $pconfig['tlsauth_enable'] && !$pconfig['autotls_enable'])
214
		if (!strstr($pconfig['tls'], "-----BEGIN OpenVPN Static key V1-----") ||
215
			!strstr($pconfig['tls'], "-----END OpenVPN Static key V1-----"))
216
			$input_errors[] = gettext("The field 'TLS Authentication Key' does not appear to be valid");
217

    
218
	if ($pconfig['dns_server_enable']) {
219
		if (!empty($pconfig['dns_server1']) && !is_ipaddr(trim($pconfig['dns_server1'])))
220
			$input_errors[] = gettext("The field 'DNS Server #1' must contain a valid IP address");
221
		if (!empty($pconfig['dns_server2']) && !is_ipaddr(trim($pconfig['dns_server2'])))
222
			$input_errors[] = gettext("The field 'DNS Server #2' must contain a valid IP address");
223
		if (!empty($pconfig['dns_server3']) && !is_ipaddr(trim($pconfig['dns_server3'])))
224
			$input_errors[] = gettext("The field 'DNS Server #3' must contain a valid IP address");
225
		if (!empty($pconfig['dns_server4']) && !is_ipaddr(trim($pconfig['dns_server4'])))
226
			$input_errors[] = gettext("The field 'DNS Server #4' must contain a valid IP address");
227
	}
228

    
229
	if ($pconfig['ntp_server_enable']) {
230
		if (!empty($pconfig['ntp_server1']) && !is_ipaddr(trim($pconfig['ntp_server1'])))
231
			$input_errors[] = gettext("The field 'NTP Server #1' must contain a valid IP address");
232
		if (!empty($pconfig['ntp_server2']) && !is_ipaddr(trim($pconfig['ntp_server2'])))
233
			$input_errors[] = gettext("The field 'NTP Server #2' must contain a valid IP address");
234
		if (!empty($pconfig['ntp_server3']) && !is_ipaddr(trim($pconfig['ntp_server3'])))
235
			$input_errors[] = gettext("The field 'NTP Server #3' must contain a valid IP address");
236
		if (!empty($pconfig['ntp_server4']) && !is_ipaddr(trim($pconfig['ntp_server4'])))
237
			$input_errors[] = gettext("The field 'NTP Server #4' must contain a valid IP address");
238
	}
239

    
240
	if ($pconfig['netbios_enable']) {
241
		if ($pconfig['wins_server_enable']) {
242
			if (!empty($pconfig['wins_server1']) && !is_ipaddr(trim($pconfig['wins_server1'])))
243
				$input_errors[] = gettext("The field 'WINS Server #1' must contain a valid IP address");
244
			if (!empty($pconfig['wins_server2']) && !is_ipaddr(trim($pconfig['wins_server2'])))
245
				$input_errors[] = gettext("The field 'WINS Server #2' must contain a valid IP address");
246
		}
247
		if ($pconfig['nbdd_server_enable'])
248
			if (!empty($pconfig['nbdd_server1']) && !is_ipaddr(trim($pconfig['nbdd_server1'])))
249
				$input_errors[] = gettext("The field 'NetBIOS Data Distribution Server #1' must contain a valid IP address");
250
	}
251

    
252
	if ($pconfig['maxclients'] && !is_numeric($pconfig['maxclients']))
253
		$input_errors[] = gettext("The field 'Concurrent connections' must be numeric.");
254

    
255
	/* If we are not in shared key mode, then we need the CA/Cert. */
256
	if ($pconfig['mode'] != "p2p_shared_key") {
257
		$reqdfields = explode(" ", "caref certref");
258
		$reqdfieldsn = array(gettext("Certificate Authority"),gettext("Certificate"));
259
	} elseif (!$pconfig['autokey_enable']) {
260
		/* We only need the shared key filled in if we are in shared key mode and autokey is not selected. */
261
		$reqdfields = array('shared_key');
262
		$reqdfieldsn = array(gettext('Shared key'));
263
	}
264

    
265
	$reqdfields[] = 'tunnel_network';
266
	$reqdfieldsn[] = gettext('Tunnel network');
267

    
268
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
269
	
270
	if (!$input_errors) {
271

    
272
		$server = array();
273

    
274
		if ($vpnid)
275
			$server['vpnid'] = $vpnid;
276
		else
277
			$server['vpnid'] = openvpn_vpnid_next();
278

    
279
		if ($_POST['disable'] == "yes")
280
			$server['disable'] = true;
281
		$server['mode'] = $pconfig['mode'];
282
		if (!empty($pconfig['authmode']))
283
			$server['authmode'] = implode(",", $pconfig['authmode']);
284
		$server['protocol'] = $pconfig['protocol'];
285
		list($server['interface'], $server['ipaddr']) = explode ("|",$pconfig['interface']);
286
		$server['local_port'] = $pconfig['local_port'];
287
		$server['description'] = $pconfig['description'];
288
		$server['custom_options'] = $pconfig['custom_options'];
289

    
290
		if ($tls_mode) {
291
			if ($pconfig['tlsauth_enable']) {
292
				if ($pconfig['autotls_enable'])
293
					$pconfig['tls'] = openvpn_create_key();
294
				$server['tls'] = base64_encode($pconfig['tls']);
295
			}
296
			$server['caref'] = $pconfig['caref'];
297
			$server['crlref'] = $pconfig['crlref'];
298
			$server['certref'] = $pconfig['certref'];
299
			$server['dh_length'] = $pconfig['dh_length'];
300
			if ($pconfig['mode'] == "server_tls_user")
301
				$server['strictusercn'] = $pconfig['strictusercn'];
302
		} else {
303
			$server['shared_key'] = base64_encode($pconfig['shared_key']);
304
		}
305
		$server['crypto'] = $pconfig['crypto'];
306

    
307
		$server['tunnel_network'] = $pconfig['tunnel_network'];
308
		$server['remote_network'] = $pconfig['remote_network'];
309
		$server['gwredir'] = $pconfig['gwredir'];
310
		$server['local_network'] = $pconfig['local_network'];
311
		$server['maxclients'] = $pconfig['maxclients'];
312
		$server['compression'] = $pconfig['compression'];
313
		$server['passtos'] = $pconfig['passtos'];
314
		$server['client2client'] = $pconfig['client2client'];
315

    
316
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
317
		$server['pool_enable'] = $pconfig['pool_enable'];
318

    
319
		if ($pconfig['dns_domain_enable'])
320
			$server['dns_domain'] = $pconfig['dns_domain'];
321

    
322
		if ($pconfig['dns_server_enable']) {
323
			$server['dns_server1'] = $pconfig['dns_server1'];
324
			$server['dns_server2'] = $pconfig['dns_server2'];
325
			$server['dns_server3'] = $pconfig['dns_server3'];
326
			$server['dns_server4'] = $pconfig['dns_server4'];
327
		}
328

    
329
		if ($pconfig['ntp_server_enable']) {
330
			$server['ntp_server1'] = $pconfig['ntp_server1'];
331
			$server['ntp_server2'] = $pconfig['ntp_server2'];
332
		}
333

    
334
		$server['netbios_enable'] = $pconfig['netbios_enable'];
335
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
336
		$server['netbios_scope'] = $pconfig['netbios_scope'];
337

    
338
		if ($pconfig['netbios_enable']) {
339

    
340
			if ($pconfig['wins_server_enable']) {
341
				$server['wins_server1'] = $pconfig['wins_server1'];
342
				$server['wins_server2'] = $pconfig['wins_server2'];
343
			}
344

    
345
			if ($pconfig['dns_server_enable'])
346
				$server['nbdd_server1'] = $pconfig['nbdd_server1'];
347
		}
348
	
349
		if (isset($id) && $a_server[$id])
350
			$a_server[$id] = $server;
351
		else
352
			$a_server[] = $server;
353

    
354
		openvpn_resync('server', $server);
355
		write_config();
356
		
357
		header("Location: vpn_openvpn_server.php");
358
		exit;
359
	}
360
	if (!empty($pconfig['authmode']))
361
		$pconfig['authmode'] = implode(",", $pconfig['authmode']);
362
}
363

    
364
include("head.inc");
365

    
366
?>
367

    
368
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
369
<?php include("fbegin.inc"); ?>
370
<script language="JavaScript">
371
<!--
372

    
373
function mode_change() {
374
	index = document.iform.mode.selectedIndex;
375
	value = document.iform.mode.options[index].value;
376
	switch(value) {
377
		case "p2p_tls":
378
		case "server_tls":
379
		case "server_user":
380
			document.getElementById("tls").style.display="";
381
			document.getElementById("tls_ca").style.display="";
382
			document.getElementById("tls_crl").style.display="";
383
			document.getElementById("tls_cert").style.display="";
384
			document.getElementById("tls_dh").style.display="";
385
			document.getElementById("strictusercn").style.display="none";
386
			document.getElementById("psk").style.display="none";
387
			break;
388
		case "server_tls_user":
389
			document.getElementById("tls").style.display="";
390
			document.getElementById("tls_ca").style.display="";
391
			document.getElementById("tls_crl").style.display="";
392
			document.getElementById("tls_cert").style.display="";
393
			document.getElementById("tls_dh").style.display="";
394
			document.getElementById("strictusercn").style.display="";
395
			document.getElementById("psk").style.display="none";
396
			break;
397
		case "p2p_shared_key":
398
			document.getElementById("tls").style.display="none";
399
			document.getElementById("tls_ca").style.display="none";
400
			document.getElementById("tls_crl").style.display="none";
401
			document.getElementById("tls_cert").style.display="none";
402
			document.getElementById("tls_dh").style.display="none";
403
			document.getElementById("strictusercn").style.display="none";
404
			document.getElementById("psk").style.display="";
405
			break;
406
	}
407
	switch(value) {
408
		case "p2p_shared_key":
409
			document.getElementById("client_opts").style.display="none";
410
			document.getElementById("remote_opts").style.display="";
411
			document.getElementById("local_opts").style.display="none";
412
			document.getElementById("authmodetr").style.display="none";
413
			document.getElementById("inter_client_communication").style.display="none";
414
			break;
415
		case "p2p_tls":
416
			document.getElementById("client_opts").style.display="none";
417
			document.getElementById("remote_opts").style.display="";
418
			document.getElementById("local_opts").style.display="";
419
			document.getElementById("authmodetr").style.display="none";
420
			document.getElementById("inter_client_communication").style.display="none";
421
			break;
422
		case "server_user":
423
                case "server_tls_user":
424
			document.getElementById("authmodetr").style.display="";
425
			document.getElementById("client_opts").style.display="";
426
			document.getElementById("remote_opts").style.display="none";
427
			document.getElementById("local_opts").style.display="";
428
			document.getElementById("inter_client_communication").style.display="";
429
			break;
430
		case "server_tls":
431
			document.getElementById("authmodetr").style.display="none";
432
		default:
433
			document.getElementById("client_opts").style.display="";
434
			document.getElementById("remote_opts").style.display="none";
435
			document.getElementById("local_opts").style.display="";
436
			document.getElementById("inter_client_communication").style.display="";
437
			break;
438
	}
439
}
440

    
441
function autokey_change() {
442

    
443
	if (document.iform.autokey_enable.checked)
444
		document.getElementById("autokey_opts").style.display="none";
445
	else
446
		document.getElementById("autokey_opts").style.display="";
447
}
448

    
449
function tlsauth_change() {
450

    
451
<?php if (!$pconfig['tls']): ?>
452
	if (document.iform.tlsauth_enable.checked)
453
		document.getElementById("tlsauth_opts").style.display="";
454
	else
455
		document.getElementById("tlsauth_opts").style.display="none";
456
<?php endif; ?>
457

    
458
	autotls_change();
459
}
460

    
461
function autotls_change() {
462

    
463
<?php if (!$pconfig['tls']): ?>
464
	autocheck = document.iform.autotls_enable.checked;
465
<?php else: ?>
466
	autocheck = false;
467
<?php endif; ?>
468

    
469
	if (document.iform.tlsauth_enable.checked && !autocheck)
470
		document.getElementById("autotls_opts").style.display="";
471
	else
472
		document.getElementById("autotls_opts").style.display="none";
473
}
474

    
475
function gwredir_change() {
476

    
477
	if (document.iform.gwredir.checked)
478
		document.getElementById("local_opts").style.display="none";
479
	else
480
		document.getElementById("local_opts").style.display="";
481
}
482

    
483
function dns_domain_change() {
484

    
485
	if (document.iform.dns_domain_enable.checked)
486
		document.getElementById("dns_domain_data").style.display="";
487
	else
488
		document.getElementById("dns_domain_data").style.display="none";
489
}
490

    
491
function dns_server_change() {
492

    
493
	if (document.iform.dns_server_enable.checked)
494
		document.getElementById("dns_server_data").style.display="";
495
	else
496
		document.getElementById("dns_server_data").style.display="none";
497
}
498

    
499
function wins_server_change() {
500

    
501
	if (document.iform.wins_server_enable.checked)
502
		document.getElementById("wins_server_data").style.display="";
503
	else
504
		document.getElementById("wins_server_data").style.display="none";
505
}
506

    
507
function ntp_server_change() {
508

    
509
	if (document.iform.ntp_server_enable.checked)
510
		document.getElementById("ntp_server_data").style.display="";
511
	else
512
		document.getElementById("ntp_server_data").style.display="none";
513
}
514

    
515
function netbios_change() {
516

    
517
	if (document.iform.netbios_enable.checked) {
518
		document.getElementById("netbios_data").style.display="";
519
		document.getElementById("wins_opts").style.display="";
520
	} else {
521
		document.getElementById("netbios_data").style.display="none";
522
		document.getElementById("wins_opts").style.display="none";
523
	}
524
}
525

    
526
//-->
527
</script>
528
<?php
529
	if ($input_errors)
530
		print_input_errors($input_errors);
531
	if ($savemsg)
532
		print_info_box($savemsg);
533
?>
534
<table width="100%" border="0" cellpadding="0" cellspacing="0">
535
	<tr>
536
		<td class="tabnavtbl">
537
			<ul id="tabnav">
538
			<?php 
539
				$tab_array = array();
540
				$tab_array[] = array(gettext("Server"), true, "vpn_openvpn_server.php");
541
				$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
542
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
543
				$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
544
				add_package_tabs("OpenVPN", $tab_array);
545
				display_top_tabs($tab_array);
546
			?>
547
			</ul>
548
		</td>
549
	</tr>    
550
	<tr>
551
		<td class="tabcont">
552

    
553
			<?php if($act=="new" || $act=="edit"): ?>
554

    
555
			<form action="vpn_openvpn_server.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
556
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
557
					<tr>
558
						<td colspan="2" valign="top" class="listtopic"><?=gettext("General information"); ?></td>
559
					</tr>
560
					<tr>
561
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td>
562
						<td width="78%" class="vtable">
563
							<table border="0" cellpadding="0" cellspacing="0">
564
								<tr>
565
									<td>
566
										<?php set_checked($pconfig['disable'],$chk); ?>
567
										<input name="disable" type="checkbox" value="yes" <?=$chk;?>/>
568
									</td>
569
									<td>
570
										&nbsp;
571
										<span class="vexpl">
572
											<strong><?=gettext("Disable this server"); ?></strong><br>
573
										</span>
574
									</td>
575
								</tr>
576
							</table>
577
							<?=gettext("Set this option to disable this server without removing it from the list"); ?>.
578
						</td>
579
					</tr>
580
					<tr>
581
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server Mode");?></td>
582
							<td width="78%" class="vtable">
583
							<select name='mode' id='mode' class="formselect" onchange='mode_change()'>
584
							<?php
585
								foreach ($openvpn_server_modes as $name => $desc):
586
									$selected = "";
587
									if ($pconfig['mode'] == $name)
588
										$selected = "selected";
589
							?>
590
								<option value="<?=$name;?>" <?=$selected;?>><?=$desc;?></option>
591
							<?php endforeach; ?>
592
							</select>
593
						</td>
594
					</tr>
595
					<tr id="authmodetr" style="display:none">
596
                                                <td width="22%" valign="top" class="vncellreq"><?=gettext("Backend for authentication");?></td>
597
                                                        <td width="78%" class="vtable">
598
                                                        <select name='authmode[]' id='authmode' class="formselect" multiple="true" size="<?php echo count($auth_servers); ?>">
599
							<?php $authmodes = explode(",", $pconfig['authmode']); ?>
600
                                                        <?php
601
								$auth_servers = auth_get_authserver_list();
602
                                                                foreach ($auth_servers as $auth_server):
603
                                                                        $selected = "";
604
                                                                        if (in_array($auth_server['name'], $authmodes))
605
                                                                                $selected = "selected";
606
                                                        ?>
607
                                                                <option value="<?=$auth_server['name'];?>" <?=$selected;?>><?=$auth_server['name'];?></option>
608
                                                        <?php 	endforeach; ?>
609
                                                        </select>
610
                                                </td>
611
                                        </tr>
612
					<tr>
613
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
614
							<td width="78%" class="vtable">
615
							<select name='protocol' class="formselect">
616
							<?php
617
								foreach ($openvpn_prots as $prot):
618
									$selected = "";
619
									if ($pconfig['protocol'] == $prot)
620
										$selected = "selected";
621
							?>
622
								<option value="<?=$prot;?>" <?=$selected;?>><?=$prot;?></option>
623
							<?php endforeach; ?>
624
							</select>
625
							</td>
626
					</tr>
627
					<tr>
628
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
629
						<td width="78%" class="vtable">
630
							<select name="interface" class="formselect">
631
								<?php
632
									$interfaces = get_configured_interface_with_descr();
633
									$carplist = get_configured_carp_interface_list();
634
									foreach ($carplist as $cif => $carpip)
635
										$interfaces[$cif.'|'.$carpip] = strtoupper($cif) . " ({$carpip})";
636
									$aliaslist = get_configured_ip_aliases_list();
637
									foreach ($aliaslist as $aliasip => $aliasif)
638
										$interfaces[$aliasif.'|'.$aliasip] = strtoupper($aliasif) . " ({$aliasip})";
639
									$interfaces['any'] = "any";
640
									foreach ($interfaces as $iface => $ifacename):
641
										$selected = "";
642
										if ($iface == $pconfig['interface'])
643
											$selected = "selected";
644
								?>
645
									<option value="<?=$iface;?>" <?=$selected;?>>
646
										<?=htmlspecialchars($ifacename);?>
647
									</option>
648
								<?php endforeach; ?>
649
							</select> <br>
650
						</td>
651
					</tr>
652
					<tr>
653
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Local port");?></td>
654
						<td width="78%" class="vtable">
655
							<input name="local_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['local_port']);?>"/>
656
						</td>
657
					</tr>
658
					<tr> 
659
						<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
660
						<td width="78%" class="vtable"> 
661
							<input name="description" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['description']);?>">
662
							<br>
663
							<?=gettext("You may enter a description here for your reference (not parsed)"); ?>.
664
						</td>
665
					</tr>
666
					<tr>
667
						<td colspan="2" class="list" height="12"></td>
668
					</tr>
669
					<tr>
670
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Cryptographic Settings"); ?></td>
671
					</tr>
672
					<tr id="tls">
673
						<td width="22%" valign="top" class="vncellreq"><?=gettext("TLS Authentication"); ?></td>
674
						<td width="78%" class="vtable">
675
							<table border="0" cellpadding="2" cellspacing="0">
676
								<tr>
677
									<td>
678
										<?php set_checked($pconfig['tlsauth_enable'],$chk); ?>
679
										<input name="tlsauth_enable" id="tlsauth_enable" type="checkbox" value="yes" <?=$chk;?> onClick="tlsauth_change()">
680
									</td>
681
									<td>
682
										<span class="vexpl">
683
											<?=gettext("Enable authentication of TLS packets"); ?>.
684
										</span>
685
									</td>
686
								</tr>
687
							</table>
688
							<?php if (!$pconfig['tls']): ?>
689
							<table border="0" cellpadding="2" cellspacing="0" id='tlsauth_opts'>
690
								<tr>
691
									<td>
692
										<?php set_checked($pconfig['autotls_enable'],$chk); ?>
693
										<input name="autotls_enable" id="autotls_enable" type="checkbox" value="yes" <?=$chk;?> onClick="autotls_change()">
694
									</td>
695
									<td>
696
										<span class="vexpl">
697
											<?=gettext("Automatically generate a shared TLS authentication key"); ?>.
698
										</span>
699
									</td>
700
								</tr>
701
							</table>
702
							<?php endif; ?>
703
							<table border="0" cellpadding="2" cellspacing="0" id='autotls_opts'>
704
								<tr>
705
									<td>
706
										<textarea name="tls" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['tls']);?></textarea>
707
										<br/>
708
										<?=gettext("Paste your shared key here"); ?>.
709
									</td>
710
								</tr>
711
							</table>
712
						</td>
713
					</tr>
714
					<tr id="tls_ca">
715
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer Certificate Authority"); ?></td>
716
							<td width="78%" class="vtable">
717
							<select name='caref' class="formselect">
718
							<?php
719
								foreach ($config['ca'] as $ca):
720
									$selected = "";
721
									if ($pconfig['caref'] == $ca['refid'])
722
										$selected = "selected";
723
							?>
724
								<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['descr'];?></option>
725
							<?php endforeach; ?>
726
							</select>
727
							</td>
728
					</tr>
729
					<tr id="tls_crl">
730
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer Certificate Revocation List"); ?></td>
731
							<td width="78%" class="vtable">
732
							<select name='crlref' class="formselect">
733
								<option value="">None</option>
734
							<?php
735
								foreach ($config['crl'] as $crl):
736
									if (is_crl_internal($crl) && (count($crl['cert']) <= 0))
737
										continue;
738
									$selected = "";
739
									if ($pconfig['crlref'] == $crl['refid'])
740
										$selected = "selected";
741
							?>
742
								<option value="<?=$crl['refid'];?>" <?=$selected;?>><?=$crl['descr'];?></option>
743
							<?php endforeach; ?>
744
							</select>
745
							</td>
746
					</tr>
747
					<tr id="tls_cert">
748
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server Certificate"); ?></td>
749
							<td width="78%" class="vtable">
750
							<select name='certref' class="formselect">
751
							<?php
752
								foreach ($config['cert'] as $cert):
753
									$selected = "";
754
									if (strstr($cert['descr'], "webConfigurator"))
755
										continue;
756
									if ($pconfig['certref'] == $cert['refid'])
757
										$selected = "selected";
758
							?>
759
								<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['descr'];?></option>
760
							<?php endforeach; ?>
761
							</select>
762
						</td>
763
					</tr>
764
					<tr id="tls_dh">
765
						<td width="22%" valign="top" class="vncellreq"><?=gettext("DH Parameters Length"); ?></td>
766
						<td width="78%" class="vtable">
767
							<select name="dh_length" class="formselect">
768
								<?php
769
									foreach ($openvpn_dh_lengths as $length):
770
									$selected = '';
771
									if ($length == $pconfig['dh_length'])
772
										$selected = ' selected';
773
								?>
774
								<option<?=$selected?>><?=$length;?></option>
775
								<?php endforeach; ?>
776
							</select>
777
							<span class="vexpl">
778
								<?=gettext("bits"); ?>
779
							</span>
780
						</td>
781
					</tr>
782
					<tr id="psk">
783
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Shared Key"); ?></td>
784
						<td width="78%" class="vtable">
785
							<?php if (!$pconfig['shared_key']): ?>
786
							<table border="0" cellpadding="2" cellspacing="0">
787
								<tr>
788
									<td>
789
										<?php set_checked($pconfig['autokey_enable'],$chk); ?>
790
										<input name="autokey_enable" type="checkbox" value="yes" <?=$chk;?> onClick="autokey_change()">
791
									</td>
792
									<td>
793
										<span class="vexpl">
794
											<?=gettext("Automatically generate a shared key"); ?>.
795
										</span>
796
									</td>
797
								</tr>
798
							</table>
799
							<?php endif; ?>
800
							<table border="0" cellpadding="2" cellspacing="0" id='autokey_opts'>
801
								<tr>
802
									<td>
803
										<textarea name="shared_key" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['shared_key']);?></textarea>
804
										<br/>
805
										<?=gettext("Paste your shared key here"); ?>.
806
									</td>
807
								</tr>
808
							</table>
809
						</td>
810
					</tr>
811
					<tr>
812
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Encryption algorithm"); ?></td>
813
						<td width="78%" class="vtable">
814
							<select name="crypto" class="formselect">
815
								<?php
816
									$cipherlist = openvpn_get_cipherlist();
817
									foreach ($cipherlist as $name => $desc):
818
									$selected = '';
819
									if ($name == $pconfig['crypto'])
820
										$selected = ' selected';
821
								?>
822
								<option value="<?=$name;?>"<?=$selected?>>
823
									<?=htmlspecialchars($desc);?>
824
								</option>
825
								<?php endforeach; ?>
826
							</select>
827
						</td>
828
					</tr>
829
					<tr id="strictusercn">
830
						<td width="22%" valign="top" class="vncell"><?=gettext("Strict User/CN Matching"); ?></td>
831
						<td width="78%" class="vtable">
832
							<table border="0" cellpadding="2" cellspacing="0">
833
								<tr>
834
									<td>
835
										<?php set_checked($pconfig['strictusercn'],$chk); ?>
836
										<input name="strictusercn" type="checkbox" value="yes" <?=$chk;?>/>
837
									</td>
838
									<td>
839
										<span class="vexpl">
840
											<?=gettext("When authenticating users, enforce a match between the common name of the client certificate and the username given at login."); ?>
841
										</span>
842
									</td>
843
								</tr>
844
							</table>
845
						</td>
846
					</tr>
847
					<tr>
848
						<td colspan="2" class="list" height="12"></td>
849
					</tr>
850
					<tr>
851
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Tunnel Settings"); ?></td>
852
					</tr>
853
					<tr>
854
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Tunnel Network"); ?></td>
855
						<td width="78%" class="vtable">
856
							<input name="tunnel_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_network']);?>">
857
							<br>
858
							<?=gettext("This is the virtual network used for private " .
859
							"communications between this server and client " .
860
							"hosts expressed using CIDR (eg. 10.0.8.0/24). " .
861
							"The first network address will be assigned to " .
862
							"the	server virtual interface. The remaining " .
863
							"network addresses can optionally be assigned " .
864
							"to connecting clients. (see Address Pool)"); ?>
865
						</td>
866
					</tr>
867
					<tr>
868
						<td width="22%" valign="top" class="vncell"><?=gettext("Redirect Gateway"); ?></td>
869
						<td width="78%" class="vtable">
870
							<table border="0" cellpadding="2" cellspacing="0">
871
								<tr>
872
									<td>
873
										<?php set_checked($pconfig['gwredir'],$chk); ?>
874
										<input name="gwredir" type="checkbox" value="yes" <?=$chk;?> onClick="gwredir_change()"/>
875
									</td>
876
									<td>
877
										<span class="vexpl">
878
											<?=gettext("Force all client generated traffic through the tunnel"); ?>.
879
										</span>
880
									</td>
881
								</tr>
882
							</table>
883
						</td>
884
					</tr>
885
					<tr id="local_opts">
886
						<td width="22%" valign="top" class="vncell"><?=gettext("Local Network"); ?></td>
887
						<td width="78%" class="vtable">
888
							<input name="local_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['local_network']);?>">
889
							<br>
890
							<?=gettext("This is the network that will be accessible " .
891
							"from the remote endpoint. Expressed as a CIDR " .
892
							"range. You may leave this blank if you don't " .
893
							"want to add a route to the local network " .
894
							"through this tunnel on the remote machine. " .
895
							"This is generally set to your LAN network"); ?>.
896
						</td>
897
					</tr>
898
					<tr id="remote_opts">
899
						<td width="22%" valign="top" class="vncell"><?=gettext("Remote Network"); ?></td>
900
						<td width="78%" class="vtable">
901
							<input name="remote_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['remote_network']);?>">
902
							<br>
903
							<?=gettext("This is a network that will be routed through " .
904
							"the tunnel, so that a site-to-site VPN can be " .
905
							"established without manually changing the " .
906
							"routing tables. Expressed as a CIDR range. If " .
907
							"this is a site-to-site VPN, enter here the " .
908
							"remote LAN here. You may leave this blank if " .
909
							"you don't want a site-to-site VPN"); ?>.
910
						</td>
911
					</tr>
912
					<tr>
913
						<td width="22%" valign="top" class="vncell"><?=gettext("Concurrent connections");?></td>
914
						<td width="78%" class="vtable">
915
							<input name="maxclients" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['maxclients']);?>"/>
916
							<br/>
917
							<?=gettext("Specify the maximum number of clients allowed to concurrently connect to this server"); ?>.
918
						</td>
919
					</tr>
920
					<tr>
921
						<td width="22%" valign="top" class="vncell"><?=gettext("Compression"); ?></td>
922
						<td width="78%" class="vtable">
923
							<table border="0" cellpadding="2" cellspacing="0">
924
								<tr>
925
									<td>
926
										<?php set_checked($pconfig['compression'],$chk); ?>
927
										<input name="compression" type="checkbox" value="yes" <?=$chk;?>>
928
									</td>
929
									<td>
930
										<span class="vexpl">
931
											<?=gettext("Compress tunnel packets using the LZO algorithm"); ?>.
932
										</span>
933
									</td>
934
								</tr>
935
							</table>
936
						</td>
937
					</tr>
938
					<tr>
939
						<td width="22%" valign="top" class="vncell"><?=gettext("Type-of-Service"); ?></td>
940
						<td width="78%" class="vtable">
941
							<table border="0" cellpadding="2" cellspacing="0">
942
								<tr>
943
									<td>
944
										<?php set_checked($pconfig['passtos'],$chk); ?>
945
										<input name="passtos" type="checkbox" value="yes" <?=$chk;?>>
946
									</td>
947
									<td>
948
										<span class="vexpl">
949
											<?=gettext("Set the TOS IP header value of tunnel packets to match the encapsulated packet value"); ?>.
950
										</span>
951
									</td>
952
								</tr>
953
							</table>
954
						</td>
955
					</tr>
956
					<tr id="inter_client_communication">
957
						<td width="22%" valign="top" class="vncell"><?=gettext("Inter-client communication"); ?></td>
958
						<td width="78%" class="vtable">
959
							<table border="0" cellpadding="2" cellspacing="0">
960
								<tr>
961
									<td>
962
										<?php set_checked($pconfig['client2client'],$chk); ?>
963
										<input name="client2client" type="checkbox" value="yes" <?=$chk;?>/>
964
									</td>
965
									<td>
966
										<span class="vexpl">
967
											<?=gettext("Allow communication between clients connected to this server"); ?>
968
										</span>
969
									</td>
970
								</tr>
971
							</table>
972
						</td>
973
					</tr>
974
				</table>
975

    
976
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
977
					<tr>
978
						<td colspan="2" class="list" height="12"></td>
979
					</tr>
980
					<tr>
981
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Client Settings"); ?></td>
982
					</tr>
983
					<tr>
984
						<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic IP"); ?></td>
985
						<td width="78%" class="vtable">
986
							<table border="0" cellpadding="2" cellspacing="0">
987
								<tr>
988
									<td>
989
										<?php set_checked($pconfig['dynamic_ip'],$chk); ?>
990
										<input name="dynamic_ip" type="checkbox" id="dynamic_ip" value="yes" <?=$chk;?>/>
991
									</td>
992
									<td>
993
										<span class="vexpl">
994
											<?=gettext("Allow connected clients to retain their connections if their IP address changes"); ?>.<br>
995
										</span>
996
									</td>
997
								</tr>
998
							</table>
999
						</td>
1000
					</tr>
1001
					<tr>
1002
						<td width="22%" valign="top" class="vncell"><?=gettext("Address Pool"); ?></td>
1003
						<td width="78%" class="vtable">
1004
							<table border="0" cellpadding="2" cellspacing="0">
1005
								<tr>
1006
									<td>
1007
										<?php set_checked($pconfig['pool_enable'],$chk); ?>
1008
										<input name="pool_enable" type="checkbox" id="pool_enable" value="yes" <?=$chk;?>/>
1009
									</td>
1010
									<td>
1011
										<span class="vexpl">
1012
											<?=gettext("Provide a virtual adapter IP address to clients (see Tunnel Network)"); ?><br>
1013
										</span>
1014
									</td>
1015
								</tr>
1016
							</table>
1017
						</td>
1018
					</tr>
1019
					<tr>
1020
						<td width="22%" valign="top" class="vncell"><?=gettext("DNS Default Domain"); ?></td>
1021
						<td width="78%" class="vtable">
1022
							<table border="0" cellpadding="2" cellspacing="0">
1023
								<tr>
1024
									<td>
1025
										<?php set_checked($pconfig['dns_domain_enable'],$chk); ?>
1026
										<input name="dns_domain_enable" type="checkbox" id="dns_domain_enable" value="yes" <?=$chk;?> onClick="dns_domain_change()">
1027
									</td>
1028
									<td>
1029
										<span class="vexpl">
1030
	                                        <?=gettext("Provide a default domain name to clients"); ?><br>
1031
										</span>
1032
									</td>
1033
								</tr>
1034
							</table>
1035
							<table border="0" cellpadding="2" cellspacing="0" id="dns_domain_data">
1036
								<tr>
1037
									<td>
1038
										<input name="dns_domain" type="text" class="formfld unknown" id="dns_domain" size="30" value="<?=htmlspecialchars($pconfig['dns_domain']);?>">
1039
									</td>
1040
								</tr>
1041
							</table>
1042
						</td>
1043
					</tr>
1044
					<tr>
1045
						<td width="22%" valign="top" class="vncell"><?=gettext("DNS Servers"); ?></td>
1046
						<td width="78%" class="vtable">
1047
							<table border="0" cellpadding="2" cellspacing="0">
1048
								<tr>
1049
									<td>
1050
										<?php set_checked($pconfig['dns_server_enable'],$chk); ?>
1051
										<input name="dns_server_enable" type="checkbox" id="dns_server_enable" value="yes" <?=$chk;?> onClick="dns_server_change()">
1052
									</td>
1053
									<td>
1054
										<span class="vexpl">
1055
											<?=gettext("Provide a DNS server list to clients"); ?><br>
1056
										</span>
1057
									</td>
1058
								</tr>
1059
							</table>
1060
							<table border="0" cellpadding="2" cellspacing="0" id="dns_server_data">
1061
								<tr>
1062
									<td>
1063
										<span class="vexpl">
1064
											<?=gettext("Server"); ?> #1:&nbsp;
1065
										</span>
1066
										<input name="dns_server1" type="text" class="formfld unknown" id="dns_server1" size="20" value="<?=$pconfig['dns_server1'];?>">
1067
									</td>
1068
								</tr>
1069
								<tr>
1070
									<td>
1071
										<span class="vexpl">
1072
											<?=gettext("Server"); ?> #2:&nbsp;
1073
										</span>
1074
										<input name="dns_server2" type="text" class="formfld unknown" id="dns_server2" size="20" value="<?=$pconfig['dns_server2'];?>">
1075
									</td>
1076
								</tr>
1077
								<tr>
1078
									<td>
1079
										<span class="vexpl">
1080
											<?=gettext("Server"); ?> #3:&nbsp;
1081
										</span>
1082
										<input name="dns_server3" type="text" class="formfld unknown" id="dns_server3" size="20" value="<?=$pconfig['dns_server3'];?>">
1083
									</td>
1084
								</tr>
1085
								<tr>
1086
									<td>
1087
										<span class="vexpl">
1088
											<?=gettext("Server"); ?> #4:&nbsp;
1089
										</span>
1090
										<input name="dns_server4" type="text" class="formfld unknown" id="dns_server4" size="20" value="<?=$pconfig['dns_server4'];?>">
1091
									</td>
1092
								</tr>
1093
							</table>
1094
						</td>
1095
					</tr>
1096
					<tr>
1097
						<td width="22%" valign="top" class="vncell"><?=gettext("NTP Servers"); ?></td>
1098
						<td width="78%" class="vtable">
1099
							<table border="0" cellpadding="2" cellspacing="0">
1100
								<tr>
1101
									<td>
1102
										<?php set_checked($pconfig['ntp_server_enable'],$chk); ?>
1103
										<input name="ntp_server_enable" type="checkbox" id="ntp_server_enable" value="yes" <?=$chk;?> onClick="ntp_server_change()">
1104
									</td>
1105
									<td>
1106
										<span class="vexpl">
1107
											<?=gettext("Provide a NTP server list to clients"); ?><br>
1108
										</span>
1109
									</td>
1110
								</tr>
1111
							</table>
1112
							<table border="0" cellpadding="2" cellspacing="0" id="ntp_server_data">
1113
								<tr>
1114
									<td>
1115
										<span class="vexpl">
1116
											<?=gettext("Server"); ?> #1:&nbsp;
1117
										</span>
1118
										<input name="ntp_server1" type="text" class="formfld unknown" id="ntp_server1" size="20" value="<?=$pconfig['ntp_server1'];?>">
1119
									</td>
1120
								</tr>
1121
								<tr>
1122
									<td>
1123
										<span class="vexpl">
1124
											<?=gettext("Server"); ?> #2:&nbsp;
1125
										</span>
1126
										<input name="ntp_server2" type="text" class="formfld unknown" id="ntp_server2" size="20" value="<?=$pconfig['ntp_server2'];?>">
1127
									</td>
1128
								</tr>
1129
							</table>
1130
						</td>
1131
					</tr>
1132
					<tr>
1133
						<td width="22%" valign="top" class="vncell"><?=gettext("NetBIOS Options"); ?></td>
1134
						<td width="78%" class="vtable">
1135
							<table border="0" cellpadding="2" cellspacing="0">
1136
								<tr>
1137
									<td>
1138
										<?php set_checked($pconfig['netbios_enable'],$chk); ?>
1139
										<input name="netbios_enable" type="checkbox" id="netbios_enable" value="yes" <?=$chk;?> onClick="netbios_change()">
1140
									</td>
1141
									<td>
1142
										<span class="vexpl">
1143
											<?=gettext("Enable NetBIOS over TCP/IP"); ?><br>
1144
										</span>
1145
									</td>
1146
								</tr>
1147
							</table>
1148
							<?=gettext("If this option is not set, all NetBIOS-over-TCP/IP options (including WINS) will be disabled"); ?>.
1149
							<br/>
1150
							<table border="0" cellpadding="2" cellspacing="0" id="netbios_data">
1151
								<tr>
1152
									<td>
1153
										<br/>
1154
										<span class="vexpl">
1155
											<?=gettext("Node Type"); ?>:&nbsp;
1156
										</span>
1157
										<select name='netbios_ntype' class="formselect">
1158
										<?php
1159
											foreach ($netbios_nodetypes as $type => $name):
1160
												$selected = "";
1161
												if ($pconfig['netbios_ntype'] == $type)
1162
													$selected = "selected";
1163
										?>
1164
											<option value="<?=$type;?>" <?=$selected;?>><?=$name;?></option>
1165
										<?php endforeach; ?>
1166
										</select>
1167
										<br/>
1168
										<?=gettext("Possible options: b-node (broadcasts), p-node " .
1169
										"(point-to-point name queries to a WINS server), " .
1170
										"m-node (broadcast then query name server), and " .
1171
										"h-node (query name server, then broadcast)"); ?>.
1172
									</td>
1173
								</tr>
1174
								<tr>
1175
									<td>
1176
										<br/>
1177
										<span class="vexpl">
1178
											<?=gettext("Scope ID"); ?>:&nbsp;
1179
										</span>
1180
										<input name="netbios_scope" type="text" class="formfld unknown" id="netbios_scope" size="30" value="<?=htmlspecialchars($pconfig['netbios_scope']);?>">
1181
										<br/>
1182
										<?=gettext("A NetBIOS Scope	ID provides an extended naming " .
1183
										"service for	NetBIOS over TCP/IP. The NetBIOS " .
1184
										"scope ID isolates NetBIOS traffic on a single " .
1185
										"network to only those nodes with the same " .
1186
										"NetBIOS scope ID"); ?>.
1187
									</td>
1188
								</tr>
1189
							</table>
1190
						</td>
1191
					</tr>
1192
					<tr id="wins_opts">
1193
						<td width="22%" valign="top" class="vncell"><?=gettext("WINS Servers"); ?></td>
1194
						<td width="78%" class="vtable">
1195
							<table border="0" cellpadding="2" cellspacing="0">
1196
								<tr>
1197
									<td>
1198
										<?php set_checked($pconfig['wins_server_enable'],$chk); ?>
1199
										<input name="wins_server_enable" type="checkbox" id="wins_server_enable" value="yes" <?=$chk;?> onClick="wins_server_change()">
1200
									</td>
1201
									<td>
1202
										<span class="vexpl">
1203
											<?=gettext("Provide a WINS server list to clients"); ?><br>
1204
										</span>
1205
									</td>
1206
								</tr>
1207
							</table>
1208
							<table border="0" cellpadding="2" cellspacing="0" id="wins_server_data">
1209
								<tr>
1210
									<td>
1211
										<span class="vexpl">
1212
											<?=gettext("Server"); ?> #1:&nbsp;
1213
										</span>
1214
										<input name="wins_server1" type="text" class="formfld unknown" id="wins_server1" size="20" value="<?=$pconfig['wins_server1'];?>">
1215
									</td>
1216
								</tr>
1217
								<tr>
1218
									<td>
1219
										<span class="vexpl">
1220
											<?=gettext("Server"); ?> #2:&nbsp;
1221
										</span>
1222
										<input name="wins_server2" type="text" class="formfld unknown" id="wins_server2" size="20" value="<?=$pconfig['wins_server2'];?>">
1223
									</td>
1224
								</tr>
1225
							</table>
1226
						</td>
1227
					</tr>
1228
				</table>
1229

    
1230
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1231
					<tr>
1232
						<td colspan="2" class="list" height="12"></td>
1233
					</tr>
1234
					<tr>
1235
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
1236
					</tr>
1237
					<tr>
1238
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1239
						<td width="78%" class="vtable">
1240
							<table border="0" cellpadding="2" cellspacing="0">
1241
								<tr>
1242
									<td>
1243
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=$pconfig['custom_options'];?></textarea><br/>
1244
										<?=gettext("Enter any additional options you would like to add to the OpenVPN server configuration here, separated by a semicolon"); ?><br/>
1245
										<?=gettext("EXAMPLE: push \"route 10.0.0.0 255.255.255.0\""); ?>;
1246
									</td>
1247
								</tr>
1248
							</table>
1249
						</td>
1250
					</tr>
1251
				</table>
1252

    
1253
				<br/>
1254

    
1255
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1256
					<tr>
1257
						<td width="22%" valign="top">&nbsp;</td>
1258
						<td width="78%"> 
1259
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>"> 
1260
							<input name="act" type="hidden" value="<?=$act;?>">
1261
							<?php if (isset($id) && $a_server[$id]): ?>
1262
							<input name="id" type="hidden" value="<?=$id;?>">
1263
							<?php endif; ?>
1264
						</td>
1265
					</tr>
1266
				</table>
1267
			</form>
1268

    
1269
			<?php else: ?>
1270

    
1271
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
1272
				<thead>
1273
				<tr>
1274
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
1275
					<td width="10%" class="listhdrr"><?=gettext("Protocol / Port"); ?></td>
1276
					<td width="30%" class="listhdrr"><?=gettext("Tunnel Network"); ?></td>
1277
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
1278
					<td width="10%" class="list"></td>
1279
				</tr>
1280
				</thead>
1281
				<tbody>
1282
				<?php
1283
					$i = 0;
1284
					foreach($a_server as $server):
1285
						$disabled = "NO";
1286
						if (isset($server['disable']))
1287
							$disabled = "YES";
1288
				?>
1289
				<tr>
1290
					<td class="listlr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1291
						<?=$disabled;?>
1292
					</td>
1293
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1294
						<?=htmlspecialchars($server['protocol']);?> / <?=htmlspecialchars($server['local_port']);?>
1295
					</td>
1296
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1297
						<?=htmlspecialchars($server['tunnel_network']);?>
1298
					</td>
1299
					<td class="listbg" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1300
						<?=htmlspecialchars($server['description']);?>
1301
					</td>
1302
					<td valign="middle" nowrap class="list">
1303
						<a href="vpn_openvpn_server.php?act=edit&id=<?=$i;?>">
1304
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit server"); ?>" width="17" height="17" border="0">
1305
						</a>
1306
						&nbsp;
1307
						<a href="vpn_openvpn_server.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this server?"); ?>')">
1308
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete server"); ?>" width="17" height="17" border="0">
1309
						</a>
1310
					</td>
1311
				</tr>
1312
				<?php
1313
					$i++;
1314
					endforeach;
1315
				?>
1316
				</tbody>
1317
				<tfoot>
1318
				<tr>
1319
					<td class="list" colspan="4"></td>
1320
					<td class="list">
1321
						<a href="vpn_openvpn_server.php?act=new"><img src="./themes/<?=$g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add server"); ?>" width="17" height="17" border="0">
1322
						</a>
1323
					</td>
1324
				</tr>
1325
				</tfoot>
1326
			</table>
1327

    
1328
			<?=gettext("Additional OpenVPN servers can be added here.");?>
1329

    
1330
			<?php endif; ?>
1331

    
1332
		</td>
1333
	</tr>
1334
</table>
1335
<script language="JavaScript">
1336
<!--
1337
mode_change();
1338
autokey_change();
1339
tlsauth_change();
1340
gwredir_change();
1341
dns_domain_change();
1342
dns_server_change();
1343
wins_server_change();
1344
ntp_server_change();
1345
netbios_change();
1346
//-->
1347
</script>
1348
</body>
1349
<?php include("fend.inc"); ?>
1350

    
1351
<?php
1352

    
1353
/* local utility functions */
1354

    
1355
function set_checked($var,& $chk) {
1356
    if($var)
1357
        $chk = 'checked';
1358
    else
1359
        $chk = '';
1360
}
1361

    
1362
?>
(213-213/220)