Project

General

Profile

Download (50.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
if (!is_array($config['ca']))
50
	$config['ca'] = array();
51

    
52
$a_ca =& $config['ca'];
53

    
54
if (!is_array($config['cert']))
55
	$config['cert'] = array();
56

    
57
$a_cert =& $config['cert'];
58

    
59
if (!is_array($config['crl']))
60
	$config['crl'] = array();
61

    
62
$a_crl =& $config['crl'];
63

    
64
foreach ($a_crl as $cid => $acrl)
65
	if (!isset($acrl['refid']))
66
		unset ($a_crl[$cid]);
67

    
68
$id = $_GET['id'];
69
if (isset($_POST['id']))
70
	$id = $_POST['id'];
71

    
72
$act = $_GET['act'];
73
if (isset($_POST['act']))
74
	$act = $_POST['act'];
75

    
76
if ($_GET['act'] == "del") {
77

    
78
	if (!$a_server[$id]) {
79
		pfSenseHeader("vpn_openvpn_server.php");
80
		exit;
81
	}
82

    
83
	openvpn_delete('server', $a_server[$id]);
84
	unset($a_server[$id]);
85
	write_config();
86
	$savemsg = gettext("Server successfully deleted")."<br/>";
87
}
88

    
89
if($_GET['act']=="new"){
90
	$pconfig['autokey_enable'] = "yes";
91
	$pconfig['tlsauth_enable'] = "yes";
92
	$pconfig['autotls_enable'] = "yes";
93
	$pconfig['dh_length'] = 1024;
94
	$pconfig['interface'] = "wan";
95
	$pconfig['local_port'] = openvpn_port_next('UDP');
96
	$pconfig['pool_enable'] = "yes";
97
}
98

    
99
if($_GET['act']=="edit"){
100

    
101
	if (isset($id) && $a_server[$id]) {
102

    
103
		$pconfig['disable'] = isset($a_server[$id]['disable']);
104
		$pconfig['mode'] = $a_server[$id]['mode'];
105
		$pconfig['protocol'] = $a_server[$id]['protocol'];
106
		$pconfig['authmode'] = $a_server[$id]['authmode'];
107
		$pconfig['interface'] = $a_server[$id]['interface'];
108
		if (!empty($a_server[$id]['ipaddr'])) {
109
			$pconfig['interface'] = $pconfig['interface'] . '|' . $a_server[$id]['ipaddr'];
110
		}
111
		$pconfig['local_port'] = $a_server[$id]['local_port'];
112
		$pconfig['description'] = $a_server[$id]['description'];
113
		$pconfig['custom_options'] = $a_server[$id]['custom_options'];
114

    
115
		if ($pconfig['mode'] != "p2p_shared_key") {
116
			if ($a_server[$id]['tls']) {
117
				$pconfig['tlsauth_enable'] = "yes";
118
				$pconfig['tls'] = base64_decode($a_server[$id]['tls']);
119
			}
120
			$pconfig['caref'] = $a_server[$id]['caref'];
121
			$pconfig['crlref'] = $a_server[$id]['crlref'];
122
			$pconfig['certref'] = $a_server[$id]['certref'];
123
			$pconfig['dh_length'] = $a_server[$id]['dh_length'];
124
			if ($pconfig['mode'] == "server_tls_user")
125
				$pconfig['strictusercn'] = $a_server[$id]['strictusercn'];
126
		} else
127
			$pconfig['shared_key'] = base64_decode($a_server[$id]['shared_key']);
128
		$pconfig['crypto'] = $a_server[$id]['crypto'];
129

    
130
		$pconfig['tunnel_network'] = $a_server[$id]['tunnel_network'];
131
		$pconfig['remote_network'] = $a_server[$id]['remote_network'];
132
		$pconfig['gwredir'] = $a_server[$id]['gwredir'];
133
		$pconfig['local_network'] = $a_server[$id]['local_network'];
134
		$pconfig['maxclients'] = $a_server[$id]['maxclients'];
135
		$pconfig['compression'] = $a_server[$id]['compression'];
136
		$pconfig['passtos'] = $a_server[$id]['passtos'];
137
		$pconfig['client2client'] = $a_server[$id]['client2client'];
138

    
139
		$pconfig['dynamic_ip'] = $a_server[$id]['dynamic_ip'];
140
		$pconfig['pool_enable'] = $a_server[$id]['pool_enable'];
141

    
142
		$pconfig['dns_domain'] = $a_server[$id]['dns_domain'];
143
		if ($pconfig['dns_domain'])
144
			$pconfig['dns_domain_enable'] = true;
145

    
146
		$pconfig['dns_server1'] = $a_server[$id]['dns_server1'];
147
		$pconfig['dns_server2'] = $a_server[$id]['dns_server2'];
148
		$pconfig['dns_server3'] = $a_server[$id]['dns_server3'];
149
		$pconfig['dns_server4'] = $a_server[$id]['dns_server4'];
150
		if ($pconfig['dns_server1'] ||
151
			$pconfig['dns_server2'] ||
152
			$pconfig['dns_server3'] ||
153
			$pconfig['dns_server4'])
154
			$pconfig['dns_server_enable'] = true;
155

    
156
		$pconfig['ntp_server1'] = $a_server[$id]['ntp_server1'];
157
		$pconfig['ntp_server2'] = $a_server[$id]['ntp_server2'];
158
		if ($pconfig['ntp_server1'] ||
159
			$pconfig['ntp_server2'])
160
			$pconfig['ntp_server_enable'] = true;
161

    
162
		$pconfig['netbios_enable'] = $a_server[$id]['netbios_enable'];
163
		$pconfig['netbios_ntype'] = $a_server[$id]['netbios_ntype'];
164
		$pconfig['netbios_scope'] = $a_server[$id]['netbios_scope'];
165

    
166
		$pconfig['wins_server1'] = $a_server[$id]['wins_server1'];
167
		$pconfig['wins_server2'] = $a_server[$id]['wins_server2'];
168
		if ($pconfig['wins_server1'] ||
169
			$pconfig['wins_server2'])
170
			$pconfig['wins_server_enable'] = true;
171

    
172
		$pconfig['nbdd_server1'] = $a_server[$id]['nbdd_server1'];
173
		if ($pconfig['nbdd_server1'])
174
			$pconfig['nbdd_server_enable'] = true;
175

    
176
		// just in case the modes switch
177
		$pconfig['autokey_enable'] = "yes";
178
		$pconfig['autotls_enable'] = "yes";
179
	}
180
}
181

    
182
if ($_POST) {
183

    
184
	unset($input_errors);
185
	$pconfig = $_POST;
186

    
187
	if (isset($id) && $a_server[$id])
188
		$vpnid = $a_server[$id]['vpnid'];
189
	else
190
		$vpnid = 0;
191

    
192
	if ($pconfig['mode'] != "p2p_shared_key")
193
		$tls_mode = true;
194
	else
195
		$tls_mode = false;
196

    
197
	if (!empty($pconfig['authmode'])) {
198
		foreach ($pconfig['authmode'] as $pauthmode) {
199
			if ($pauthmode != "Local Database" && $pconfig['mode'] == "server_tls_user") 
200
				$input_errors[] = gettext("Only 'Local authentication database'  is allowed with") . " " . $openvpn_server_modes[$pconfig['mode']];
201
		}
202
	}
203

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

    
207
	/* input validation */
208
	if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
209
		$input_errors[] = $result;
210

    
211
	if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'Tunnel network'))
