Project

General

Profile

Download (64.1 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['tunnel_networkv6'] = $a_server[$id]['tunnel_networkv6'];
140

    
141
		$pconfig['remote_network'] = $a_server[$id]['remote_network'];
142
		$pconfig['gwredir'] = $a_server[$id]['gwredir'];
143
		$pconfig['local_network'] = $a_server[$id]['local_network'];
144
		$pconfig['local_networkv6'] = $a_server[$id]['local_networkv6'];
145
		$pconfig['maxclients'] = $a_server[$id]['maxclients'];
146
		$pconfig['compression'] = $a_server[$id]['compression'];
147
		$pconfig['passtos'] = $a_server[$id]['passtos'];
148
		$pconfig['client2client'] = $a_server[$id]['client2client'];
149

    
150
		$pconfig['dynamic_ip'] = $a_server[$id]['dynamic_ip'];
151
		$pconfig['pool_enable'] = $a_server[$id]['pool_enable'];
152

    
153
		$pconfig['serverbridge_dhcp'] = $a_server[$id]['serverbridge_dhcp'];
154
		$pconfig['serverbridge_interface'] = $a_server[$id]['serverbridge_interface'];
155
		$pconfig['serverbridge_dhcp_start'] = $a_server[$id]['serverbridge_dhcp_start'];
156
		$pconfig['serverbridge_dhcp_end'] = $a_server[$id]['serverbridge_dhcp_end'];
157

    
158
		$pconfig['dns_domain'] = $a_server[$id]['dns_domain'];
159
		if ($pconfig['dns_domain'])
160
			$pconfig['dns_domain_enable'] = true;
161

    
162
		$pconfig['dns_server1'] = $a_server[$id]['dns_server1'];
163
		$pconfig['dns_server2'] = $a_server[$id]['dns_server2'];
164
		$pconfig['dns_server3'] = $a_server[$id]['dns_server3'];
165
		$pconfig['dns_server4'] = $a_server[$id]['dns_server4'];
166
		if ($pconfig['dns_server1'] ||
167
			$pconfig['dns_server2'] ||
168
			$pconfig['dns_server3'] ||
169
			$pconfig['dns_server4'])
170
			$pconfig['dns_server_enable'] = true;
171

    
172
		$pconfig['ntp_server1'] = $a_server[$id]['ntp_server1'];
173
		$pconfig['ntp_server2'] = $a_server[$id]['ntp_server2'];
174
		if ($pconfig['ntp_server1'] ||
175
			$pconfig['ntp_server2'])
176
			$pconfig['ntp_server_enable'] = true;
177

    
178
		$pconfig['netbios_enable'] = $a_server[$id]['netbios_enable'];
179
		$pconfig['netbios_ntype'] = $a_server[$id]['netbios_ntype'];
180
		$pconfig['netbios_scope'] = $a_server[$id]['netbios_scope'];
181

    
182
		$pconfig['wins_server1'] = $a_server[$id]['wins_server1'];
183
		$pconfig['wins_server2'] = $a_server[$id]['wins_server2'];
184
		if ($pconfig['wins_server1'] ||
185
			$pconfig['wins_server2'])
186
			$pconfig['wins_server_enable'] = true;
187

    
188
		$pconfig['nbdd_server1'] = $a_server[$id]['nbdd_server1'];
189
		if ($pconfig['nbdd_server1'])
190
			$pconfig['nbdd_server_enable'] = true;
191

    
192
		// just in case the modes switch
193
		$pconfig['autokey_enable'] = "yes";
194
		$pconfig['autotls_enable'] = "yes";
195

    
196
		$pconfig['duplicate_cn'] = isset($a_server[$id]['duplicate_cn']);
197
	}
198
}
199
if ($_POST) {
200

    
201
	unset($input_errors);
202
	$pconfig = $_POST;
203

    
204
	if (isset($id) && $a_server[$id])
205
		$vpnid = $a_server[$id]['vpnid'];
206
	else
207
		$vpnid = 0;
208

    
209
	if ($pconfig['mode'] != "p2p_shared_key")
210
		$tls_mode = true;
211
	else
212
		$tls_mode = false;
213

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

    
217
	/* input validation */
218
	if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
219
		$input_errors[] = $result;
220

    
221
	if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'Tunnel network'))
222
		$input_errors[] = $result;
223

    
224
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'Remote network'))
225
		$input_errors[] = $result;
226

    
227
	if ($result = openvpn_validate_cidr($pconfig['local_network'], 'Local network'))
228
		$input_errors[] = $result;
229

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

    
234
	if ($pconfig['autokey_enable'])
235
		$pconfig['shared_key'] = openvpn_create_key();
236

    
237
	if (!$tls_mode && !$pconfig['autokey_enable'])
238
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
239
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
240
			$input_errors[] = gettext("The field 'Shared Key' does not appear to be valid");
241

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

    
247
	if ($pconfig['dns_server_enable']) {
248
		if (!empty($pconfig['dns_server1']) && !is_ipaddr(trim($pconfig['dns_server1'])))
249
			$input_errors[] = gettext("The field 'DNS Server #1' must contain a valid IP address");
250
		if (!empty($pconfig['dns_server2']) && !is_ipaddr(trim($pconfig['dns_server2'])))
251
			$input_errors[] = gettext("The field 'DNS Server #2' must contain a valid IP address");
252
		if (!empty($pconfig['dns_server3']) && !is_ipaddr(trim($pconfig['dns_server3'])))
253
			$input_errors[] = gettext("The field 'DNS Server #3' must contain a valid IP address");
254
		if (!empty($pconfig['dns_server4']) && !is_ipaddr(trim($pconfig['dns_server4'])))
255
			$input_errors[] = gettext("The field 'DNS Server #4' must contain a valid IP address");
256
	}
257

    
258
	if ($pconfig['ntp_server_enable']) {
259
		if (!empty($pconfig['ntp_server1']) && !is_ipaddr(trim($pconfig['ntp_server1'])))
260
			$input_errors[] = gettext("The field 'NTP Server #1' must contain a valid IP address");
261
		if (!empty($pconfig['ntp_server2']) && !is_ipaddr(trim($pconfig['ntp_server2'])))
262
			$input_errors[] = gettext("The field 'NTP Server #2' must contain a valid IP address");
263
		if (!empty($pconfig['ntp_server3']) && !is_ipaddr(trim($pconfig['ntp_server3'])))
264
			$input_errors[] = gettext("The field 'NTP Server #3' must contain a valid IP address");
265
		if (!empty($pconfig['ntp_server4']) && !is_ipaddr(trim($pconfig['ntp_server4'])))
266
			$input_errors[] = gettext("The field 'NTP Server #4' must contain a valid IP address");
267
	}
268

    
269
	if ($pconfig['netbios_enable']) {
270
		if ($pconfig['wins_server_enable']) {
271
			if (!empty($pconfig['wins_server1']) && !is_ipaddr(trim($pconfig['wins_server1'])))
272
				$input_errors[] = gettext("The field 'WINS Server #1' must contain a valid IP address");
273
			if (!empty($pconfig['wins_server2']) && !is_ipaddr(trim($pconfig['wins_server2'])))
274
				$input_errors[] = gettext("The field 'WINS Server #2' must contain a valid IP address");
275
		}
276
		if ($pconfig['nbdd_server_enable'])
277
			if (!empty($pconfig['nbdd_server1']) && !is_ipaddr(trim($pconfig['nbdd_server1'])))
278
				$input_errors[] = gettext("The field 'NetBIOS Data Distribution Server #1' must contain a valid IP address");
279
	}
280

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

    
284
	/* If we are not in shared key mode, then we need the CA/Cert. */
285
	if ($pconfig['mode'] != "p2p_shared_key") {
286
		$reqdfields = explode(" ", "caref certref");
287
		$reqdfieldsn = array(gettext("Certificate Authority"),gettext("Certificate"));
288
	} elseif (!$pconfig['autokey_enable']) {
289
		/* We only need the shared key filled in if we are in shared key mode and autokey is not selected. */
290
		$reqdfields = array('shared_key');
291
		$reqdfieldsn = array(gettext('Shared key'));
292
	}
