Project

General

Profile

Download (65.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
if (!is_array($config['openvpn']['openvpn-server']))
41
	$config['openvpn']['openvpn-server'] = array();
42

    
43
$a_server = &$config['openvpn']['openvpn-server'];
44

    
45
if (!is_array($config['ca']))
46
	$config['ca'] = array();
47

    
48
$a_ca =& $config['ca'];
49

    
50
if (!is_array($config['cert']))
51
	$config['cert'] = array();
52

    
53
$a_cert =& $config['cert'];
54

    
55
if (!is_array($config['crl']))
56
	$config['crl'] = array();
57

    
58
$a_crl =& $config['crl'];
59

    
60
foreach ($a_crl as $cid => $acrl)
61
	if (!isset($acrl['refid']))
62
		unset ($a_crl[$cid]);
63

    
64
$id = $_GET['id'];
65
if (isset($_POST['id']))
66
	$id = $_POST['id'];
67

    
68
$act = $_GET['act'];
69
if (isset($_POST['act']))
70
	$act = $_POST['act'];
71

    
72
if (isset($id) && $a_server[$id])
73
	$vpnid = $a_server[$id]['vpnid'];
74
else
75
	$vpnid = 0;
76

    
77
if ($_GET['act'] == "del") {
78

    
79
	if (!$a_server[$id]) {
80
		pfSenseHeader("vpn_openvpn_server.php");
81
		exit;
82
	}
83

    
84
	openvpn_delete('server', $a_server[$id]);
85
	unset($a_server[$id]);
86
	write_config();
87
	$savemsg = gettext("Server successfully deleted")."<br/>";
88
}
89

    
90
if($_GET['act']=="new"){
91
	$pconfig['autokey_enable'] = "yes";
92
	$pconfig['tlsauth_enable'] = "yes";
93
	$pconfig['autotls_enable'] = "yes";
94
	$pconfig['dh_length'] = 1024;
95
	$pconfig['dev_mode'] = "tun";
96
	$pconfig['interface'] = "wan";
97
	$pconfig['local_port'] = openvpn_port_next('UDP');
98
	$pconfig['pool_enable'] = "yes";
99
	$pconfig['cert_depth'] = 1;
100
}
101

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

    
104
	if (isset($id) && $a_server[$id]) {
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['remote_networkv6'] = $a_server[$id]['remote_networkv6'];
143
		$pconfig['gwredir'] = $a_server[$id]['gwredir'];
144
		$pconfig['local_network'] = $a_server[$id]['local_network'];
145
		$pconfig['local_networkv6'] = $a_server[$id]['local_networkv6'];
146
		$pconfig['maxclients'] = $a_server[$id]['maxclients'];
147
		$pconfig['compression'] = $a_server[$id]['compression'];
148
		$pconfig['passtos'] = $a_server[$id]['passtos'];
149
		$pconfig['client2client'] = $a_server[$id]['client2client'];
150

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
315
		$server = array();
316

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

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

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

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

    
365
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
366
		$server['pool_enable'] = $pconfig['pool_enable'];
367

    
368
		$server['serverbridge_dhcp'] = $pconfig['serverbridge_dhcp'];
369
		$server['serverbridge_interface'] = $pconfig['serverbridge_interface'];
370
		$server['serverbridge_dhcp_start'] = $pconfig['serverbridge_dhcp_start'];
371
		$server['serverbridge_dhcp_end'] = $pconfig['serverbridge_dhcp_end'];
372

    
373
		if ($pconfig['dns_domain_enable'])
374
			$server['dns_domain'] = $pconfig['dns_domain'];
375

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

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

    
388
		$server['netbios_enable'] = $pconfig['netbios_enable'];
389
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
390
		$server['netbios_scope'] = $pconfig['netbios_scope'];
391

    
392
		if ($pconfig['netbios_enable']) {
393

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

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

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

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

    
411
		openvpn_resync('server', $server);
412
		write_config();
413
		
414
		header("Location: vpn_openvpn_server.php");
415
		exit;
416
	}
417
	if (!empty($pconfig['authmode']))
418
		$pconfig['authmode'] = implode(",", $pconfig['authmode']);
419
}
420
$pgtitle = array(gettext("OpenVPN"), gettext("Server"));
421
$shortcut_section = "openvpn";
422

    
423
include("head.inc");
424

    
425
?>
426

    
427
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
428
<?php include("fbegin.inc"); ?>
429
<script language="JavaScript">
430
<!--
431

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

    
516
function autokey_change() {
517

    
518
	if (document.iform.autokey_enable.checked)
519
		document.getElementById("autokey_opts").style.display="none";
520
	else
521
		document.getElementById("autokey_opts").style.display="";
522
}
523

    
524
function tlsauth_change() {
525

    
526
<?php if (!$pconfig['tls']): ?>
527
	if (document.iform.tlsauth_enable.checked)
528
		document.getElementById("tlsauth_opts").style.display="";
529
	else
530
		document.getElementById("tlsauth_opts").style.display="none";
531
<?php endif; ?>
532

    
533
	autotls_change();
534
}
535

    
536
function autotls_change() {
537

    
538
<?php if (!$pconfig['tls']): ?>
539
	autocheck = document.iform.autotls_enable.checked;
540
<?php else: ?>
541
	autocheck = false;
542
<?php endif; ?>
543

    
544
	if (document.iform.tlsauth_enable.checked && !autocheck)
545
		document.getElementById("autotls_opts").style.display="";
546
	else
547
		document.getElementById("autotls_opts").style.display="none";
548
}
549

    
550
function gwredir_change() {
551

    
552
	if (document.iform.gwredir.checked) {
553
		document.getElementById("local_optsv4").style.display="none";
554
		document.getElementById("local_optsv6").style.display="none";
555
	} else {
556
		document.getElementById("local_optsv4").style.display="";
557
		document.getElementById("local_optsv6").style.display="";
558
	}
559
}
560

    
561
function dns_domain_change() {
562

    
563
	if (document.iform.dns_domain_enable.checked)
564
		document.getElementById("dns_domain_data").style.display="";
565
	else
566
		document.getElementById("dns_domain_data").style.display="none";
567
}
568

    
569
function dns_server_change() {
570

    
571
	if (document.iform.dns_server_enable.checked)
572
		document.getElementById("dns_server_data").style.display="";
573
	else
574
		document.getElementById("dns_server_data").style.display="none";
575
}
576

    
577
function wins_server_change() {
578

    
579
	if (document.iform.wins_server_enable.checked)
580
		document.getElementById("wins_server_data").style.display="";
581
	else
582
		document.getElementById("wins_server_data").style.display="none";
583
}
584

    
585
function ntp_server_change() {
586

    
587
	if (document.iform.ntp_server_enable.checked)
588
		document.getElementById("ntp_server_data").style.display="";
589
	else
590
		document.getElementById("ntp_server_data").style.display="none";
591
}
592

    
593
function netbios_change() {
594

    
595
	if (document.iform.netbios_enable.checked) {
596
		document.getElementById("netbios_data").style.display="";
597
		document.getElementById("wins_opts").style.display="";
598
	} else {
599
		document.getElementById("netbios_data").style.display="none";
600
		document.getElementById("wins_opts").style.display="none";
601
	}
602
}
603

    
604
function tuntap_change() {
605

    
606
	mindex = document.iform.mode.selectedIndex;
607
	mvalue = document.iform.mode.options[mindex].value;
608

    
609
	switch(mvalue) {
610
		case "p2p_tls":
611
		case "p2p_shared_key":
612
			p2p = true;
613
			break;
614
		default:
615
			p2p = false;
616
			break;
617
	}
618

    
619
	index = document.iform.dev_mode.selectedIndex;
620
	value = document.iform.dev_mode.options[index].value;
621
	switch(value) {
622
		case "tun":
623
			document.getElementById("ipv4_tunnel_network").className="vncellreq";
624
			document.getElementById("serverbridge_dhcp").style.display="none";
625
			document.getElementById("serverbridge_interface").style.display="none";
626
			document.getElementById("serverbridge_dhcp_start").style.display="none";
627
			document.getElementById("serverbridge_dhcp_end").style.display="none";
628
			break;
629
		case "tap":
630
			document.getElementById("ipv4_tunnel_network").className="vncell";
631
			if (!p2p) {
632
				document.getElementById("serverbridge_dhcp").style.display="";
633
				document.getElementById("serverbridge_interface").style.display="";
634
				document.getElementById("serverbridge_dhcp_start").style.display="";
635
				document.getElementById("serverbridge_dhcp_end").style.display="";
636
				if (document.iform.serverbridge_dhcp.checked) {
637
					document.iform.serverbridge_interface.disabled = false;
638
					document.iform.serverbridge_dhcp_start.disabled = false;
639
					document.iform.serverbridge_dhcp_end.disabled = false;
640
				} else {
641
					document.iform.serverbridge_interface.disabled = true;
642
					document.iform.serverbridge_dhcp_start.disabled = true;
643
					document.iform.serverbridge_dhcp_end.disabled = true;
644
				}
645
			} else {
646
				document.iform.serverbridge_dhcp.disabled = true;
647
				document.iform.serverbridge_interface.disabled = true;
648
				document.iform.serverbridge_dhcp_start.disabled = true;
649
				document.iform.serverbridge_dhcp_end.disabled = true;
650
			}
651
			break;
652
	}
653
}
654
//-->
655
</script>
656
<?php
657
if (!$savemsg)
658
	$savemsg = "";
659

    
660
if ($input_errors)
661
	print_input_errors($input_errors);
662
if ($savemsg)
663
	print_info_box_np($savemsg);
664
?>
665
<table width="100%" border="0" cellpadding="0" cellspacing="0">
666
	<tr>
667
		<td class="tabnavtbl">
668
			<ul id="tabnav">
669
			<?php 
670
				$tab_array = array();
671
				$tab_array[] = array(gettext("Server"), true, "vpn_openvpn_server.php");
672
				$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
673
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
674
				$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
675
				add_package_tabs("OpenVPN", $tab_array);
676
				display_top_tabs($tab_array);
677
			?>
678
			</ul>
679
		</td>
680
	</tr>    
681
	<tr>
682
		<td class="tabcont">
683

    
684
			<?php if($act=="new" || $act=="edit"): ?>
685

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

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

    
1586
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1587
					<tr>
1588
						<td colspan="2" class="list" height="12"></td>
1589
					</tr>
1590
					<tr>
1591
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
1592
					</tr>
1593
					<tr>
1594
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1595
						<td width="78%" class="vtable">
1596
							<table border="0" cellpadding="2" cellspacing="0">
1597
								<tr>
1598
									<td>
1599
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=htmlspecialchars($pconfig['custom_options']);?></textarea><br/>
1600
										<?=gettext("Enter any additional options you would like to add to the OpenVPN server configuration here, separated by a semicolon"); ?><br/>
1601
										<?=gettext("EXAMPLE: push \"route 10.0.0.0 255.255.255.0\""); ?>;
1602
									</td>
1603
								</tr>
1604
							</table>
1605
						</td>
1606
					</tr>
1607
				</table>
1608

    
1609
				<br/>
1610
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
1611
					<tr>
1612
						<td width="22%" valign="top">&nbsp;</td>
1613
						<td width="78%"> 
1614
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>"> 
1615
							<input name="act" type="hidden" value="<?=$act;?>">
1616
							<?php if (isset($id) && $a_server[$id]): ?>
1617
							<input name="id" type="hidden" value="<?=$id;?>">
1618
							<?php endif; ?>
1619
						</td>
1620
					</tr>
1621
				</table>
1622
			</form>
1623

    
1624
			<?php else: ?>
1625

    
1626
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
1627
				<thead>
1628
				<tr>
1629
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
1630
					<td width="10%" class="listhdrr"><?=gettext("Protocol / Port"); ?></td>
1631
					<td width="30%" class="listhdrr"><?=gettext("Tunnel Network"); ?></td>
1632
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
1633
					<td width="10%" class="list"></td>
1634
				</tr>
1635
				</thead>
1636
				<tbody>
1637
				<?php
1638
					$i = 0;
1639
					foreach($a_server as $server):
1640
						$disabled = "NO";
1641
						if (isset($server['disable']))
1642
							$disabled = "YES";
1643
				?>
1644
				<tr>
1645
					<td class="listlr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1646
						<?=$disabled;?>
1647
					</td>
1648
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1649
						<?=htmlspecialchars($server['protocol']);?> / <?=htmlspecialchars($server['local_port']);?>
1650
					</td>
1651
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1652
						<?=htmlspecialchars($server['tunnel_network']);?><br/>
1653
						<?=htmlspecialchars($server['tunnel_networkv6']);?><br/>
1654
					</td>
1655
					<td class="listbg" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1656
						<?=htmlspecialchars($server['description']);?>
1657
					</td>
1658
					<td valign="middle" nowrap class="list">
1659
						<a href="vpn_openvpn_server.php?act=edit&id=<?=$i;?>">
1660
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit server"); ?>" width="17" height="17" border="0">
1661
						</a>
1662
						&nbsp;
1663
						<a href="vpn_openvpn_server.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this server?"); ?>')">