212
		$input_errors[] = $result;
213

    
214
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'Remote network'))
215
		$input_errors[] = $result;
216

    
217
	if ($result = openvpn_validate_cidr($pconfig['local_network'], 'Local network'))
218
		$input_errors[] = $result;
219

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

    
224
	if ($pconfig['autokey_enable'])
225
		$pconfig['shared_key'] = openvpn_create_key();
226

    
227
	if (!$tls_mode && !$pconfig['autokey_enable'])
228
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
229
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
230
			$input_errors[] = gettext("The field 'Shared Key' does not appear to be valid");
231

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

    
237
	if ($pconfig['dns_server_enable']) {
238
		if (!empty($pconfig['dns_server1']) && !is_ipaddr(trim($pconfig['dns_server1'])))
239
			$input_errors[] = gettext("The field 'DNS Server #1' must contain a valid IP address");
240
		if (!empty($pconfig['dns_server2']) && !is_ipaddr(trim($pconfig['dns_server2'])))
241
			$input_errors[] = gettext("The field 'DNS Server #2' must contain a valid IP address");
242
		if (!empty($pconfig['dns_server3']) && !is_ipaddr(trim($pconfig['dns_server3'])))
243
			$input_errors[] = gettext("The field 'DNS Server #3' must contain a valid IP address");
244
		if (!empty($pconfig['dns_server4']) && !is_ipaddr(trim($pconfig['dns_server4'])))
245
			$input_errors[] = gettext("The field 'DNS Server #4' must contain a valid IP address");
246
	}