293

    
294
	if ($pconfig['dev_mode'] != "tap") {
295
		$reqdfields[] = 'tunnel_network';
296
		$reqdfieldsn[] = gettext('Tunnel network');
297
	} else {
298
		if ($pconfig['serverbridge_dhcp'] && $pconfig['tunnel_network'])
299
			$input_errors[] = gettext("Using a tunnel network and server bridge settings together is not allowed.");
300
		if (($pconfig['serverbridge_dhcp_start'] && !$pconfig['serverbridge_dhcp_end']) 
301
		|| (!$pconfig['serverbridge_dhcp_start'] && $pconfig['serverbridge_dhcp_end']))
302
			$input_errors[] = gettext("Server Bridge DHCP Start and End must both be empty, or defined.");
303
		if (($pconfig['serverbridge_dhcp_start'] && !is_ipaddrv4($pconfig['serverbridge_dhcp_start'])))
304
			$input_errors[] = gettext("Server Bridge DHCP Start must be an IPv4 address.");
305
		if (($pconfig['serverbridge_dhcp_end'] && !is_ipaddrv4($pconfig['serverbridge_dhcp_end'])))
306
			$input_errors[] = gettext("Server Bridge DHCP End must be an IPv4 address.");
307
		if (ip2ulong($pconfig['serverbridge_dhcp_start']) > ip2ulong($pconfig['serverbridge_dhcp_end']))
308
			$input_errors[] = gettext("The Server Bridge DHCP range is invalid (start higher than end).");
309
	}
310
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
311
	
312
	if (!$input_errors) {
313

    
314
		$server = array();
315

    
316
		if ($vpnid)
317
			$server['vpnid'] = $vpnid;
318
		else
319
			$server['vpnid'] = openvpn_vpnid_next();
320

    
321
		if ($_POST['disable'] == "yes")
322
			$server['disable'] = true;
323
		$server['mode'] = $pconfig['mode'];
324
		if (!empty($pconfig['authmode']))
325
			$server['authmode'] = implode(",", $pconfig['authmode']);
326
		$server['protocol'] = $pconfig['protocol'];
327
		$server['dev_mode'] = $pconfig['dev_mode'];
328
		list($server['interface'], $server['ipaddr']) = explode ("|",$pconfig['interface']);
329
		$server['local_port'] = $pconfig['local_port'];
330
		$server['description'] = $pconfig['description'];
331
		$server['custom_options'] = str_replace("\r\n", "\n", $pconfig['custom_options']);
332

    
333
		if ($tls_mode) {
334
			if ($pconfig['tlsauth_enable']) {
335
				if ($pconfig['autotls_enable'])
336
					$pconfig['tls'] = openvpn_create_key();
337
				$server['tls'] = base64_encode($pconfig['tls']);
338
			}
339
			$server['caref'] = $pconfig['caref'];
340
			$server['crlref'] = $pconfig['crlref'];
341
			$server['certref'] = $pconfig['certref'];
342
			$server['dh_length'] = $pconfig['dh_length'];
343
			$server['cert_depth'] = $pconfig['cert_depth'];
344
			if ($pconfig['mode'] == "server_tls_user")
345
				$server['strictusercn'] = $pconfig['strictusercn'];
346
		} else {
347
			$server['shared_key'] = base64_encode($pconfig['shared_key']);
348
		}
349
		$server['crypto'] = $pconfig['crypto'];
350
		$server['engine'] = $pconfig['engine'];
351

    
352
		$server['tunnel_network'] = $pconfig['tunnel_network'];
353
		$server['tunnel_networkv6'] = $pconfig['tunnel_networkv6'];
354
		$server['remote_network'] = $pconfig['remote_network'];
355
		$server['gwredir'] = $pconfig['gwredir'];
356
		$server['local_network'] = $pconfig['local_network'];
357
		$server['local_networkv6'] = $pconfig['local_networkv6'];
358
		$server['maxclients'] = $pconfig['maxclients'];
359
		$server['compression'] = $pconfig['compression'];
360
		$server['passtos'] = $pconfig['passtos'];
361
		$server['client2client'] = $pconfig['client2client'];
362

    
363
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
364
		$server['pool_enable'] = $pconfig['pool_enable'];
365

    
366
		$server['serverbridge_dhcp'] = $pconfig['serverbridge_dhcp'];
367
		$server['serverbridge_interface'] = $pconfig['serverbridge_interface'];
368
		$server['serverbridge_dhcp_start'] = $pconfig['serverbridge_dhcp_start'];
369
		$server['serverbridge_dhcp_end'] = $pconfig['serverbridge_dhcp_end'];
370

    
371
		if ($pconfig['dns_domain_enable'])
372
			$server['dns_domain'] = $pconfig['dns_domain'];
373

    
374
		if ($pconfig['dns_server_enable']) {
375
			$server['dns_server1'] = $pconfig['dns_server1'];
376
			$server['dns_server2'] = $pconfig['dns_server2'];
377
			$server['dns_server3'] = $pconfig['dns_server3'];
378
			$server['dns_server4'] = $pconfig['dns_server4'];
379
		}
380

    
381
		if ($pconfig['ntp_server_enable']) {
382
			$server['ntp_server1'] = $pconfig['ntp_server1'];
383
			$server['ntp_server2'] = $pconfig['ntp_server2'];
384
		}
385

    
386
		$server['netbios_enable'] = $pconfig['netbios_enable'];
387
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
388
		$server['netbios_scope'] = $pconfig['netbios_scope'];
389

    
390
		if ($pconfig['netbios_enable']) {
391

    
392
			if ($pconfig['wins_server_enable']) {
393
				$server['wins_server1'] = $pconfig['wins_server1'];
394
				$server['wins_server2'] = $pconfig['wins_server2'];
395
			}
396

    
397
			if ($pconfig['dns_server_enable'])
398
				$server['nbdd_server1'] = $pconfig['nbdd_server1'];
399
		}
400

    
401
		if ($_POST['duplicate_cn'] == "yes")
402
			$server['duplicate_cn'] = true;
403

    
404
		if (isset($id) && $a_server[$id])
405
			$a_server[$id] = $server;
406
		else
407
			$a_server[] = $server;
408

    
409
		openvpn_resync('server', $server);
410
		write_config();
411
		
412
		header("Location: vpn_openvpn_server.php");
413
		exit;
414
	}
415
	if (!empty($pconfig['authmode']))
416
		$pconfig['authmode'] = implode(",", $pconfig['authmode']);
