Project

General

Profile

Download (52.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
		$pconfig['engine'] = $a_server[$id]['engine'];
130

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

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

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

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

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

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

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

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

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

    
181
		$pconfig['duplicate_cn'] = isset($a_server[$id]['duplicate_cn']);
182
	}
183
}
184

    
185
if ($_POST) {
186

    
187
	unset($input_errors);
188
	$pconfig = $_POST;
189

    
190
	if (isset($id) && $a_server[$id])
191
		$vpnid = $a_server[$id]['vpnid'];
192
	else
193
		$vpnid = 0;
194

    
195
	if ($pconfig['mode'] != "p2p_shared_key")
196
		$tls_mode = true;
197
	else
198
		$tls_mode = false;
199

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

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

    
210
	/* input validation */
211
	if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
212
		$input_errors[] = $result;
213

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

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

    
220
	if ($result = openvpn_validate_cidr($pconfig['local_network'], 'Local network'))
221
		$input_errors[] = $result;
222

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

    
227
	if ($pconfig['autokey_enable'])
228
		$pconfig['shared_key'] = openvpn_create_key();
229

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

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

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

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

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

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

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

    
287
	$reqdfields[] = 'tunnel_network';
288
	$reqdfieldsn[] = gettext('Tunnel network');
289

    
290
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
291
	
292
	if (!$input_errors) {
293

    
294
		$server = array();
295

    
296
		if ($vpnid)
297
			$server['vpnid'] = $vpnid;
298
		else
299
			$server['vpnid'] = openvpn_vpnid_next();
300

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

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

    
330
		$server['tunnel_network'] = $pconfig['tunnel_network'];
331
		$server['remote_network'] = $pconfig['remote_network'];
332
		$server['gwredir'] = $pconfig['gwredir'];
333
		$server['local_network'] = $pconfig['local_network'];
334
		$server['maxclients'] = $pconfig['maxclients'];
335
		$server['compression'] = $pconfig['compression'];
336
		$server['passtos'] = $pconfig['passtos'];
337
		$server['client2client'] = $pconfig['client2client'];
338

    
339
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
340
		$server['pool_enable'] = $pconfig['pool_enable'];
341

    
342
		if ($pconfig['dns_domain_enable'])
343
			$server['dns_domain'] = $pconfig['dns_domain'];
344

    
345
		if ($pconfig['dns_server_enable']) {
346
			$server['dns_server1'] = $pconfig['dns_server1'];
347
			$server['dns_server2'] = $pconfig['dns_server2'];
348
			$server['dns_server3'] = $pconfig['dns_server3'];
349
			$server['dns_server4'] = $pconfig['dns_server4'];
350
		}
351

    
352
		if ($pconfig['ntp_server_enable']) {
353
			$server['ntp_server1'] = $pconfig['ntp_server1'];
354
			$server['ntp_server2'] = $pconfig['ntp_server2'];
355
		}
356

    
357
		$server['netbios_enable'] = $pconfig['netbios_enable'];
358
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
359
		$server['netbios_scope'] = $pconfig['netbios_scope'];
360

    
361
		if ($pconfig['netbios_enable']) {
362

    
363
			if ($pconfig['wins_server_enable']) {
364
				$server['wins_server1'] = $pconfig['wins_server1'];
365
				$server['wins_server2'] = $pconfig['wins_server2'];
366
			}
367

    
368
			if ($pconfig['dns_server_enable'])
369
				$server['nbdd_server1'] = $pconfig['nbdd_server1'];
370
		}
371

    
372
		if ($_POST['duplicate_cn'] == "yes")
373
			$server['duplicate_cn'] = true;
374

    
375
		if (isset($id) && $a_server[$id])
376
			$a_server[$id] = $server;
377
		else
378
			$a_server[] = $server;
379

    
380
		openvpn_resync('server', $server);
381
		write_config();
382
		
383
		header("Location: vpn_openvpn_server.php");
384
		exit;
385
	}
386
	if (!empty($pconfig['authmode']))
387
		$pconfig['authmode'] = implode(",", $pconfig['authmode']);
388
}
389

    
390
include("head.inc");
391

    
392
?>
393

    
394
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
395
<?php include("fbegin.inc"); ?>
396
<script language="JavaScript">
397
<!--
398

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

    
472
function autokey_change() {
473

    
474
	if (document.iform.autokey_enable.checked)
475
		document.getElementById("autokey_opts").style.display="none";
476
	else
477
		document.getElementById("autokey_opts").style.display="";
478
}
479

    
480
function tlsauth_change() {
481

    
482
<?php if (!$pconfig['tls']): ?>
483
	if (document.iform.tlsauth_enable.checked)
484
		document.getElementById("tlsauth_opts").style.display="";
485
	else
486
		document.getElementById("tlsauth_opts").style.display="none";
487
<?php endif; ?>
488

    
489
	autotls_change();
490
}
491

    
492
function autotls_change() {
493

    
494
<?php if (!$pconfig['tls']): ?>
495
	autocheck = document.iform.autotls_enable.checked;
496
<?php else: ?>
497
	autocheck = false;
498
<?php endif; ?>
499

    
500
	if (document.iform.tlsauth_enable.checked && !autocheck)
501
		document.getElementById("autotls_opts").style.display="";
502
	else
503
		document.getElementById("autotls_opts").style.display="none";
504
}
505

    
506
function gwredir_change() {
507

    
508
	if (document.iform.gwredir.checked)
509
		document.getElementById("local_opts").style.display="none";
510
	else
511
		document.getElementById("local_opts").style.display="";
512
}
513

    
514
function dns_domain_change() {
515

    
516
	if (document.iform.dns_domain_enable.checked)
517
		document.getElementById("dns_domain_data").style.display="";
518
	else
519
		document.getElementById("dns_domain_data").style.display="none";
520
}
521

    
522
function dns_server_change() {
523

    
524
	if (document.iform.dns_server_enable.checked)
525
		document.getElementById("dns_server_data").style.display="";
526
	else
527
		document.getElementById("dns_server_data").style.display="none";
528
}
529

    
530
function wins_server_change() {
531

    
532
	if (document.iform.wins_server_enable.checked)
533
		document.getElementById("wins_server_data").style.display="";
534
	else
535
		document.getElementById("wins_server_data").style.display="none";
536
}
537

    
538
function ntp_server_change() {
539

    
540
	if (document.iform.ntp_server_enable.checked)
541
		document.getElementById("ntp_server_data").style.display="";
542
	else
543
		document.getElementById("ntp_server_data").style.display="none";
544
}
545

    
546
function netbios_change() {
547

    
548
	if (document.iform.netbios_enable.checked) {
549
		document.getElementById("netbios_data").style.display="";
550
		document.getElementById("wins_opts").style.display="";
551
	} else {
552
		document.getElementById("netbios_data").style.display="none";
553
		document.getElementById("wins_opts").style.display="none";
554
	}
555
}
556

    
557
//-->
558
</script>
559
<?php
560
if (!$savemsg)
561
	$savemsg = "";