247

    
248
	if ($pconfig['ntp_server_enable']) {
249
		if (!empty($pconfig['ntp_server1']) && !is_ipaddr(trim($pconfig['ntp_server1'])))
250
			$input_errors[] = gettext("The field 'NTP Server #1' must contain a valid IP address");
251
		if (!empty($pconfig['ntp_server2']) && !is_ipaddr(trim($pconfig['ntp_server2'])))
252
			$input_errors[] = gettext("The field 'NTP Server #2' must contain a valid IP address");
253
		if (!empty($pconfig['ntp_server3']) && !is_ipaddr(trim($pconfig['ntp_server3'])))
254
			$input_errors[] = gettext("The field 'NTP Server #3' must contain a valid IP address");
255
		if (!empty($pconfig['ntp_server4']) && !is_ipaddr(trim($pconfig['ntp_server4'])))
256
			$input_errors[] = gettext("The field 'NTP Server #4' must contain a valid IP address");
257
	}
258

    
259
	if ($pconfig['netbios_enable']) {
260
		if ($pconfig['wins_server_enable']) {
261
			if (!empty($pconfig['wins_server1']) && !is_ipaddr(trim($pconfig['wins_server1'])))
262
				$input_errors[] = gettext("The field 'WINS Server #1' must contain a valid IP address");
263
			if (!empty($pconfig['wins_server2']) && !is_ipaddr(trim($pconfig['wins_server2'])))
264
				$input_errors[] = gettext("The field 'WINS Server #2' must contain a valid IP address");
265
		}
266
		if ($pconfig['nbdd_server_enable'])
267
			if (!empty($pconfig['nbdd_server1']) && !is_ipaddr(trim($pconfig['nbdd_server1'])))
268
				$input_errors[] = gettext("The field 'NetBIOS Data Distribution Server #1' must contain a valid IP address");
269
	}
270

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

    
274
	/* If we are not in shared key mode, then we need the CA/Cert. */
275
	if ($pconfig['mode'] != "p2p_shared_key") {
276
		$reqdfields = explode(" ", "caref certref");
277
		$reqdfieldsn = array(gettext("Certificate Authority"),gettext("Certificate"));
278
	} elseif (!$pconfig['autokey_enable']) {
279
		/* We only need the shared key filled in if we are in shared key mode and autokey is not selected. */
280
		$reqdfields = array('shared_key');
281
		$reqdfieldsn = array(gettext('Shared key'));
282
	}
283

    
284
	$reqdfields[] = 'tunnel_network';
285
	$reqdfieldsn[] = gettext('Tunnel network');