417
}
418

    
419
include("head.inc");
420

    
421
?>
422

    
423
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
424
<?php include("fbegin.inc"); ?>
425
<script language="JavaScript">
426
<!--
427

    
428
function mode_change() {
429
	index = document.iform.mode.selectedIndex;
430
	value = document.iform.mode.options[index].value;
431
	switch(value) {
432
		case "p2p_tls":
433
		case "server_tls":
434
		case "server_user":
435
			document.getElementById("tls").style.display="";
436
			document.getElementById("tls_ca").style.display="";
437
			document.getElementById("tls_crl").style.display="";
438
			document.getElementById("tls_cert").style.display="";
439
			document.getElementById("tls_dh").style.display="";
440
			document.getElementById("cert_depth").style.display="";
441
			document.getElementById("strictusercn").style.display="none";
442
			document.getElementById("psk").style.display="none";
443
			break;
444
		case "server_tls_user":
445
			document.getElementById("tls").style.display="";
446
			document.getElementById("tls_ca").style.display="";
447
			document.getElementById("tls_crl").style.display="";
448
			document.getElementById("tls_cert").style.display="";
449
			document.getElementById("tls_dh").style.display="";
450
			document.getElementById("cert_depth").style.display="";
451
			document.getElementById("strictusercn").style.display="";
452
			document.getElementById("psk").style.display="none";
453
			break;
454
		case "p2p_shared_key":
455
			document.getElementById("tls").style.display="none";
456
			document.getElementById("tls_ca").style.display="none";
457
			document.getElementById("tls_crl").style.display="none";
458
			document.getElementById("tls_cert").style.display="none";
459
			document.getElementById("tls_dh").style.display="none";
460
			document.getElementById("cert_depth").style.display="none";
461
			document.getElementById("strictusercn").style.display="none";
462
			document.getElementById("psk").style.display="";
463
			break;
464
	}
465
	switch(value) {
466
		case "p2p_shared_key":
467
			document.getElementById("client_opts").style.display="none";
468
			document.getElementById("remote_opts").style.display="";
469
			document.getElementById("gwredir_opts").style.display="none";
470
			document.getElementById("local_opts").style.display="none";
471
			document.getElementById("authmodetr").style.display="none";
472
			document.getElementById("inter_client_communication").style.display="none";
473
			break;
474
		case "p2p_tls":
475
			document.getElementById("client_opts").style.display="none";
476
			document.getElementById("remote_opts").style.display="";
477
			document.getElementById("gwredir_opts").style.display="";
478
			document.getElementById("local_opts").style.display="";
479
			document.getElementById("authmodetr").style.display="none";
480
			document.getElementById("inter_client_communication").style.display="none";
481
			break;
482
		case "server_user":
483
                case "server_tls_user":
484
			document.getElementById("authmodetr").style.display="";
485
			document.getElementById("client_opts").style.display="";
486
			document.getElementById("remote_opts").style.display="none";
487
			document.getElementById("gwredir_opts").style.display="";
488
			document.getElementById("local_opts").style.display="";
489
			document.getElementById("inter_client_communication").style.display="";
490
			break;
491
		case "server_tls":
492
			document.getElementById("authmodetr").style.display="none";
493
		default:
494
			document.getElementById("client_opts").style.display="";
495
			document.getElementById("remote_opts").style.display="none";
496
			document.getElementById("gwredir_opts").style.display="";
497
			document.getElementById("local_opts").style.display="";
498
			document.getElementById("inter_client_communication").style.display="";
499
			break;
500
	}
501
	gwredir_change();
502
}
503

    
504
function autokey_change() {
505

    
506
	if (document.iform.autokey_enable.checked)
507
		document.getElementById("autokey_opts").style.display="none";
508
	else
509
		document.getElementById("autokey_opts").style.display="";
510
}
511

    
512
function tlsauth_change() {
513

    
514
<?php if (!$pconfig['tls']): ?>
515
	if (document.iform.tlsauth_enable.checked)
516
		document.getElementById("tlsauth_opts").style.display="";
517
	else
518
		document.getElementById("tlsauth_opts").style.display="none";
519
<?php endif; ?>
520

    
521
	autotls_change();
522
}
523

    
524
function autotls_change() {
525

    
526
<?php if (!$pconfig['tls']): ?>
527
	autocheck = document.iform.autotls_enable.checked;
528
<?php else: ?>
529
	autocheck = false;
530
<?php endif; ?>
531

    
532
	if (document.iform.tlsauth_enable.checked && !autocheck)
533
		document.getElementById("autotls_opts").style.display="";
534
	else
535
		document.getElementById("autotls_opts").style.display="none";
536
}
537

    
538
function gwredir_change() {
539

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

    
546
function dns_domain_change() {
547

    
548
	if (document.iform.dns_domain_enable.checked)
549
		document.getElementById("dns_domain_data").style.display="";
550
	else
551
		document.getElementById("dns_domain_data").style.display="none";
552
}
553

    
554
function dns_server_change() {
555

    
556
	if (document.iform.dns_server_enable.checked)
557
		document.getElementById("dns_server_data").style.display="";
558
	else
559
		document.getElementById("dns_server_data").style.display="none";
560
}
561

    
562
function wins_server_change() {
563

    
564
	if (document.iform.wins_server_enable.checked)
565
		document.getElementById("wins_server_data").style.display="";
566
	else
567
		document.getElementById("wins_server_data").style.display="none";
568
}
569

    
570
function ntp_server_change() {
571

    
572
	if (document.iform.ntp_server_enable.checked)
573
		document.getElementById("ntp_server_data").style.display="";
574
	else
575
		document.getElementById("ntp_server_data").style.display="none";
576
}
577

    
578
function netbios_change() {
579

    
580
	if (document.iform.netbios_enable.checked) {
581
		document.getElementById("netbios_data").style.display="";
582
		document.getElementById("wins_opts").style.display="";
583
	} else {
584
		document.getElementById("netbios_data").style.display="none";
585
		document.getElementById("wins_opts").style.display="none";
586
	}
587
}
588

    
589
function tuntap_change() {
590

    
591
	mindex = document.iform.mode.selectedIndex;
592
	mvalue = document.iform.mode.options[mindex].value;
593

    
594
	switch(mvalue) {
595
		case "p2p_tls":
596
		case "p2p_shared_key":
597
			p2p = true;
598
			break;
599
		default:
600
			p2p = false;
601
			break;
602
	}
603

    
604
	index = document.iform.dev_mode.selectedIndex;
605
	value = document.iform.dev_mode.options[index].value;
606
	switch(value) {
607
		case "tun":
608
			document.getElementById("ipv4_tunnel_network").className="vncellreq";
609
			document.getElementById("serverbridge_dhcp").style.display="none";
610
			document.getElementById("serverbridge_interface").style.display="none";
611
			document.getElementById("serverbridge_dhcp_start").style.display="none";
612
			document.getElementById("serverbridge_dhcp_end").style.display="none";
613
			break;
614
		case "tap":
615
			document.getElementById("ipv4_tunnel_network").className="vncell";
616
			if (!p2p) {
617
				document.getElementById("serverbridge_dhcp").style.display="";
618
				document.getElementById("serverbridge_interface").style.display="";
619
				document.getElementById("serverbridge_dhcp_start").style.display="";
620
				document.getElementById("serverbridge_dhcp_end").style.display="";
621
				if (document.iform.serverbridge_dhcp.checked) {
622
					document.iform.serverbridge_interface.disabled = false;
623
					document.iform.serverbridge_dhcp_start.disabled = false;
624
					document.iform.serverbridge_dhcp_end.disabled = false;
625
				} else {
626
					document.iform.serverbridge_interface.disabled = true;
627
					document.iform.serverbridge_dhcp_start.disabled = true;
628
					document.iform.serverbridge_dhcp_end.disabled = true;
629
				}
630
			} else {
631
				document.iform.serverbridge_dhcp.disabled = true;
632
				document.iform.serverbridge_interface.disabled = true;
633
				document.iform.serverbridge_dhcp_start.disabled = true;
634
				document.iform.serverbridge_dhcp_end.disabled = true;
635
			}
636
			break;
637
	}
638
}
639
//-->
640
</script>
641
<?php
642
if (!$savemsg)
643
	$savemsg = "";
644

    
645
if ($input_errors)
646
	print_input_errors($input_errors);
647
if ($savemsg)
648
	print_info_box_np($savemsg);
649
?>
650
<table width="100%" border="0" cellpadding="0" cellspacing="0">
651
	<tr>
652
		<td class="tabnavtbl">
653
			<ul id="tabnav">
654
			<?php 
655
				$tab_array = array();
656
				$tab_array[] = array(gettext("Server"), true, "vpn_openvpn_server.php");
657
				$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
658
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
659
				$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
660
				add_package_tabs("OpenVPN", $tab_array);
661
				display_top_tabs($tab_array);
662
			?>
663
			</ul>
664
		</td>
665
	</tr>    
666
	<tr>
667
		<td class="tabcont">
668

    
669
			<?php if($act=="new" || $act=="edit"): ?>
670

    
671
			<form action="vpn_openvpn_server.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
672
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
673
					<tr>
674
						<td colspan="2" valign="top" class="listtopic"><?=gettext("General information"); ?></td>
675
					</tr>
676
					<tr>
677
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td>
678
						<td width="78%" class="vtable">
679
							<table border="0" cellpadding="0" cellspacing="0">
680
								<tr>
681
									<td>
682
										<?php set_checked($pconfig['disable'],$chk); ?>
683
										<input name="disable" type="checkbox" value="yes" <?=$chk;?>/>
684
									</td>
685
									<td>
686
										&nbsp;
687
										<span class="vexpl">
688
											<strong><?=gettext("Disable this server"); ?></strong><br>
689
										</span>
690
									</td>
691
								</tr>
692
							</table>
693
							<?=gettext("Set this option to disable this server without removing it from the list"); ?>.
694
						</td>
695
					</tr>
696
					<tr>
697
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server Mode");?></td>
698
							<td width="78%" class="vtable">
699
							<select name='mode' id='mode' class="formselect" onchange='mode_change(); tuntap_change()'>
700
							<?php
701
								foreach ($openvpn_server_modes as $name => $desc):
702
									$selected = "";
703
									if ($pconfig['mode'] == $name)
704
										$selected = "selected";
705
							?>
706
								<option value="<?=$name;?>" <?=$selected;?>><?=$desc;?></option>
707
							<?php endforeach; ?>
708
							</select>
709
						</td>
710
					</tr>
711
					<tr id="authmodetr" style="display:none">
712
                                                <td width="22%" valign="top" class="vncellreq"><?=gettext("Backend for authentication");?></td>
713
                                                        <td width="78%" class="vtable">
714
                                                        <select name='authmode[]' id='authmode' class="formselect" multiple="true" size="<?php echo count($auth_servers); ?>">
715
							<?php $authmodes = explode(",", $pconfig['authmode']); ?>
716
                                                        <?php
717
								$auth_servers = auth_get_authserver_list();
718
                                                                foreach ($auth_servers as $auth_server):
719
                                                                        $selected = "";
720
                                                                        if (in_array($auth_server['name'], $authmodes))
721
                                                                                $selected = "selected";
722
                                                        ?>
723
                                                                <option value="<?=$auth_server['name'];?>" <?=$selected;?>><?=$auth_server['name'];?></option>
724
                                                        <?php 	endforeach; ?>
725
                                                        </select>
726
                                                </td>
727
                                        </tr>
728
					<tr>
729
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
730
							<td width="78%" class="vtable">
731
							<select name='protocol' class="formselect">
732
							<?php
733
								foreach ($openvpn_prots as $prot):
734
									$selected = "";
735
									if ($pconfig['protocol'] == $prot)
736
										$selected = "selected";
737
							?>
738
								<option value="<?=$prot;?>" <?=$selected;?>><?=$prot;?></option>
739
							<?php endforeach; ?>
740
							</select>
741
							</td>
742
					</tr>
743
					<tr>
744
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Device Mode"); ?></td>
745
						<td width="78%" class="vtable">
746
							<select name="dev_mode" class="formselect" onchange='tuntap_change()'>
747
                                                        <?php
748
                                                                foreach ($openvpn_dev_mode as $device):
749
                                                                       $selected = "";
750
                                                                       if (! empty($pconfig['dev_mode'])) {
751
                                                                               if ($pconfig['dev_mode'] == $device)
752
                                                                                       $selected = "selected";
753
                                                                       } else {
754
                                                                               if ($device == "tun")
755
                                                                                       $selected = "selected";
756
                                                                       }
757
                                                        ?>
758
                                                                <option value="<?=$device;?>" <?=$selected;?>><?=$device;?></option>
759
                                                        <?php endforeach; ?>
760
                                                        </select>
761
                                                        </td>
762
                                        </tr>
763
					<tr>
764
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
765
						<td width="78%" class="vtable">
766
							<select name="interface" class="formselect">
767
								<?php
768
									$interfaces = get_configured_interface_with_descr();
769
									$carplist = get_configured_carp_interface_list();
770
									foreach ($carplist as $cif => $carpip)
771
										$interfaces[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")";
772
									$aliaslist = get_configured_ip_aliases_list();
773
									foreach ($aliaslist as $aliasip => $aliasif)
774
										$interfaces[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
775
									$interfaces['any'] = "any";
776
									foreach ($interfaces as $iface => $ifacename):
777
										$selected = "";
778
										if ($iface == $pconfig['interface'])
779
											$selected = "selected";
780
								?>
781
									<option value="<?=$iface;?>" <?=$selected;?>>
782
										<?=htmlspecialchars($ifacename);?>
783
									</option>
784
								<?php endforeach; ?>
785
							</select> <br>
786
						</td>
787
					</tr>
788
					<tr>
789
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Local port");?></td>
790
						<td width="78%" class="vtable">
791
							<input name="local_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['local_port']);?>"/>
792
						</td>
793
					</tr>
794
					<tr> 
795
						<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
796
						<td width="78%" class="vtable"> 
797
							<input name="description" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['description']);?>">
798
							<br>
799
							<?=gettext("You may enter a description here for your reference (not parsed)"); ?>.
800
						</td>
801
					</tr>
802
					<tr>
803
						<td colspan="2" class="list" height="12"></td>
804
					</tr>
805
					<tr>
806
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Cryptographic Settings"); ?></td>
807
					</tr>
808
					<tr id="tls">
809
						<td width="22%" valign="top" class="vncellreq"><?=gettext("TLS Authentication"); ?></td>
810
						<td width="78%" class="vtable">
811
							<table border="0" cellpadding="2" cellspacing="0">
812
								<tr>
813
									<td>
814
										<?php set_checked($pconfig['tlsauth_enable'],$chk); ?>
815
										<input name="tlsauth_enable" id="tlsauth_enable" type="checkbox" value="yes" <?=$chk;?> onClick="tlsauth_change()">
816
									</td>
817
									<td>
818
										<span class="vexpl">
819
											<?=gettext("Enable authentication of TLS packets"); ?>.
820
										</span>
821
									</td>
822
								</tr>
823
							</table>
824
							<?php if (!$pconfig['tls']): ?>
825
							<table border="0" cellpadding="2" cellspacing="0" id='tlsauth_opts'>
826
								<tr>
827
									<td>
828
										<?php set_checked($pconfig['autotls_enable'],$chk); ?>
829
										<input name="autotls_enable" id="autotls_enable" type="checkbox" value="yes" <?=$chk;?> onClick="autotls_change()">
830
									</td>
831
									<td>
832
										<span class="vexpl">
833
											<?=gettext("Automatically generate a shared TLS authentication key"); ?>.
834
										</span>
835
									</td>
836
								</tr>
837
							</table>
838
							<?php endif; ?>
839
							<table border="0" cellpadding="2" cellspacing="0" id='autotls_opts'>
840
								<tr>
841
									<td>
842
										<textarea name="tls" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['tls']);?></textarea>
843
										<br/>
844
										<?=gettext("Paste your shared key here"); ?>.
845
									</td>
846
								</tr>
847
							</table>
848
						</td>
849
					</tr>
850
					<tr id="tls_ca">
851
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer Certificate Authority"); ?></td>
852
							<td width="78%" class="vtable">
853
							<?php if (count($a_ca)): ?>
854
							<select name='caref' class="formselect">
855
							<?php
856
								foreach ($a_ca as $ca):
857
									$selected = "";
858
									if ($pconfig['caref'] == $ca['refid'])
859
										$selected = "selected";
860
							?>
861
								<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['descr'];?></option>
862
							<?php endforeach; ?>
863
							</select>
864
							<?php else: ?>
865
								<b>No Certificate Authorities defined.</b> <br/>Create one under <a href="system_camanager.php">System &gt; Cert Manager</a>.
866
							<?php endif; ?>
867
							</td>
868
					</tr>
869
					<tr id="tls_crl">
870
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer Certificate Revocation List"); ?></td>
871
							<td width="78%" class="vtable">
872
							<?php if (count($a_crl)): ?>
873
							<select name='crlref' class="formselect">
874
								<option value="">None</option>
875
							<?php
876
								foreach ($a_crl as $crl):
877
									$selected = "";
878
									$caname = "";
879
									$ca = lookup_ca($crl['caref']);
880
									if ($ca) {
881
										$caname = " (CA: {$ca['descr']})";
882
										if ($pconfig['crlref'] == $crl['refid'])
883
											$selected = "selected";
884
									}
885
							?>
886
								<option value="<?=$crl['refid'];?>" <?=$selected;?>><?=$crl['descr'] . $caname;?></option>
887
							<?php endforeach; ?>
888
							</select>
889
							<?php else: ?>
890
								<b>No Certificate Revocation Lists (CRLs) defined.</b> <br/>Create one under <a href="system_crlmanager.php">System &gt; Cert Manager</a>.
891
							<?php endif; ?>
892
							</td>
893
					</tr>
894
					<tr id="tls_cert">
895
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server Certificate"); ?></td>
896
							<td width="78%" class="vtable">
897
							<?php if (count($a_cert)): ?>
898
							<select name='certref' class="formselect">
899
							<?php
900
							foreach ($a_cert as $cert):
901
								$selected = "";
902
								$caname = "";
903
								$inuse = "";
904
								$revoked = "";
905
								$ca = lookup_ca($cert['caref']);
906
								if ($ca)
907
									$caname = " (CA: {$ca['descr']})";
908
								if ($pconfig['certref'] == $cert['refid'])
909
									$selected = "selected";
910
								if (cert_in_use($cert['refid']))
911
									$inuse = " *In Use";
912
								if (is_cert_revoked($cert))
913
								$revoked = " *Revoked";
914
							?>
915
								<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['descr'] . $caname . $inuse . $revoked;?></option>
916
							<?php endforeach; ?>
917
							</select>
918
							<?php else: ?>
919
								<b>No Certificates defined.</b> <br/>Create one under <a href="system_certmanager.php">System &gt; Cert Manager</a>.
920
							<?php endif; ?>
921
						</td>
922
					</tr>
923
					<tr id="tls_dh">
924
						<td width="22%" valign="top" class="vncellreq"><?=gettext("DH Parameters Length"); ?></td>
925
						<td width="78%" class="vtable">
926
							<select name="dh_length" class="formselect">
927
								<?php
928
									foreach ($openvpn_dh_lengths as $length):
929
									$selected = '';
930
									if ($length == $pconfig['dh_length'])
931
										$selected = ' selected';
932
								?>
933
								<option<?=$selected?>><?=$length;?></option>
934
								<?php endforeach; ?>
935
							</select>
936
							<span class="vexpl">
937
								<?=gettext("bits"); ?>
938
							</span>
939
						</td>
940
					</tr>
941
					<tr id="psk">
942
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Shared Key"); ?></td>
943
						<td width="78%" class="vtable">
944
							<?php if (!$pconfig['shared_key']): ?>
945
							<table border="0" cellpadding="2" cellspacing="0">
946
								<tr>
947
									<td>
948
										<?php set_checked($pconfig['autokey_enable'],$chk); ?>
949
										<input name="autokey_enable" type="checkbox" value="yes" <?=$chk;?> onClick="autokey_change()">
950
									</td>
951
									<td>
952
										<span class="vexpl">
953
											<?=gettext("Automatically generate a shared key"); ?>.
954
										</span>
955
									</td>
956
								</tr>
957
							</table>
958
							<?php endif; ?>
959
							<table border="0" cellpadding="2" cellspacing="0" id='autokey_opts'>
960
								<tr>
961
									<td>
962
										<textarea name="shared_key" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['shared_key']);?></textarea>