1664
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete server"); ?>" width="17" height="17" border="0">
1665
						</a>
1666
					</td>
1667
				</tr>
1668
				<?php
1669
					$i++;
1670
					endforeach;
1671
				?>
1672
				</tbody>
1673
				<tfoot>
1674
				<tr>
1675
					<td class="list" colspan="4"></td>
1676
					<td class="list">
1677
						<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">
1678
						</a>
1679
					</td>
1680
				</tr>
1681
				</tfoot>
1682
			</table>
1683

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

    
1686
			<?php endif; ?>
1687

    
1688
		</td>
1689
	</tr>
1690
</table>
1691
<script language="JavaScript">
1692
<!--
1693
mode_change();
1694
autokey_change();
1695
tlsauth_change();
1696
gwredir_change();
1697
dns_domain_change();
1698
dns_server_change();
1699
wins_server_change();
1700
ntp_server_change();
1701
netbios_change();
1702
tuntap_change();
1703
//-->
1704
</script>
1705
</body>
1706
<?php include("fend.inc"); ?>
1707

    
1708
<?php
1709

    
1710
/* local utility functions */
1711

    
1712
function set_checked($var,& $chk) {
1713
    if($var)
1714
        $chk = 'checked';
1715
    else
1716
        $chk = '';
1717
}
1718

    
1719
?>
(243-243/250)