286

    
287
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
288
	
289
	if (!$input_errors) {
290

    
291
		$server = array();
292

    
293
		if ($vpnid)
294
			$server['vpnid'] = $vpnid;
295
		else
296
			$server['vpnid'] = openvpn_vpnid_next();
297

    
298
		if ($_POST['disable'] == "yes")
299
			$server['disable'] = true;
300
		$server['mode'] = $pconfig['mode'];
301
		if (!empty($pconfig['authmode']))
302
			$server['authmode'] = implode(",", $pconfig['authmode']);
303
		$server['protocol'] = $pconfig['protocol'];
304
		list($server['interface'], $server['ipaddr']) = explode ("|",$pconfig['interface']);
305
		$server['local_port'] = $pconfig['local_port'];
306
		$server['description'] = $pconfig['description'];
307
		$server['custom_options'] = str_replace("\r\n", "\n", $pconfig['custom_options']);
308

    
309
		if ($tls_mode) {
310
			if ($pconfig['tlsauth_enable']) {
311
				if ($pconfig['autotls_enable'])
312
					$pconfig['tls'] = openvpn_create_key();
313
				$server['tls'] = base64_encode($pconfig['tls']);
314
			}
315
			$server['caref'] = $pconfig['caref'];
316
			$server['crlref'] = $pconfig['crlref'];
317
			$server['certref'] = $pconfig['certref'];
318
			$server['dh_length'] = $pconfig['dh_length'];
319
			if ($pconfig['mode'] == "server_tls_user")
320
				$server['strictusercn'] = $pconfig['strictusercn'];
321
		} else {
322
			$server['shared_key'] = base64_encode($pconfig['shared_key']);
323
		}
324
		$server['crypto'] = $pconfig['crypto'];
325

    
326
		$server['tunnel_network'] = $pconfig['tunnel_network'];
327
		$server['remote_network'] = $pconfig['remote_network'];
328
		$server['gwredir'] = $pconfig['gwredir'];
329
		$server['local_network'] = $pconfig['local_network'];
330
		$server['maxclients'] = $pconfig['maxclients'];
331
		$server['compression'] = $pconfig['compression'];
332
		$server['passtos'] = $pconfig['passtos'];
333
		$server['client2client'] = $pconfig['client2client'];
334

    
335
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
336
		$server['pool_enable'] = $pconfig['pool_enable'];
337

    
338
		if ($pconfig['dns_domain_enable'])
339
			$server['dns_domain'] = $pconfig['dns_domain'];
340

    
341
		if ($pconfig['dns_server_enable']) {
342
			$server['dns_server1'] = $pconfig['dns_server1'];
343
			$server['dns_server2'] = $pconfig['dns_server2'];
344
			$server['dns_server3'] = $pconfig['dns_server3'];
345
			$server['dns_server4'] = $pconfig['dns_server4'];
346
		}
347

    
348
		if ($pconfig['ntp_server_enable']) {
349
			$server['ntp_server1'] = $pconfig['ntp_server1'];
350
			$server['ntp_server2'] = $pconfig['ntp_server2'];
351
		}
352

    
353
		$server['netbios_enable'] = $pconfig['netbios_enable'];
354
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
355
		$server['netbios_scope'] = $pconfig['netbios_scope'];
356

    
357
		if ($pconfig['netbios_enable']) {
358

    
359
			if ($pconfig['wins_server_enable']) {
360
				$server['wins_server1'] = $pconfig['wins_server1'];
361
				$server['wins_server2'] = $pconfig['wins_server2'];
362
			}
363

    
364
			if ($pconfig['dns_server_enable'])
365
				$server['nbdd_server1'] = $pconfig['nbdd_server1'];
366
		}
367
	
368
		if (isset($id) && $a_server[$id])
369
			$a_server[$id] = $server;
370
		else
371
			$a_server[] = $server;
372

    
373
		openvpn_resync('server', $server);
374
		write_config();
375
		
376
		header("Location: vpn_openvpn_server.php");
377
		exit;
378
	}