963
										<br/>
964
										<?=gettext("Paste your shared key here"); ?>.
965
									</td>
966
								</tr>
967
							</table>
968
						</td>
969
					</tr>
970
					<tr>
971
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Encryption algorithm"); ?></td>
972
						<td width="78%" class="vtable">
973
							<select name="crypto" class="formselect">
974
								<?php
975
									$cipherlist = openvpn_get_cipherlist();
976
									foreach ($cipherlist as $name => $desc):
977
									$selected = '';
978
									if ($name == $pconfig['crypto'])
979
										$selected = ' selected';
980
								?>
981
								<option value="<?=$name;?>"<?=$selected?>>
982
									<?=htmlspecialchars($desc);?>
983
								</option>
984
								<?php endforeach; ?>
985
							</select>
986
						</td>
987
					</tr>
988
					<tr id="engine">
989
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Hardware Crypto"); ?></td>
990
						<td width="78%" class="vtable">
991
							<select name="engine" class="formselect">
992
								<?php
993
									$engines = openvpn_get_engines();
994
									foreach ($engines as $name => $desc):
995
									$selected = '';
996
									if ($name == $pconfig['engine'])
997
										$selected = ' selected';
998
								?>
999
								<option value="<?=$name;?>"<?=$selected?>>
1000
									<?=htmlspecialchars($desc);?>
