Project

General

Profile

Download (55.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['dev_mode'] = "tun";
95
	$pconfig['interface'] = "wan";
96
	$pconfig['local_port'] = openvpn_port_next('UDP');
97
	$pconfig['pool_enable'] = "yes";
98
	$pconfig['cert_depth'] = 1;
99
}
100

    
101
if($_GET['act']=="edit"){
102

    
103
	if (isset($id) && $a_server[$id]) {
104

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

    
118
		if ($pconfig['mode'] != "p2p_shared_key") {
119
			if ($a_server[$id]['tls']) {
120
				$pconfig['tlsauth_enable'] = "yes";
121
				$pconfig['tls'] = base64_decode($a_server[$id]['tls']);
122
			}
123
			$pconfig['caref'] = $a_server[$id]['caref'];
124
			$pconfig['crlref'] = $a_server[$id]['crlref'];
125
			$pconfig['certref'] = $a_server[$id]['certref'];
126
			$pconfig['dh_length'] = $a_server[$id]['dh_length'];
127
			if (isset($a_server[$id]['cert_depth']))
128
				$pconfig['cert_depth'] = $a_server[$id]['cert_depth'];
129
			else
130
				$pconfig['cert_depth'] = 1;
131
			if ($pconfig['mode'] == "server_tls_user")
132
				$pconfig['strictusercn'] = $a_server[$id]['strictusercn'];
133
		} else
134
			$pconfig['shared_key'] = base64_decode($a_server[$id]['shared_key']);
135
		$pconfig['crypto'] = $a_server[$id]['crypto'];
136
		$pconfig['engine'] = $a_server[$id]['engine'];
137

    
138
		$pconfig['tunnel_network'] = $a_server[$id]['tunnel_network'];
139
		$pconfig['remote_network'] = $a_server[$id]['remote_network'];
140
		$pconfig['gwredir'] = $a_server[$id]['gwredir'];
141
		$pconfig['local_network'] = $a_server[$id]['local_network'];
142
		$pconfig['maxclients'] = $a_server[$id]['maxclients'];
143
		$pconfig['compression'] = $a_server[$id]['compression'];
144
		$pconfig['passtos'] = $a_server[$id]['passtos'];
145
		$pconfig['client2client'] = $a_server[$id]['client2client'];
146

    
147
		$pconfig['dynamic_ip'] = $a_server[$id]['dynamic_ip'];
148
		$pconfig['pool_enable'] = $a_server[$id]['pool_enable'];
149

    
150
		$pconfig['dns_domain'] = $a_server[$id]['dns_domain'];
151
		if ($pconfig['dns_domain'])
152
			$pconfig['dns_domain_enable'] = true;
153

    
154
		$pconfig['dns_server1'] = $a_server[$id]['dns_server1'];
155
		$pconfig['dns_server2'] = $a_server[$id]['dns_server2'];
156
		$pconfig['dns_server3'] = $a_server[$id]['dns_server3'];
157
		$pconfig['dns_server4'] = $a_server[$id]['dns_server4'];
158
		if ($pconfig['dns_server1'] ||
159
			$pconfig['dns_server2'] ||
160
			$pconfig['dns_server3'] ||
161
			$pconfig['dns_server4'])
162
			$pconfig['dns_server_enable'] = true;
163

    
164
		$pconfig['ntp_server1'] = $a_server[$id]['ntp_server1'];
165
		$pconfig['ntp_server2'] = $a_server[$id]['ntp_server2'];
166
		if ($pconfig['ntp_server1'] ||
167
			$pconfig['ntp_server2'])
168
			$pconfig['ntp_server_enable'] = true;
169

    
170
		$pconfig['netbios_enable'] = $a_server[$id]['netbios_enable'];
171
		$pconfig['netbios_ntype'] = $a_server[$id]['netbios_ntype'];
172
		$pconfig['netbios_scope'] = $a_server[$id]['netbios_scope'];
173

    
174
		$pconfig['wins_server1'] = $a_server[$id]['wins_server1'];
175
		$pconfig['wins_server2'] = $a_server[$id]['wins_server2'];
176
		if ($pconfig['wins_server1'] ||
177
			$pconfig['wins_server2'])
178
			$pconfig['wins_server_enable'] = true;
179

    
180
		$pconfig['nbdd_server1'] = $a_server[$id]['nbdd_server1'];
181
		if ($pconfig['nbdd_server1'])
182
			$pconfig['nbdd_server_enable'] = true;
183

    
184
		// just in case the modes switch
185
		$pconfig['autokey_enable'] = "yes";
186
		$pconfig['autotls_enable'] = "yes";
187

    
188
		$pconfig['duplicate_cn'] = isset($a_server[$id]['duplicate_cn']);
189
	}
190
}
191

    
192
if ($_POST) {
193

    
194
	unset($input_errors);
195
	$pconfig = $_POST;
196

    
197
	if (isset($id) && $a_server[$id])
198
		$vpnid = $a_server[$id]['vpnid'];
199
	else
200
		$vpnid = 0;
201

    
202
	if ($pconfig['mode'] != "p2p_shared_key")
203
		$tls_mode = true;
204
	else
205
		$tls_mode = false;
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
		$server['dev_mode'] = $pconfig['dev_mode'];
308
		list($server['interface'], $server['ipaddr']) = explode ("|",$pconfig['interface']);
309
		$server['local_port'] = $pconfig['local_port'];
310
		$server['description'] = $pconfig['description'];
311
		$server['custom_options'] = str_replace("\r\n", "\n", $pconfig['custom_options']);
312

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

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

    
341
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
342
		$server['pool_enable'] = $pconfig['pool_enable'];
343

    
344
		if ($pconfig['dns_domain_enable'])
345
			$server['dns_domain'] = $pconfig['dns_domain'];
346

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

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

    
359
		$server['netbios_enable'] = $pconfig['netbios_enable'];
360
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
361
		$server['netbios_scope'] = $pconfig['netbios_scope'];
362

    
363
		if ($pconfig['netbios_enable']) {
364

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

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

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

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

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

    
392
include("head.inc");
393

    
394
?>
395

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

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

    
477
function autokey_change() {
478

    
479
	if (document.iform.autokey_enable.checked)
480
		document.getElementById("autokey_opts").style.display="none";
481
	else
482
		document.getElementById("autokey_opts").style.display="";
483
}
484

    
485
function tlsauth_change() {
486

    
487
<?php if (!$pconfig['tls']): ?>
488
	if (document.iform.tlsauth_enable.checked)
489
		document.getElementById("tlsauth_opts").style.display="";
490
	else
491
		document.getElementById("tlsauth_opts").style.display="none";
492
<?php endif; ?>
493

    
494
	autotls_change();
495
}
496

    
497
function autotls_change() {
498

    
499
<?php if (!$pconfig['tls']): ?>
500
	autocheck = document.iform.autotls_enable.checked;
501
<?php else: ?>
502
	autocheck = false;
503
<?php endif; ?>
504

    
505
	if (document.iform.tlsauth_enable.checked && !autocheck)
506
		document.getElementById("autotls_opts").style.display="";
507
	else
508
		document.getElementById("autotls_opts").style.display="none";
509
}
510

    
511
function gwredir_change() {
512

    
513
	if (document.iform.gwredir.checked)
514
		document.getElementById("local_opts").style.display="none";
515
	else
516
		document.getElementById("local_opts").style.display="";
517
}
518

    
519
function dns_domain_change() {
520

    
521
	if (document.iform.dns_domain_enable.checked)
522
		document.getElementById("dns_domain_data").style.display="";
523
	else
524
		document.getElementById("dns_domain_data").style.display="none";
525
}
526

    
527
function dns_server_change() {
528

    
529
	if (document.iform.dns_server_enable.checked)
530
		document.getElementById("dns_server_data").style.display="";
531
	else
532
		document.getElementById("dns_server_data").style.display="none";
533
}
534

    
535
function wins_server_change() {
536

    
537
	if (document.iform.wins_server_enable.checked)
538
		document.getElementById("wins_server_data").style.display="";
539
	else
540
		document.getElementById("wins_server_data").style.display="none";
541
}
542

    
543
function ntp_server_change() {
544

    
545
	if (document.iform.ntp_server_enable.checked)
546
		document.getElementById("ntp_server_data").style.display="";
547
	else
548
		document.getElementById("ntp_server_data").style.display="none";
549
}
550

    
551
function netbios_change() {
552

    
553
	if (document.iform.netbios_enable.checked) {
554
		document.getElementById("netbios_data").style.display="";
555
		document.getElementById("wins_opts").style.display="";
556
	} else {
557
		document.getElementById("netbios_data").style.display="none";
558
		document.getElementById("wins_opts").style.display="none";
559
	}
560
}
561

    
562
//-->
563
</script>
564
<?php
565
if (!$savemsg)
566
	$savemsg = "";
567

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

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

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

    
1119
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1120
					<tr>
1121
						<td colspan="2" class="list" height="12"></td>
1122
					</tr>
1123
					<tr>
1124
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Client Settings"); ?></td>
1125
					</tr>
1126
					<tr>
1127
						<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic IP"); ?></td>
1128
						<td width="78%" class="vtable">
1129
							<table border="0" cellpadding="2" cellspacing="0">
1130
								<tr>
1131
									<td>
1132
										<?php set_checked($pconfig['dynamic_ip'],$chk); ?>
1133
										<input name="dynamic_ip" type="checkbox" id="dynamic_ip" value="yes" <?=$chk;?>/>
1134
									</td>
1135
									<td>
1136
										<span class="vexpl">
1137
											<?=gettext("Allow connected clients to retain their connections if their IP address changes"); ?>.<br>
1138
										</span>
1139
									</td>
1140
								</tr>
1141
							</table>
1142
						</td>
1143
					</tr>
1144
					<tr>
1145
						<td width="22%" valign="top" class="vncell"><?=gettext("Address Pool"); ?></td>
1146
						<td width="78%" class="vtable">
1147
							<table border="0" cellpadding="2" cellspacing="0">
1148
								<tr>
1149
									<td>
1150
										<?php set_checked($pconfig['pool_enable'],$chk); ?>
1151
										<input name="pool_enable" type="checkbox" id="pool_enable" value="yes" <?=$chk;?>/>
1152
									</td>
1153
									<td>
1154
										<span class="vexpl">
1155
											<?=gettext("Provide a virtual adapter IP address to clients (see Tunnel Network)"); ?><br>
1156
										</span>
1157
									</td>
1158
								</tr>
1159
							</table>
1160
						</td>
1161
					</tr>
1162
					<tr>
1163
						<td width="22%" valign="top" class="vncell"><?=gettext("DNS Default Domain"); ?></td>
1164
						<td width="78%" class="vtable">
1165
							<table border="0" cellpadding="2" cellspacing="0">
1166
								<tr>
1167
									<td>
1168
										<?php set_checked($pconfig['dns_domain_enable'],$chk); ?>
1169
										<input name="dns_domain_enable" type="checkbox" id="dns_domain_enable" value="yes" <?=$chk;?> onClick="dns_domain_change()">
1170
									</td>
1171
									<td>
1172
										<span class="vexpl">
1173
	                                        <?=gettext("Provide a default domain name to clients"); ?><br>
1174
										</span>
1175
									</td>
1176
								</tr>
1177
							</table>
1178
							<table border="0" cellpadding="2" cellspacing="0" id="dns_domain_data">
1179
								<tr>
1180
									<td>
1181
										<input name="dns_domain" type="text" class="formfld unknown" id="dns_domain" size="30" value="<?=htmlspecialchars($pconfig['dns_domain']);?>">
1182
									</td>
1183
								</tr>
1184
							</table>
1185
						</td>
1186
					</tr>
1187
					<tr>
1188
						<td width="22%" valign="top" class="vncell"><?=gettext("DNS Servers"); ?></td>
1189
						<td width="78%" class="vtable">
1190
							<table border="0" cellpadding="2" cellspacing="0">
1191
								<tr>
1192
									<td>
1193
										<?php set_checked($pconfig['dns_server_enable'],$chk); ?>
1194
										<input name="dns_server_enable" type="checkbox" id="dns_server_enable" value="yes" <?=$chk;?> onClick="dns_server_change()">
1195
									</td>
1196
									<td>
1197
										<span class="vexpl">
1198
											<?=gettext("Provide a DNS server list to clients"); ?><br>
1199
										</span>
1200
									</td>
1201
								</tr>
1202
							</table>
1203
							<table border="0" cellpadding="2" cellspacing="0" id="dns_server_data">
1204
								<tr>
1205
									<td>
1206
										<span class="vexpl">
1207
											<?=gettext("Server"); ?> #1:&nbsp;
1208
										</span>
1209
										<input name="dns_server1" type="text" class="formfld unknown" id="dns_server1" size="20" value="<?=htmlspecialchars($pconfig['dns_server1']);?>">
1210
									</td>
1211
								</tr>
1212
								<tr>
1213
									<td>
1214
										<span class="vexpl">
1215
											<?=gettext("Server"); ?> #2:&nbsp;
1216
										</span>
1217
										<input name="dns_server2" type="text" class="formfld unknown" id="dns_server2" size="20" value="<?=htmlspecialchars($pconfig['dns_server2']);?>">
1218
									</td>
1219
								</tr>
1220
								<tr>
1221
									<td>
1222
										<span class="vexpl">
1223
											<?=gettext("Server"); ?> #3:&nbsp;
1224
										</span>
1225
										<input name="dns_server3" type="text" class="formfld unknown" id="dns_server3" size="20" value="<?=htmlspecialchars($pconfig['dns_server3']);?>">
1226
									</td>
1227
								</tr>
1228
								<tr>
1229
									<td>
1230
										<span class="vexpl">
1231
											<?=gettext("Server"); ?> #4:&nbsp;
1232
										</span>
1233
										<input name="dns_server4" type="text" class="formfld unknown" id="dns_server4" size="20" value="<?=htmlspecialchars($pconfig['dns_server4']);?>">
1234
									</td>
1235
								</tr>
1236
							</table>
1237
						</td>
1238
					</tr>
1239
					<tr>
1240
						<td width="22%" valign="top" class="vncell"><?=gettext("NTP Servers"); ?></td>
1241
						<td width="78%" class="vtable">
1242
							<table border="0" cellpadding="2" cellspacing="0">
1243
								<tr>
1244
									<td>
1245
										<?php set_checked($pconfig['ntp_server_enable'],$chk); ?>
1246
										<input name="ntp_server_enable" type="checkbox" id="ntp_server_enable" value="yes" <?=$chk;?> onClick="ntp_server_change()">
1247
									</td>
1248
									<td>
1249
										<span class="vexpl">
1250
											<?=gettext("Provide a NTP server list to clients"); ?><br>
1251
										</span>
1252
									</td>
1253
								</tr>
1254
							</table>
1255
							<table border="0" cellpadding="2" cellspacing="0" id="ntp_server_data">
1256
								<tr>
1257
									<td>
1258
										<span class="vexpl">
1259
											<?=gettext("Server"); ?> #1:&nbsp;
1260
										</span>
1261
										<input name="ntp_server1" type="text" class="formfld unknown" id="ntp_server1" size="20" value="<?=htmlspecialchars($pconfig['ntp_server1']);?>">
1262
									</td>
1263
								</tr>
1264
								<tr>
1265
									<td>
1266
										<span class="vexpl">
1267
											<?=gettext("Server"); ?> #2:&nbsp;
1268
										</span>
1269
										<input name="ntp_server2" type="text" class="formfld unknown" id="ntp_server2" size="20" value="<?=htmlspecialchars($pconfig['ntp_server2']);?>">
1270
									</td>
1271
								</tr>
1272
							</table>
1273
						</td>
1274
					</tr>
1275
					<tr>
1276
						<td width="22%" valign="top" class="vncell"><?=gettext("NetBIOS Options"); ?></td>
1277
						<td width="78%" class="vtable">
1278
							<table border="0" cellpadding="2" cellspacing="0">
1279
								<tr>
1280
									<td>
1281
										<?php set_checked($pconfig['netbios_enable'],$chk); ?>
1282
										<input name="netbios_enable" type="checkbox" id="netbios_enable" value="yes" <?=$chk;?> onClick="netbios_change()">
1283
									</td>
1284
									<td>
1285
										<span class="vexpl">
1286
											<?=gettext("Enable NetBIOS over TCP/IP"); ?><br>
1287
										</span>
1288
									</td>
1289
								</tr>
1290
							</table>
1291
							<?=gettext("If this option is not set, all NetBIOS-over-TCP/IP options (including WINS) will be disabled"); ?>.
1292
							<br/>
1293
							<table border="0" cellpadding="2" cellspacing="0" id="netbios_data">
1294
								<tr>
1295
									<td>
1296
										<br/>
1297
										<span class="vexpl">
1298
											<?=gettext("Node Type"); ?>:&nbsp;
1299
										</span>
1300
										<select name='netbios_ntype' class="formselect">
1301
										<?php
1302
											foreach ($netbios_nodetypes as $type => $name):
1303
												$selected = "";
1304
												if ($pconfig['netbios_ntype'] == $type)
1305
													$selected = "selected";
1306
										?>
1307
											<option value="<?=$type;?>" <?=$selected;?>><?=$name;?></option>
1308
										<?php endforeach; ?>
1309
										</select>
1310
										<br/>
1311
										<?=gettext("Possible options: b-node (broadcasts), p-node " .
1312
										"(point-to-point name queries to a WINS server), " .
1313
										"m-node (broadcast then query name server), and " .
1314
										"h-node (query name server, then broadcast)"); ?>.
1315
									</td>
1316
								</tr>
1317
								<tr>
1318
									<td>
1319
										<br/>
1320
										<span class="vexpl">
1321
											<?=gettext("Scope ID"); ?>:&nbsp;
1322
										</span>
1323
										<input name="netbios_scope" type="text" class="formfld unknown" id="netbios_scope" size="30" value="<?=htmlspecialchars($pconfig['netbios_scope']);?>">
1324
										<br/>
1325
										<?=gettext("A NetBIOS Scope	ID provides an extended naming " .
1326
										"service for	NetBIOS over TCP/IP. The NetBIOS " .
1327
										"scope ID isolates NetBIOS traffic on a single " .
1328
										"network to only those nodes with the same " .
1329
										"NetBIOS scope ID"); ?>.
1330
									</td>
1331
								</tr>
1332
							</table>
1333
						</td>
1334
					</tr>
1335
					<tr id="wins_opts">
1336
						<td width="22%" valign="top" class="vncell"><?=gettext("WINS Servers"); ?></td>
1337
						<td width="78%" class="vtable">
1338
							<table border="0" cellpadding="2" cellspacing="0">
1339
								<tr>
1340
									<td>
1341
										<?php set_checked($pconfig['wins_server_enable'],$chk); ?>
1342
										<input name="wins_server_enable" type="checkbox" id="wins_server_enable" value="yes" <?=$chk;?> onClick="wins_server_change()">
1343
									</td>
1344
									<td>
1345
										<span class="vexpl">
1346
											<?=gettext("Provide a WINS server list to clients"); ?><br>
1347
										</span>
1348
									</td>
1349
								</tr>
1350
							</table>
1351
							<table border="0" cellpadding="2" cellspacing="0" id="wins_server_data">
1352
								<tr>
1353
									<td>
1354
										<span class="vexpl">
1355
											<?=gettext("Server"); ?> #1:&nbsp;
1356
										</span>
1357
										<input name="wins_server1" type="text" class="formfld unknown" id="wins_server1" size="20" value="<?=htmlspecialchars($pconfig['wins_server1']);?>">
1358
									</td>
1359
								</tr>
1360
								<tr>
1361
									<td>
1362
										<span class="vexpl">
1363
											<?=gettext("Server"); ?> #2:&nbsp;
1364
										</span>
1365
										<input name="wins_server2" type="text" class="formfld unknown" id="wins_server2" size="20" value="<?=htmlspecialchars($pconfig['wins_server2']);?>">
1366
									</td>
1367
								</tr>
1368
							</table>
1369
						</td>
1370
					</tr>
1371
				</table>
1372

    
1373
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1374
					<tr>
1375
						<td colspan="2" class="list" height="12"></td>
1376
					</tr>
1377
					<tr>
1378
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
1379
					</tr>
1380
					<tr>
1381
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1382
						<td width="78%" class="vtable">
1383
							<table border="0" cellpadding="2" cellspacing="0">
1384
								<tr>
1385
									<td>
1386
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=htmlspecialchars($pconfig['custom_options']);?></textarea><br/>
1387
										<?=gettext("Enter any additional options you would like to add to the OpenVPN server configuration here, separated by a semicolon"); ?><br/>
1388
										<?=gettext("EXAMPLE: push \"route 10.0.0.0 255.255.255.0\""); ?>;
1389
									</td>
1390
								</tr>
1391
							</table>
1392
						</td>
1393
					</tr>
1394
				</table>
1395

    
1396
				<br/>
1397

    
1398
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1399
					<tr>
1400
						<td width="22%" valign="top">&nbsp;</td>
1401
						<td width="78%"> 
1402
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>"> 
1403
							<input name="act" type="hidden" value="<?=$act;?>">
1404
							<?php if (isset($id) && $a_server[$id]): ?>
1405
							<input name="id" type="hidden" value="<?=$id;?>">
1406
							<?php endif; ?>
1407
						</td>
1408
					</tr>
1409
				</table>
1410
			</form>
1411

    
1412
			<?php else: ?>
1413

    
1414
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
1415
				<thead>
1416
				<tr>
1417
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
1418
					<td width="10%" class="listhdrr"><?=gettext("Protocol / Port"); ?></td>
1419
					<td width="30%" class="listhdrr"><?=gettext("Tunnel Network"); ?></td>
1420
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
1421
					<td width="10%" class="list"></td>
1422
				</tr>
1423
				</thead>
1424
				<tbody>
1425
				<?php
1426
					$i = 0;
1427
					foreach($a_server as $server):
1428
						$disabled = "NO";
1429
						if (isset($server['disable']))
1430
							$disabled = "YES";
1431
				?>
1432
				<tr>
1433
					<td class="listlr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1434
						<?=$disabled;?>
1435
					</td>
1436
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1437
						<?=htmlspecialchars($server['protocol']);?> / <?=htmlspecialchars($server['local_port']);?>
1438
					</td>
1439
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1440
						<?=htmlspecialchars($server['tunnel_network']);?>
1441
					</td>
1442
					<td class="listbg" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1443
						<?=htmlspecialchars($server['description']);?>
1444
					</td>
1445
					<td valign="middle" nowrap class="list">
1446
						<a href="vpn_openvpn_server.php?act=edit&id=<?=$i;?>">
1447
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit server"); ?>" width="17" height="17" border="0">
1448
						</a>
1449
						&nbsp;
1450
						<a href="vpn_openvpn_server.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this server?"); ?>')">
1451
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete server"); ?>" width="17" height="17" border="0">
1452
						</a>
1453
					</td>
1454
				</tr>
1455
				<?php
1456
					$i++;
1457
					endforeach;
1458
				?>
1459
				</tbody>
1460
				<tfoot>
1461
				<tr>
1462
					<td class="list" colspan="4"></td>
1463
					<td class="list">
1464
						<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">
1465
						</a>
1466
					</td>
1467
				</tr>
1468
				</tfoot>
1469
			</table>
1470

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

    
1473
			<?php endif; ?>
1474

    
1475
		</td>
1476
	</tr>
1477
</table>
1478
<script language="JavaScript">
1479
<!--
1480
mode_change();
1481
autokey_change();
1482
tlsauth_change();
1483
gwredir_change();
1484
dns_domain_change();
1485
dns_server_change();
1486
wins_server_change();
1487
ntp_server_change();
1488
netbios_change();
1489
//-->
1490
</script>
1491
</body>
1492
<?php include("fend.inc"); ?>
1493

    
1494
<?php
1495

    
1496
/* local utility functions */
1497

    
1498
function set_checked($var,& $chk) {
1499
    if($var)
1500
        $chk = 'checked';
1501
    else
1502
        $chk = '';
1503
}
1504

    
1505
?>
(221-221/228)