379
	if (!empty($pconfig['authmode']))
380
		$pconfig['authmode'] = implode(",", $pconfig['authmode']);
381
}
382

    
383
include("head.inc");
384

    
385
?>
386

    
387
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
388
<?php include("fbegin.inc"); ?>
389
<script language="JavaScript">
390
<!--
391

    
392
function mode_change() {
393
	index = document.iform.mode.selectedIndex;
394
	value = document.iform.mode.options[index].value;
395
	switch(value) {
396
		case "p2p_tls":
397
		case "server_tls":
398
		case "server_user":
399
			document.getElementById("tls").style.display="";
400
			document.getElementById("tls_ca").style.display="";
401
			document.getElementById("tls_crl").style.display="";
402
			document.getElementById("tls_cert").style.display="";
403
			document.getElementById("tls_dh").style.display="";
404
			document.getElementById("strictusercn").style.display="none";
405
			document.getElementById("psk").style.display="none";
406
			break;
407
		case "server_tls_user":
408
			document.getElementById("tls").style.display="";
409
			document.getElementById("tls_ca").style.display="";
410
			document.getElementById("tls_crl").style.display="";
411
			document.getElementById("tls_cert").style.display="";
412
			document.getElementById("tls_dh").style.display="";
413
			document.getElementById("strictusercn").style.display="";
414
			document.getElementById("psk").style.display="none";
415
			break;
416
		case "p2p_shared_key":
417
			document.getElementById("tls").style.display="none";
418
			document.getElementById("tls_ca").style.display="none";
419
			document.getElementById("tls_crl").style.display="none";
420
			document.getElementById("tls_cert").style.display="none";
421
			document.getElementById("tls_dh").style.display="none";
422
			document.getElementById("strictusercn").style.display="none";
423
			document.getElementById("psk").style.display="";
424
			break;
425
	}
426
	switch(value) {
427
		case "p2p_shared_key":
428
			document.getElementById("client_opts").style.display="none";
429
			document.getElementById("remote_opts").style.display="";
430
			document.getElementById("local_opts").style.display="none";
431
			document.getElementById("authmodetr").style.display="none";
432
			document.getElementById("inter_client_communication").style.display="none";
433
			break;
434
		case "p2p_tls":
435
			document.getElementById("client_opts").style.display="none";
436
			document.getElementById("remote_opts").style.display="";
437
			document.getElementById("local_opts").style.display="";
438
			document.getElementById("authmodetr").style.display="none";
439
			document.getElementById("inter_client_communication").style.display="none";
440
			break;
441
		case "server_user":
442
                case "server_tls_user":
443
			document.getElementById("authmodetr").style.display="";
444
			document.getElementById("client_opts").style.display="";
445
			document.getElementById("remote_opts").style.display="none";
446
			document.getElementById("local_opts").style.display="";
447
			document.getElementById("inter_client_communication").style.display="";
448
			break;
449
		case "server_tls":
450
			document.getElementById("authmodetr").style.display="none";
451
		default:
452
			document.getElementById("client_opts").style.display="";
453
			document.getElementById("remote_opts").style.display="none";
454
			document.getElementById("local_opts").style.display="";
455
			document.getElementById("inter_client_communication").style.display="";
456
			break;
457
	}
458
}
459

    
460
function autokey_change() {
461

    
462
	if (document.iform.autokey_enable.checked)
463
		document.getElementById("autokey_opts").style.display="none";
464
	else
465
		document.getElementById("autokey_opts").style.display="";
466
}
467

    
468
function tlsauth_change() {
469

    
470
<?php if (!$pconfig['tls']): ?>
471
	if (document.iform.tlsauth_enable.checked)
472
		document.getElementById("tlsauth_opts").style.display="";
473
	else
474
		document.getElementById("tlsauth_opts").style.display="none";
475
<?php endif; ?>
476

    
477
	autotls_change();
478
}
479

    
480
function autotls_change() {
481

    
482
<?php if (!$pconfig['tls']): ?>
483
	autocheck = document.iform.autotls_enable.checked;
484
<?php else: ?>
485
	autocheck = false;
486
<?php endif; ?>
487

    
488
	if (document.iform.tlsauth_enable.checked && !autocheck)
489
		document.getElementById("autotls_opts").style.display="";
490
	else
491
		document.getElementById("autotls_opts").style.display="none";
492
}
493

    
494
function gwredir_change() {
495

    
496
	if (document.iform.gwredir.checked)
497
		document.getElementById("local_opts").style.display="none";
498
	else
499
		document.getElementById("local_opts").style.display="";
500
}
501

    
502
function dns_domain_change() {
503

    
504
	if (document.iform.dns_domain_enable.checked)
505
		document.getElementById("dns_domain_data").style.display="";
506
	else
507
		document.getElementById("dns_domain_data").style.display="none";
508
}
509

    
510
function dns_server_change() {
511

    
512
	if (document.iform.dns_server_enable.checked)
513
		document.getElementById("dns_server_data").style.display="";
514
	else
515
		document.getElementById("dns_server_data").style.display="none";
516
}
517

    
518
function wins_server_change() {
519

    
520
	if (document.iform.wins_server_enable.checked)
521
		document.getElementById("wins_server_data").style.display="";
522
	else
523
		document.getElementById("wins_server_data").style.display="none";
524
}
525

    
526
function ntp_server_change() {
527

    
528
	if (document.iform.ntp_server_enable.checked)
529
		document.getElementById("ntp_server_data").style.display="";
530
	else
531
		document.getElementById("ntp_server_data").style.display="none";
532
}
533

    
534
function netbios_change() {
535

    
536
	if (document.iform.netbios_enable.checked) {
537
		document.getElementById("netbios_data").style.display="";
538
		document.getElementById("wins_opts").style.display="";
539
	} else {
540
		document.getElementById("netbios_data").style.display="none";
541
		document.getElementById("wins_opts").style.display="none";
542
	}
543
}
544

    
545
//-->
546
</script>
547
<?php
548
if (!$savemsg)
549
	$savemsg = "";