1001
								</option>
1002
								<?php endforeach; ?>
1003
							</select>
1004
						</td>
1005
					</tr>
1006
					<tr id="cert_depth">
1007
						<td width="22%" valign="top" class="vncell"><?=gettext("Certificate Depth"); ?></td>
1008
						<td width="78%" class="vtable">
1009
							<table border="0" cellpadding="2" cellspacing="0">
1010
							<tr><td>
1011
							<select name="cert_depth" class="formselect">
1012
								<option value="">Do Not Check</option>
1013
								<?php
1014
									foreach ($openvpn_cert_depths as $depth => $depthdesc):
1015
									$selected = '';
1016
									if ($depth == $pconfig['cert_depth'])
1017
										$selected = ' selected';
1018
								?>
1019
								<option value="<?= $depth ?>" <?= $selected ?>><?= $depthdesc ?></option>
1020
								<?php endforeach; ?>
1021
							</select>
1022
							</td></tr>
1023
							<tr><td>
1024
							<span class="vexpl">
1025
								<?=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."); ?>
1026
							</span>
1027
							</td></tr>
1028
							</table>
1029
						</td>
1030
					</tr>
1031
					<tr id="strictusercn">
1032
						<td width="22%" valign="top" class="vncell"><?=gettext("Strict User/CN Matching"); ?></td>
1033
						<td width="78%" class="vtable">
1034
							<table border="0" cellpadding="2" cellspacing="0">
1035
								<tr>
1036
									<td>
1037
										<?php set_checked($pconfig['strictusercn'],$chk); ?>
1038
										<input name="strictusercn" type="checkbox" value="yes" <?=$chk;?>/>
1039
									</td>
1040
									<td>
1041
										<span class="vexpl">
1042
											<?=gettext("When authenticating users, enforce a match between the common name of the client certificate and the username given at login."); ?>
1043
										</span>
1044
									</td>
1045
								</tr>
1046
							</table>
1047
						</td>
1048
					</tr>
1049
					<tr>
1050
						<td colspan="2" class="list" height="12"></td>
1051
					</tr>
1052
					<tr>
1053
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Tunnel Settings"); ?></td>
1054
					</tr>
1055
					<tr>
1056
						<td width="22%" valign="top" class="vncellreq" id="ipv4_tunnel_network"><?=gettext("IPv4 Tunnel Network"); ?></td>
1057
						<td width="78%" class="vtable">
1058
							<input name="tunnel_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_network']);?>">
1059
							<br>
1060
							<?=gettext("This is the IPv4 virtual network used for private " .
1061
							"communications between this server and client " .
1062
							"hosts expressed using CIDR (eg. 10.0.8.0/24). " .
1063
							"The first network address will be assigned to " .
1064
							"the	server virtual interface. The remaining " .
1065
							"network addresses can optionally be assigned " .
1066
							"to connecting clients. (see Address Pool)"); ?>
1067
						</td>
1068
					</tr>
1069
					<tr>
1070
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Tunnel Network"); ?></td>
1071
						<td width="78%" class="vtable">
1072
							<input name="tunnel_networkv6" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_networkv6']);?>">
1073
							<br>
1074
							<?=gettext("This is the IPv6 virtual network used for private " .
1075
							"communications between this server and client " .
1076
							"hosts expressed using CIDR (eg. fe80::/64). " .
1077
							"The first network address will be assigned to " .
1078
							"the	server virtual interface. The remaining " .
1079
							"network addresses can optionally be assigned " .
1080
							"to connecting clients. (see Address Pool)"); ?>
1081
						</td>
1082
					</tr>
1083
					<tr id="serverbridge_dhcp">
1084
						<td width="22%" valign="top" class="vncell"><?=gettext("Bridge DHCP"); ?></td>
1085
						<td width="78%" class="vtable">
1086
							<table border="0" cellpadding="2" cellspacing="0">
1087
								<tr>
1088
									<td>
1089
										<?php set_checked($pconfig['serverbridge_dhcp'],$chk); ?>
1090
										<input name="serverbridge_dhcp" type="checkbox" value="yes" <?=$chk;?> onchange='tuntap_change()' />
1091
									</td>
1092
									<td>
1093
										<span class="vexpl">
1094
											<?=gettext("Allow clients on the bridge to obtain DHCP."); ?><br>
1095
										</span>
1096
									</td>
1097
								</tr>
1098
							</table>
1099
						</td>
