Project

General

Profile

Download (55.9 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
}
99

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

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

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

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

    
133
		$pconfig['tunnel_network'] = $a_server[$id]['tunnel_network'];
134
		$pconfig['tunnel_networkv6'] = $a_server[$id]['tunnel_networkv6'];
135
		$pconfig['remote_network'] = $a_server[$id]['remote_network'];
136
		$pconfig['gwredir'] = $a_server[$id]['gwredir'];
137
		$pconfig['local_network'] = $a_server[$id]['local_network'];
138
		$pconfig['local_networkv6'] = $a_server[$id]['local_networkv6'];
139
		$pconfig['maxclients'] = $a_server[$id]['maxclients'];
140
		$pconfig['compression'] = $a_server[$id]['compression'];
141
		$pconfig['passtos'] = $a_server[$id]['passtos'];
142
		$pconfig['client2client'] = $a_server[$id]['client2client'];
143

    
144
		$pconfig['dynamic_ip'] = $a_server[$id]['dynamic_ip'];
145
		$pconfig['pool_enable'] = $a_server[$id]['pool_enable'];
146

    
147
		$pconfig['dns_domain'] = $a_server[$id]['dns_domain'];
148
		if ($pconfig['dns_domain'])
149
			$pconfig['dns_domain_enable'] = true;
150

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

    
161
		$pconfig['ntp_server1'] = $a_server[$id]['ntp_server1'];
162
		$pconfig['ntp_server2'] = $a_server[$id]['ntp_server2'];
163
		if ($pconfig['ntp_server1'] ||
164
			$pconfig['ntp_server2'])
165
			$pconfig['ntp_server_enable'] = true;
166

    
167
		$pconfig['netbios_enable'] = $a_server[$id]['netbios_enable'];
168
		$pconfig['netbios_ntype'] = $a_server[$id]['netbios_ntype'];
169
		$pconfig['netbios_scope'] = $a_server[$id]['netbios_scope'];
170

    
171
		$pconfig['wins_server1'] = $a_server[$id]['wins_server1'];
172
		$pconfig['wins_server2'] = $a_server[$id]['wins_server2'];
173
		if ($pconfig['wins_server1'] ||
174
			$pconfig['wins_server2'])
175
			$pconfig['wins_server_enable'] = true;
176

    
177
		$pconfig['nbdd_server1'] = $a_server[$id]['nbdd_server1'];
178
		if ($pconfig['nbdd_server1'])
179
			$pconfig['nbdd_server_enable'] = true;
180

    
181
		// just in case the modes switch
182
		$pconfig['autokey_enable'] = "yes";
183
		$pconfig['autotls_enable'] = "yes";
184

    
185
		$pconfig['duplicate_cn'] = isset($a_server[$id]['duplicate_cn']);
186
	}
187
}
188

    
189
if ($_POST) {
190

    
191
	unset($input_errors);
192
	$pconfig = $_POST;
193

    
194
	if (isset($id) && $a_server[$id])
195
		$vpnid = $a_server[$id]['vpnid'];
196
	else
197
		$vpnid = 0;
198

    
199
	if ($pconfig['mode'] != "p2p_shared_key")
200
		$tls_mode = true;
201
	else
202
		$tls_mode = false;
203

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
291
		$server = array();
292

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

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

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

    
328
		$server['tunnel_network'] = $pconfig['tunnel_network'];
329
		$server['tunnel_networkv6'] = $pconfig['tunnel_networkv6'];
330
		$server['remote_network'] = $pconfig['remote_network'];
331
		$server['gwredir'] = $pconfig['gwredir'];
332
		$server['local_network'] = $pconfig['local_network'];
333
		$server['local_networkv6'] = $pconfig['local_networkv6'];
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

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

    
587
			<?php if($act=="new" || $act=="edit"): ?>
588

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

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

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

    
1393
				<br/>
1394

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

    
1409
			<?php else: ?>
1410

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

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

    
1471
			<?php endif; ?>
1472

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

    
1492
<?php
1493

    
1494
/* local utility functions */
1495

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

    
1503
?>
(226-226/233)