550
if (count($a_ca) == 0)
551
	$savemsg .= "You have no Certificate Authorities defined. You must visit the <a href=\"system_camanager.php\">Certificate Manager</a> to make one.";
552
if (count($a_cert) == 0)
553
	$savemsg .= "<br/>You have no Certificates defined. You must visit the <a href=\"system_camanager.php\">Certificate Manager</a> to make one.";
554

    
555
if ($input_errors)
556
	print_input_errors($input_errors);
557
if ($savemsg)
558
	print_info_box_np($savemsg);
559
?>
560
<table width="100%" border="0" cellpadding="0" cellspacing="0">
561
	<tr>
562
		<td class="tabnavtbl">
563
			<ul id="tabnav">
564
			<?php 
565
				$tab_array = array();
566
				$tab_array[] = array(gettext("Server"), true, "vpn_openvpn_server.php");
567
				$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
568
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
569
				$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
570
				add_package_tabs("OpenVPN", $tab_array);
571
				display_top_tabs($tab_array);
572
			?>
573
			</ul>
574
		</td>
575
	</tr>    
576
	<tr>
577
		<td class="tabcont">
578

    
579
			<?php if($act=="new" || $act=="edit"): ?>
580

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

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

    
1266
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1267
					<tr>
1268
						<td colspan="2" class="list" height="12"></td>
1269
					</tr>
1270
					<tr>
1271
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
1272
					</tr>
1273
					<tr>
1274
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1275
						<td width="78%" class="vtable">