1100
					</tr>
1101
					<tr id="serverbridge_interface">
1102
						<td width="22%" valign="top" class="vncell"><?=gettext("Bridge Interface"); ?></td>
1103
						<td width="78%" class="vtable">
1104
							<select name="serverbridge_interface" class="formselect">
1105
								<?php
1106
									$serverbridge_interface['none'] = "none";
1107
									$serverbridge_interface = array_merge($serverbridge_interface, get_configured_interface_with_descr());
1108
									$carplist = get_configured_carp_interface_list();
1109
									foreach ($carplist as $cif => $carpip)
1110
										$serverbridge_interface[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")";
1111
									$aliaslist = get_configured_ip_aliases_list();
1112
									foreach ($aliaslist as $aliasip => $aliasif)
1113
										$serverbridge_interface[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
1114
									foreach ($serverbridge_interface as $iface => $ifacename):
1115
										$selected = "";
1116
										if ($iface == $pconfig['serverbridge_interface'])
1117
											$selected = "selected";
1118
								?>
1119
									<option value="<?=$iface;?>" <?=$selected;?>>
1120
										<?=htmlspecialchars($ifacename);?>
1121
									</option>
1122
								<?php endforeach; ?>
1123
							</select> <br>
1124
							<?=gettext("The interface to which this tap instance will be, " .
1125
							"bridged. This is not done automatically. You must assign this " .
1126
							"interface and create the bridge separately. " .
1127
							"This setting controls which existing IP address and subnet " .
1128
							"mask are used by OpenVPN for the bridge. Setting this to " .
1129
							"'none' will cause the Server Bridge DHCP settings below to be ignored."); ?>
1130
						</td>
1131
					</tr>
1132
					<tr id="serverbridge_dhcp_start">
1133
						<td width="22%" valign="top" class="vncell"><?=gettext("Server Bridge DHCP Start"); ?></td>
1134
						<td width="78%" class="vtable">
1135
							<input name="serverbridge_dhcp_start" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['serverbridge_dhcp_start']);?>">
1136
							<br>
1137
							<?=gettext("When using tap mode as multi-point server, " .
1138
							"you may optionally supply a DHCP range to use on the " .
1139
							"interface to which this tap instance is bridged. " .
1140
							"If these settings are left blank, DHCP will be passed " .
1141
							"through to the LAN, and the interface setting above " .
1142
							"will be ignored."); ?>
1143
						</td>
1144
					</tr>
1145
					<tr id="serverbridge_dhcp_end">
1146
						<td width="22%" valign="top" class="vncell"><?=gettext("Server Bridge DHCP End"); ?></td>
1147
						<td width="78%" class="vtable">
1148
							<input name="serverbridge_dhcp_end" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['serverbridge_dhcp_end']);?>">
1149
							<br>
1150
							<?=gettext(""); ?>
1151
						</td>
1152
					</tr>
1153
					<tr id="gwredir_opts">
1154
						<td width="22%" valign="top" class="vncell"><?=gettext("Redirect Gateway"); ?></td>
1155
						<td width="78%" class="vtable">
1156
							<table border="0" cellpadding="2" cellspacing="0">
1157
								<tr>
1158
									<td>
1159
										<?php set_checked($pconfig['gwredir'],$chk); ?>
1160
										<input name="gwredir" type="checkbox" value="yes" <?=$chk;?> onClick="gwredir_change()"/>
1161
									</td>
1162
									<td>
1163
										<span class="vexpl">
1164
											<?=gettext("Force all client generated traffic through the tunnel"); ?>.
1165
										</span>
1166
									</td>
1167
								</tr>
1168
							</table>
1169
						</td>
1170
					</tr>
1171
					<tr id="local_opts">
1172
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Local Network"); ?></td>
1173
						<td width="78%" class="vtable">
1174
							<input name="local_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['local_network']);?>">
1175
							<br>
1176
							<?=gettext("This is the network that will be accessible " .
1177
							"from the remote endpoint. Expressed as a CIDR " .
1178
							"range. You may leave this blank if you don't " .
1179
							"want to add a route to the local network " .
1180
							"through this tunnel on the remote machine. " .
1181
							"This is generally set to your LAN network"); ?>.
1182
						</td>
1183
					</tr>
1184
					<tr id="local_opts">
1185
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Local Network"); ?></td>
1186
						<td width="78%" class="vtable">
1187
							<input name="local_networkv6" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['local_networkv6']);?>">
1188
							<br>
1189
							<?=gettext("This is the IPv6 network that will be accessible " .
1190
							"from the remote endpoint. Expressed as a CIDR " .
1191
							"range. You may leave this blank if you don't " .
1192
							"want to add a route to the local network " .
1193
							"through this tunnel on the remote machine. " .
1194
							"This is generally set to your LAN network"); ?>.
1195
						</td>
1196
					</tr>
1197
					<tr id="remote_opts">
1198
						<td width="22%" valign="top" class="vncell"><?=gettext("Remote Network"); ?></td>
1199
						<td width="78%" class="vtable">
1200
							<input name="remote_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['remote_network']);?>">
1201
							<br>
1202
							<?=gettext("This is a network that will be routed through " .
1203
							"the tunnel, so that a site-to-site VPN can be " .
1204
							"established without manually changing the " .
1205
							"routing tables. Expressed as a CIDR range. If " .
1206
							"this is a site-to-site VPN, enter here the " .
1207
							"remote LAN here. You may leave this blank if " .
1208
							"you don't want a site-to-site VPN"); ?>.
1209
						</td>
1210
					</tr>
1211
					<tr>
1212
						<td width="22%" valign="top" class="vncell"><?=gettext("Concurrent connections");?></td>
1213
						<td width="78%" class="vtable">
1214
							<input name="maxclients" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['maxclients']);?>"/>
1215
							<br/>
1216
							<?=gettext("Specify the maximum number of clients allowed to concurrently connect to this server"); ?>.
1217
						</td>
1218
					</tr>
1219
					<tr>
1220
						<td width="22%" valign="top" class="vncell"><?=gettext("Compression"); ?></td>
1221
						<td width="78%" class="vtable">
1222
							<table border="0" cellpadding="2" cellspacing="0">
1223
								<tr>
1224
									<td>
1225
										<?php set_checked($pconfig['compression'],$chk); ?>
1226
										<input name="compression" type="checkbox" value="yes" <?=$chk;?>>
1227
									</td>
1228
									<td>
1229
										<span class="vexpl">
1230
											<?=gettext("Compress tunnel packets using the LZO algorithm"); ?>.
1231
										</span>
1232
									</td>
1233
								</tr>
1234
							</table>
1235
						</td>
1236
					</tr>
1237
					<tr>
1238
						<td width="22%" valign="top" class="vncell"><?=gettext("Type-of-Service"); ?></td>
1239
						<td width="78%" class="vtable">
1240
							<table border="0" cellpadding="2" cellspacing="0">
1241
								<tr>
1242
									<td>
1243
										<?php set_checked($pconfig['passtos'],$chk); ?>
1244
										<input name="passtos" type="checkbox" value="yes" <?=$chk;?>>
1245
									</td>
1246
									<td>
1247
										<span class="vexpl">
1248
											<?=gettext("Set the TOS IP header value of tunnel packets to match the encapsulated packet value"); ?>.
1249
										</span>
1250
									</td>
1251
								</tr>
1252
							</table>
1253
						</td>
1254
					</tr>
1255
					<tr id="inter_client_communication">
1256
						<td width="22%" valign="top" class="vncell"><?=gettext("Inter-client communication"); ?></td>
1257
						<td width="78%" class="vtable">
1258
							<table border="0" cellpadding="2" cellspacing="0">
1259
								<tr>
1260
									<td>
1261
										<?php set_checked($pconfig['client2client'],$chk); ?>
1262
										<input name="client2client" type="checkbox" value="yes" <?=$chk;?>/>
1263
									</td>
1264
									<td>
1265
										<span class="vexpl">
1266
											<?=gettext("Allow communication between clients connected to this server"); ?>
1267
										</span>
1268
									</td>
1269
								</tr>
1270
							</table>
1271
						</td>
1272
					</tr>
1273
					<tr id="duplicate_cn">
