Project

General

Profile

Download (51 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("gwredir_opts").style.display="none";
431
			document.getElementById("local_opts").style.display="none";
432
			document.getElementById("authmodetr").style.display="none";
433
			document.getElementById("inter_client_communication").style.display="none";
434
			break;
435
		case "p2p_tls":
436
			document.getElementById("client_opts").style.display="none";
437
			document.getElementById("remote_opts").style.display="";
438
			document.getElementById("gwredir_opts").style.display="";
439
			document.getElementById("local_opts").style.display="";
440
			document.getElementById("authmodetr").style.display="none";
441
			document.getElementById("inter_client_communication").style.display="none";
442
			break;
443
		case "server_user":
444
                case "server_tls_user":
445
			document.getElementById("authmodetr").style.display="";
446
			document.getElementById("client_opts").style.display="";
447
			document.getElementById("remote_opts").style.display="none";
448
			document.getElementById("gwredir_opts").style.display="";
449
			document.getElementById("local_opts").style.display="";
450
			document.getElementById("inter_client_communication").style.display="";
451
			break;
452
		case "server_tls":
453
			document.getElementById("authmodetr").style.display="none";
454
		default:
455
			document.getElementById("client_opts").style.display="";
456
			document.getElementById("remote_opts").style.display="none";
457
			document.getElementById("gwredir_opts").style.display="";
458
			document.getElementById("local_opts").style.display="";
459
			document.getElementById("inter_client_communication").style.display="";
460
			break;
461
	}
462
	gwredir_change();
463
}
464

    
465
function autokey_change() {
466

    
467
	if (document.iform.autokey_enable.checked)
468
		document.getElementById("autokey_opts").style.display="none";
469
	else
470
		document.getElementById("autokey_opts").style.display="";
471
}
472

    
473
function tlsauth_change() {
474

    
475
<?php if (!$pconfig['tls']): ?>
476
	if (document.iform.tlsauth_enable.checked)
477
		document.getElementById("tlsauth_opts").style.display="";
478
	else
479
		document.getElementById("tlsauth_opts").style.display="none";
480
<?php endif; ?>
481

    
482
	autotls_change();
483
}
484

    
485
function autotls_change() {
486

    
487
<?php if (!$pconfig['tls']): ?>
488
	autocheck = document.iform.autotls_enable.checked;
489
<?php else: ?>
490
	autocheck = false;
491
<?php endif; ?>
492

    
493
	if (document.iform.tlsauth_enable.checked && !autocheck)
494
		document.getElementById("autotls_opts").style.display="";
495
	else
496
		document.getElementById("autotls_opts").style.display="none";
497
}
498

    
499
function gwredir_change() {
500

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

    
507
function dns_domain_change() {
508

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

    
515
function dns_server_change() {
516

    
517
	if (document.iform.dns_server_enable.checked)
518
		document.getElementById("dns_server_data").style.display="";
519
	else
520
		document.getElementById("dns_server_data").style.display="none";
521
}
522

    
523
function wins_server_change() {
524

    
525
	if (document.iform.wins_server_enable.checked)
526
		document.getElementById("wins_server_data").style.display="";
527
	else
528
		document.getElementById("wins_server_data").style.display="none";
529
}
530

    
531
function ntp_server_change() {
532

    
533
	if (document.iform.ntp_server_enable.checked)
534
		document.getElementById("ntp_server_data").style.display="";
535
	else
536
		document.getElementById("ntp_server_data").style.display="none";
537
}
538

    
539
function netbios_change() {
540

    
541
	if (document.iform.netbios_enable.checked) {
542
		document.getElementById("netbios_data").style.display="";
543
		document.getElementById("wins_opts").style.display="";
544
	} else {
545
		document.getElementById("netbios_data").style.display="none";
546
		document.getElementById("wins_opts").style.display="none";
547
	}
548
}
549

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

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

    
584
			<?php if($act=="new" || $act=="edit"): ?>
585

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

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

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

    
1294
				<br/>
1295

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

    
1310
			<?php else: ?>
1311

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

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

    
1371
			<?php endif; ?>
1372

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

    
1392
<?php
1393

    
1394
/* local utility functions */
1395

    
1396
function set_checked($var,& $chk) {
1397
    if($var)
1398
        $chk = 'checked';
1399
    else
1400
        $chk = '';
1401
}
1402

    
1403
?>
(215-215/222)