1276
							<table border="0" cellpadding="2" cellspacing="0">
1277
								<tr>
1278
									<td>
1279
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=$pconfig['custom_options'];?></textarea><br/>
1280
										<?=gettext("Enter any additional options you would like to add to the OpenVPN server configuration here, separated by a semicolon"); ?><br/>
1281
										<?=gettext("EXAMPLE: push \"route 10.0.0.0 255.255.255.0\""); ?>;
1282
									</td>
1283
								</tr>
1284
							</table>
1285
						</td>
1286
					</tr>
1287
				</table>
1288

    
1289
				<br/>
1290

    
1291
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1292
					<tr>
1293
						<td width="22%" valign="top">&nbsp;</td>
1294
						<td width="78%"> 
1295
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>"> 
1296
							<input name="act" type="hidden" value="<?=$act;?>">
1297
							<?php if (isset($id) && $a_server[$id]): ?>
1298
							<input name="id" type="hidden" value="<?=$id;?>">
1299
							<?php endif; ?>
1300
						</td>
1301
					</tr>
1302
				</table>
1303
			</form>
1304

    
1305
			<?php else: ?>
1306

    
1307
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
1308
				<thead>
1309
				<tr>
1310
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
1311
					<td width="10%" class="listhdrr"><?=gettext("Protocol / Port"); ?></td>
1312
					<td width="30%" class="listhdrr"><?=gettext("Tunnel Network"); ?></td>
1313
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
1314
					<td width="10%" class="list"></td>
1315
				</tr>
1316
				</thead>
1317
				<tbody>
1318
				<?php
1319
					$i = 0;
1320
					foreach($a_server as $server):
1321
						$disabled = "NO";
1322
						if (isset($server['disable']))
1323
							$disabled = "YES";
1324
				?>
1325
				<tr>
1326
					<td class="listlr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1327
						<?=$disabled;?>
1328
					</td>
1329
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1330
						<?=htmlspecialchars($server['protocol']);?> / <?=htmlspecialchars($server['local_port']);?>
1331
					</td>
1332
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1333
						<?=htmlspecialchars($server['tunnel_network']);?>
1334
					</td>
1335
					<td class="listbg" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1336
						<?=htmlspecialchars($server['description']);?>
1337
					</td>
1338
					<td valign="middle" nowrap class="list">
1339
						<a href="vpn_openvpn_server.php?act=edit&id=<?=$i;?>">
1340
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit server"); ?>" width="17" height="17" border="0">
1341
						</a>
1342
						&nbsp;
1343
						<a href="vpn_openvpn_server.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this server?"); ?>')">
1344
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete server"); ?>" width="17" height="17" border="0">
1345
						</a>
1346
					</td>
1347
				</tr>
1348
				<?php
1349
					$i++;
1350
					endforeach;
1351
				?>
1352
				</tbody>
1353
				<tfoot>
1354
				<tr>
1355
					<td class="list" colspan="4"></td>
1356
					<td class="list">
1357
						<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">
1358
						</a>
1359
					</td>
1360
				</tr>
1361
				</tfoot>
1362
			</table>
1363

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

    
1366
			<?php endif; ?>
1367

    
1368
		</td>
1369
	</tr>
1370
</table>
1371
<script language="JavaScript">
1372
<!--
1373
mode_change();
1374
autokey_change();
1375
tlsauth_change();
1376
gwredir_change();
1377
dns_domain_change();
1378
dns_server_change();
1379
wins_server_change();
1380
ntp_server_change();
1381
netbios_change();
1382
//-->
1383
</script>
1384
</body>
1385
<?php include("fend.inc"); ?>
1386

    
1387
<?php
1388

    
1389
/* local utility functions */
1390

    
1391
function set_checked($var,& $chk) {
1392
    if($var)
1393
        $chk = 'checked';
1394
    else
1395
        $chk = '';
1396
}
1397

    
1398
?>
(213-213/220)