1274
						<td width="22%" valign="top" class="vncell"><?=gettext("Duplicate Connections"); ?></td>
1275
						<td width="78%" class="vtable">
1276
							<table border="0" cellpadding="2" cellspacing="0">
1277
								<tr>
1278
									<td>
1279
										<?php set_checked($pconfig['duplicate_cn'],$chk); ?>
1280
										<input name="duplicate_cn" type="checkbox" value="yes" <?=$chk;?>/>
1281
									</td>
1282
									<td>
1283
										<span class="vexpl">
1284
											<?=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."); ?>
1285
										</span>
1286
									</td>
1287
								</tr>
1288
							</table>
1289
						</td>
1290
					</tr>
1291
				</table>
1292

    
1293
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1294
					<tr>
1295
						<td colspan="2" class="list" height="12"></td>
1296
					</tr>
1297
					<tr>
1298
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Client Settings"); ?></td>
1299
					</tr>
1300
					<tr>
1301
						<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic IP"); ?></td>
1302
						<td width="78%" class="vtable">
1303
							<table border="0" cellpadding="2" cellspacing="0">
1304
								<tr>
1305
									<td>
1306
										<?php set_checked($pconfig['dynamic_ip'],$chk); ?>
1307
										<input name="dynamic_ip" type="checkbox" id="dynamic_ip" value="yes" <?=$chk;?>/>
1308
									</td>
1309
									<td>
1310
										<span class="vexpl">
1311
											<?=gettext("Allow connected clients to retain their connections if their IP address changes"); ?>.<br>
1312
										</span>
1313
									</td>
1314
								</tr>
1315
							</table>
1316
						</td>
1317
					</tr>
1318
					<tr>
1319
						<td width="22%" valign="top" class="vncell"><?=gettext("Address Pool"); ?></td>
1320
						<td width="78%" class="vtable">
1321
							<table border="0" cellpadding="2" cellspacing="0">
1322
								<tr>
1323
									<td>
1324
										<?php set_checked($pconfig['pool_enable'],$chk); ?>
1325
										<input name="pool_enable" type="checkbox" id="pool_enable" value="yes" <?=$chk;?>/>
1326
									</td>
1327
									<td>
1328
										<span class="vexpl">
1329
											<?=gettext("Provide a virtual adapter IP address to clients (see Tunnel Network)"); ?><br>
1330
										</span>
1331
									</td>
1332
								</tr>
1333
							</table>
1334
						</td>
1335
					</tr>
1336
					<tr>
1337
						<td width="22%" valign="top" class="vncell"><?=gettext("DNS Default Domain"); ?></td>
1338
						<td width="78%" class="vtable">
1339
							<table border="0" cellpadding="2" cellspacing="0">
1340
								<tr>
1341
									<td>
1342
										<?php set_checked($pconfig['dns_domain_enable'],$chk); ?>
1343
										<input name="dns_domain_enable" type="checkbox" id="dns_domain_enable" value="yes" <?=$chk;?> onClick="dns_domain_change()">
1344
									</td>
1345
									<td>
1346
										<span class="vexpl">
1347
	                                        <?=gettext("Provide a default domain name to clients"); ?><br>
1348
										</span>
1349
									</td>
1350
								</tr>
1351
							</table>
1352
							<table border="0" cellpadding="2" cellspacing="0" id="dns_domain_data">
1353
								<tr>
1354
									<td>
1355
										<input name="dns_domain" type="text" class="formfld unknown" id="dns_domain" size="30" value="<?=htmlspecialchars($pconfig['dns_domain']);?>">
1356
									</td>
1357
								</tr>
1358
							</table>
1359
						</td>
1360
					</tr>
1361
					<tr>
1362
						<td width="22%" valign="top" class="vncell"><?=gettext("DNS Servers"); ?></td>
1363
						<td width="78%" class="vtable">
1364
							<table border="0" cellpadding="2" cellspacing="0">
1365
								<tr>
1366
									<td>
1367
										<?php set_checked($pconfig['dns_server_enable'],$chk); ?>
1368
										<input name="dns_server_enable" type="checkbox" id="dns_server_enable" value="yes" <?=$chk;?> onClick="dns_server_change()">
1369
									</td>
1370
									<td>
1371
										<span class="vexpl">
1372
											<?=gettext("Provide a DNS server list to clients"); ?><br>
1373
										</span>
1374
									</td>
1375
								</tr>
1376
							</table>
1377
							<table border="0" cellpadding="2" cellspacing="0" id="dns_server_data">
1378
								<tr>
1379
									<td>
1380
										<span class="vexpl">
1381
											<?=gettext("Server"); ?> #1:&nbsp;
1382
										</span>
1383
										<input name="dns_server1" type="text" class="formfld unknown" id="dns_server1" size="20" value="<?=htmlspecialchars($pconfig['dns_server1']);?>">
1384
									</td>
1385
								</tr>
1386
								<tr>
1387
									<td>
1388
										<span class="vexpl">
1389
											<?=gettext("Server"); ?> #2:&nbsp;
1390
										</span>
1391
										<input name="dns_server2" type="text" class="formfld unknown" id="dns_server2" size="20" value="<?=htmlspecialchars($pconfig['dns_server2']);?>">
1392
									</td>
1393
								</tr>
1394
								<tr>
1395
									<td>
1396
										<span class="vexpl">
1397
											<?=gettext("Server"); ?> #3:&nbsp;
1398
										</span>
1399
										<input name="dns_server3" type="text" class="formfld unknown" id="dns_server3" size="20" value="<?=htmlspecialchars($pconfig['dns_server3']);?>">
1400
									</td>
1401
								</tr>
1402
								<tr>
1403
									<td>
1404
										<span class="vexpl">
1405
											<?=gettext("Server"); ?> #4:&nbsp;
1406
										</span>
1407
										<input name="dns_server4" type="text" class="formfld unknown" id="dns_server4" size="20" value="<?=htmlspecialchars($pconfig['dns_server4']);?>">
1408
									</td>
1409
								</tr>
1410
							</table>
1411
						</td>
1412
					</tr>
1413
					<tr>
1414
						<td width="22%" valign="top" class="vncell"><?=gettext("NTP Servers"); ?></td>
1415
						<td width="78%" class="vtable">
1416
							<table border="0" cellpadding="2" cellspacing="0">
1417
								<tr>
1418
									<td>
1419
										<?php set_checked($pconfig['ntp_server_enable'],$chk); ?>
1420
										<input name="ntp_server_enable" type="checkbox" id="ntp_server_enable" value="yes" <?=$chk;?> onClick="ntp_server_change()">
1421
									</td>
1422
									<td>
1423
										<span class="vexpl">
1424
											<?=gettext("Provide a NTP server list to clients"); ?><br>
1425
										</span>
1426
									</td>
1427
								</tr>
1428
							</table>
1429
							<table border="0" cellpadding="2" cellspacing="0" id="ntp_server_data">
1430
								<tr>
1431
									<td>
1432
										<span class="vexpl">
1433
											<?=gettext("Server"); ?> #1:&nbsp;
1434
										</span>
1435
										<input name="ntp_server1" type="text" class="formfld unknown" id="ntp_server1" size="20" value="<?=htmlspecialchars($pconfig['ntp_server1']);?>">
1436
									</td>
1437
								</tr>
1438
								<tr>
1439
									<td>
1440
										<span class="vexpl">
1441
											<?=gettext("Server"); ?> #2:&nbsp;
1442
										</span>
1443
										<input name="ntp_server2" type="text" class="formfld unknown" id="ntp_server2" size="20" value="<?=htmlspecialchars($pconfig['ntp_server2']);?>">
1444
									</td>
1445
								</tr>
1446
							</table>
1447
						</td>
1448
					</tr>
1449
					<tr>
1450
						<td width="22%" valign="top" class="vncell"><?=gettext("NetBIOS Options"); ?></td>
1451
						<td width="78%" class="vtable">
1452
							<table border="0" cellpadding="2" cellspacing="0">
1453
								<tr>
1454
									<td>
1455
										<?php set_checked($pconfig['netbios_enable'],$chk); ?>
1456
										<input name="netbios_enable" type="checkbox" id="netbios_enable" value="yes" <?=$chk;?> onClick="netbios_change()">