562
if (count($a_ca) == 0)
563
	$savemsg .= "You have no Certificate Authorities defined. You must visit the <a href=\"system_camanager.php\">Certificate Manager</a> to make one.";
564
if (count($a_cert) == 0)
565
	$savemsg .= "<br/>You have no Certificates defined. You must visit the <a href=\"system_camanager.php\">Certificate Manager</a> to make one.";
566

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

    
591
			<?php if($act=="new" || $act=="edit"): ?>
592

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

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

    
1314
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1315
					<tr>
1316
						<td colspan="2" class="list" height="12"></td>
1317
					</tr>
1318
					<tr>
1319
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
1320
					</tr>
1321
					<tr>
1322
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1323
						<td width="78%" class="vtable">
1324
							<table border="0" cellpadding="2" cellspacing="0">
1325
								<tr>
1326
									<td>
1327
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=htmlspecialchars($pconfig['custom_options']);?></textarea><br/>
1328
										<?=gettext("Enter any additional options you would like to add to the OpenVPN server configuration here, separated by a semicolon"); ?><br/>
1329
										<?=gettext("EXAMPLE: push \"route 10.0.0.0 255.255.255.0\""); ?>;
1330
									</td>
1331
								</tr>
1332
							</table>
1333
						</td>
1334
					</tr>