1457
									</td>
1458
									<td>
1459
										<span class="vexpl">
1460
											<?=gettext("Enable NetBIOS over TCP/IP"); ?><br>
1461
										</span>
1462
									</td>
1463
								</tr>
1464
							</table>
1465
							<?=gettext("If this option is not set, all NetBIOS-over-TCP/IP options (including WINS) will be disabled"); ?>.
1466
							<br/>
1467
							<table border="0" cellpadding="2" cellspacing="0" id="netbios_data">
1468
								<tr>
1469
									<td>
1470
										<br/>
1471
										<span class="vexpl">
1472
											<?=gettext("Node Type"); ?>:&nbsp;
1473
										</span>
1474
										<select name='netbios_ntype' class="formselect">
1475
										<?php
1476
											foreach ($netbios_nodetypes as $type => $name):
1477
												$selected = "";
1478
												if ($pconfig['netbios_ntype'] == $type)
1479
													$selected = "selected";
1480
										?>
1481
											<option value="<?=$type;?>" <?=$selected;?>><?=$name;?></option>
1482
										<?php endforeach; ?>
1483
										</select>
1484
										<br/>
1485
										<?=gettext("Possible options: b-node (broadcasts), p-node " .
1486
										"(point-to-point name queries to a WINS server), " .
1487
										"m-node (broadcast then query name server), and " .
1488
										"h-node (query name server, then broadcast)"); ?>.
1489
									</td>
1490
								</tr>
1491
								<tr>
1492
									<td>
1493
										<br/>
1494
										<span class="vexpl">
1495
											<?=gettext("Scope ID"); ?>:&nbsp;
1496
										</span>
1497
										<input name="netbios_scope" type="text" class="formfld unknown" id="netbios_scope" size="30" value="<?=htmlspecialchars($pconfig['netbios_scope']);?>">
1498
										<br/>
1499
										<?=gettext("A NetBIOS Scope	ID provides an extended naming " .
1500
										"service for	NetBIOS over TCP/IP. The NetBIOS " .
1501
										"scope ID isolates NetBIOS traffic on a single " .
1502
										"network to only those nodes with the same " .
1503
										"NetBIOS scope ID"); ?>.
1504
									</td>
1505
								</tr>
1506
							</table>
1507
						</td>
1508
					</tr>
1509
					<tr id="wins_opts">
1510
						<td width="22%" valign="top" class="vncell"><?=gettext("WINS Servers"); ?></td>
1511
						<td width="78%" class="vtable">
1512
							<table border="0" cellpadding="2" cellspacing="0">
1513
								<tr>
1514
									<td>
1515
										<?php set_checked($pconfig['wins_server_enable'],$chk); ?>
1516
										<input name="wins_server_enable" type="checkbox" id="wins_server_enable" value="yes" <?=$chk;?> onClick="wins_server_change()">
1517
									</td>
1518
									<td>
1519
										<span class="vexpl">
1520
											<?=gettext("Provide a WINS server list to clients"); ?><br>
1521
										</span>
1522
									</td>
1523
								</tr>
1524
							</table>
1525
							<table border="0" cellpadding="2" cellspacing="0" id="wins_server_data">
1526
								<tr>
1527
									<td>
1528
										<span class="vexpl">
1529
											<?=gettext("Server"); ?> #1:&nbsp;
1530
										</span>
1531
										<input name="wins_server1" type="text" class="formfld unknown" id="wins_server1" size="20" value="<?=htmlspecialchars($pconfig['wins_server1']);?>">
1532
									</td>
1533
								</tr>
1534
								<tr>
1535
									<td>
1536
										<span class="vexpl">
1537
											<?=gettext("Server"); ?> #2:&nbsp;
1538
										</span>
1539
										<input name="wins_server2" type="text" class="formfld unknown" id="wins_server2" size="20" value="<?=htmlspecialchars($pconfig['wins_server2']);?>">
1540
									</td>
1541
								</tr>
1542
							</table>
1543
						</td>
1544
					</tr>
1545
				</table>
1546

    
1547
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1548
					<tr>
1549
						<td colspan="2" class="list" height="12"></td>
1550
					</tr>
1551
					<tr>
1552
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
1553
					</tr>
1554
					<tr>
1555
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1556
						<td width="78%" class="vtable">
1557
							<table border="0" cellpadding="2" cellspacing="0">
1558
								<tr>
1559
									<td>
1560
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=htmlspecialchars($pconfig['custom_options']);?></textarea><br/>
1561
										<?=gettext("Enter any additional options you would like to add to the OpenVPN server configuration here, separated by a semicolon"); ?><br/>
1562
										<?=gettext("EXAMPLE: push \"route 10.0.0.0 255.255.255.0\""); ?>;
1563
									</td>
1564
								</tr>
1565
							</table>
1566
						</td>
1567
					</tr>
1568
				</table>
1569

    
1570
				<br/>
1571

    
1572
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1573
					<tr>
1574
						<td width="22%" valign="top">&nbsp;</td>
1575
						<td width="78%"> 
1576
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>"> 
1577
							<input name="act" type="hidden" value="<?=$act;?>">
1578
							<?php if (isset($id) && $a_server[$id]): ?>
1579
							<input name="id" type="hidden" value="<?=$id;?>">
1580
							<?php endif; ?>
1581
						</td>
1582
					</tr>
1583
				</table>
1584
			</form>
1585

    
1586
			<?php else: ?>
1587

    
1588
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
1589
				<thead>
1590
				<tr>
1591
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
1592
					<td width="10%" class="listhdrr"><?=gettext("Protocol / Port"); ?></td>
1593
					<td width="30%" class="listhdrr"><?=gettext("Tunnel Network"); ?></td>
1594
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
1595
					<td width="10%" class="list"></td>
1596
				</tr>
1597
				</thead>
1598
				<tbody>
1599
				<?php
1600
					$i = 0;
1601
					foreach($a_server as $server):
1602
						$disabled = "NO";
1603
						if (isset($server['disable']))
1604
							$disabled = "YES";
1605
				?>
1606
				<tr>
1607
					<td class="listlr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1608
						<?=$disabled;?>
1609
					</td>
1610
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1611
						<?=htmlspecialchars($server['protocol']);?> / <?=htmlspecialchars($server['local_port']);?>
1612
					</td>
1613
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1614
						<?=htmlspecialchars($server['tunnel_network']);?><br/>
1615
						<?=htmlspecialchars($server['tunnel_networkv6']);?><br/>
1616
					</td>
1617
					<td class="listbg" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1618
						<?=htmlspecialchars($server['description']);?>
1619
					</td>
1620
					<td valign="middle" nowrap class="list">
1621
						<a href="vpn_openvpn_server.php?act=edit&id=<?=$i;?>">
1622
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit server"); ?>" width="17" height="17" border="0">
1623
						</a>
1624
						&nbsp;
1625
						<a href="vpn_openvpn_server.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this server?"); ?>')">
1626
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete server"); ?>" width="17" height="17" border="0">
1627
						</a>
1628
					</td>
1629
				</tr>
1630
				<?php
1631
					$i++;
1632
					endforeach;
1633
				?>
1634
				</tbody>
1635
				<tfoot>
1636
				<tr>
1637
					<td class="list" colspan="4"></td>
1638
					<td class="list">
1639
						<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">
1640
						</a>
1641
					</td>
1642
				</tr>
1643
				</tfoot>
1644
			</table>
1645

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

    
1648
			<?php endif; ?>
1649

    
1650
		</td>
1651
	</tr>
1652
</table>
1653
<script language="JavaScript">
1654
<!--
1655
mode_change();
1656
autokey_change();
1657
tlsauth_change();
1658
gwredir_change();
1659
dns_domain_change();
1660
dns_server_change();
1661
wins_server_change();
1662
ntp_server_change();
1663
netbios_change();
1664
tuntap_change();
1665
//-->
1666
</script>
1667
</body>
1668
<?php include("fend.inc"); ?>
1669

    
1670
<?php
1671

    
1672
/* local utility functions */
1673

    
1674
function set_checked($var,& $chk) {
1675
    if($var)
1676
        $chk = 'checked';
1677
    else
1678
        $chk = '';
1679
}
1680

    
1681
?>
(242-242/249)