1335
				</table>
1336

    
1337
				<br/>
1338

    
1339
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1340
					<tr>
1341
						<td width="22%" valign="top">&nbsp;</td>
1342
						<td width="78%"> 
1343
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>"> 
1344
							<input name="act" type="hidden" value="<?=$act;?>">
1345
							<?php if (isset($id) && $a_server[$id]): ?>
1346
							<input name="id" type="hidden" value="<?=$id;?>">
1347
							<?php endif; ?>
1348
						</td>
1349
					</tr>
1350
				</table>
1351
			</form>
1352

    
1353
			<?php else: ?>
1354

    
1355
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
1356
				<thead>
1357
				<tr>
1358
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
1359
					<td width="10%" class="listhdrr"><?=gettext("Protocol / Port"); ?></td>
1360
					<td width="30%" class="listhdrr"><?=gettext("Tunnel Network"); ?></td>
1361
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
1362
					<td width="10%" class="list"></td>
1363
				</tr>
1364
				</thead>
1365
				<tbody>
1366
				<?php
1367
					$i = 0;
1368
					foreach($a_server as $server):
1369
						$disabled = "NO";
1370
						if (isset($server['disable']))
1371
							$disabled = "YES";
1372
				?>
1373
				<tr>
1374
					<td class="listlr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1375
						<?=$disabled;?>
1376
					</td>
1377
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1378
						<?=htmlspecialchars($server['protocol']);?> / <?=htmlspecialchars($server['local_port']);?>
1379
					</td>
1380
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1381
						<?=htmlspecialchars($server['tunnel_network']);?>
1382
					</td>
1383
					<td class="listbg" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1384
						<?=htmlspecialchars($server['description']);?>
1385
					</td>
1386
					<td valign="middle" nowrap class="list">
1387
						<a href="vpn_openvpn_server.php?act=edit&id=<?=$i;?>">
1388
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit server"); ?>" width="17" height="17" border="0">
1389
						</a>
1390
						&nbsp;
1391
						<a href="vpn_openvpn_server.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this server?"); ?>')">
1392
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete server"); ?>" width="17" height="17" border="0">
1393
						</a>
1394
					</td>
1395
				</tr>
1396
				<?php
1397
					$i++;
1398
					endforeach;
1399
				?>
1400
				</tbody>
1401
				<tfoot>
1402
				<tr>
1403
					<td class="list" colspan="4"></td>
1404
					<td class="list">
1405
						<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">
1406
						</a>
1407
					</td>
1408
				</tr>
1409
				</tfoot>
1410
			</table>
1411

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

    
1414
			<?php endif; ?>
1415

    
1416
		</td>
1417
	</tr>
1418
</table>
1419
<script language="JavaScript">
1420
<!--
1421
mode_change();
1422
autokey_change();
1423
tlsauth_change();
1424
gwredir_change();
1425
dns_domain_change();
1426
dns_server_change();
1427
wins_server_change();
1428
ntp_server_change();
1429
netbios_change();
1430
//-->
1431
</script>
1432
</body>
1433
<?php include("fend.inc"); ?>
1434

    
1435
<?php
1436

    
1437
/* local utility functions */
1438

    
1439
function set_checked($var,& $chk) {
1440
    if($var)
1441
        $chk = 'checked';
1442
    else
1443
        $chk = '';
1444
}
1445

    
1446
?>
(216-216/223)