Project

General

Profile

Download (67 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 (!isset($a_server[$id])) {
80
		pfSenseHeader("vpn_openvpn_server.php");
81
		exit;
82
	}
83
	if (!empty($a_server[$id]))
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
	list($iv_iface, $iv_ip) = explode ("|",$pconfig['interface']);
211
	if (is_ipaddrv4($iv_ip) && (stristr($pconfig['protocol'], "6") !== false)) {
212
		$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv6 protocol and an IPv4 IP address.");
213
	} elseif (is_ipaddrv6($iv_ip) && (stristr($pconfig['protocol'], "6") === false)) {
214
		$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv4 protocol and an IPv6 IP address.");
215
	} elseif ((stristr($pconfig['protocol'], "6") === false) && !get_interface_ip($iv_iface)) {
216
		$input_errors[] = gettext("An IPv4 protocol was selected, but the selected interface has no IPv4 address.");
217
	} elseif ((stristr($pconfig['protocol'], "6") !== false) && !get_interface_ipv6($iv_iface)) {
218
		$input_errors[] = gettext("An IPv6 protocol was selected, but the selected interface has no IPv6 address.");
219
	}
220

    
221
	if ($pconfig['mode'] != "p2p_shared_key")
222
		$tls_mode = true;
223
	else
224
		$tls_mode = false;
225

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

    
229
	/* input validation */
230
	if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
231
		$input_errors[] = $result;
232

    
233
	if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'Tunnel network'))
234
		$input_errors[] = $result;
235

    
236
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'Remote network'))
237
		$input_errors[] = $result;
238

    
239
	if ($result = openvpn_validate_cidr($pconfig['local_network'], 'Local network'))
240
		$input_errors[] = $result;
241

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

    
246
	if ($pconfig['autokey_enable'])
247
		$pconfig['shared_key'] = openvpn_create_key();
248

    
249
	if (!$tls_mode && !$pconfig['autokey_enable'])
250
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
251
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
252
			$input_errors[] = gettext("The field 'Shared Key' does not appear to be valid");
253

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

    
259
	if ($pconfig['dns_server_enable']) {
260
		if (!empty($pconfig['dns_server1']) && !is_ipaddr(trim($pconfig['dns_server1'])))
261
			$input_errors[] = gettext("The field 'DNS Server #1' must contain a valid IP address");
262
		if (!empty($pconfig['dns_server2']) && !is_ipaddr(trim($pconfig['dns_server2'])))
263
			$input_errors[] = gettext("The field 'DNS Server #2' must contain a valid IP address");
264
		if (!empty($pconfig['dns_server3']) && !is_ipaddr(trim($pconfig['dns_server3'])))
265
			$input_errors[] = gettext("The field 'DNS Server #3' must contain a valid IP address");
266
		if (!empty($pconfig['dns_server4']) && !is_ipaddr(trim($pconfig['dns_server4'])))
267
			$input_errors[] = gettext("The field 'DNS Server #4' must contain a valid IP address");
268
	}
269

    
270
	if ($pconfig['ntp_server_enable']) {
271
		if (!empty($pconfig['ntp_server1']) && !is_ipaddr(trim($pconfig['ntp_server1'])))
272
			$input_errors[] = gettext("The field 'NTP Server #1' must contain a valid IP address");
273
		if (!empty($pconfig['ntp_server2']) && !is_ipaddr(trim($pconfig['ntp_server2'])))
274
			$input_errors[] = gettext("The field 'NTP Server #2' must contain a valid IP address");
275
		if (!empty($pconfig['ntp_server3']) && !is_ipaddr(trim($pconfig['ntp_server3'])))
276
			$input_errors[] = gettext("The field 'NTP Server #3' must contain a valid IP address");
277
		if (!empty($pconfig['ntp_server4']) && !is_ipaddr(trim($pconfig['ntp_server4'])))
278
			$input_errors[] = gettext("The field 'NTP Server #4' must contain a valid IP address");
279
	}
280

    
281
	if ($pconfig['netbios_enable']) {
282
		if ($pconfig['wins_server_enable']) {
283
			if (!empty($pconfig['wins_server1']) && !is_ipaddr(trim($pconfig['wins_server1'])))
284
				$input_errors[] = gettext("The field 'WINS Server #1' must contain a valid IP address");
285
			if (!empty($pconfig['wins_server2']) && !is_ipaddr(trim($pconfig['wins_server2'])))
286
				$input_errors[] = gettext("The field 'WINS Server #2' must contain a valid IP address");
287
		}
288
		if ($pconfig['nbdd_server_enable'])
289
			if (!empty($pconfig['nbdd_server1']) && !is_ipaddr(trim($pconfig['nbdd_server1'])))
290
				$input_errors[] = gettext("The field 'NetBIOS Data Distribution Server #1' must contain a valid IP address");
291
	}
292

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

    
296
	/* If we are not in shared key mode, then we need the CA/Cert. */
297
	if ($pconfig['mode'] != "p2p_shared_key") {
298
		$reqdfields = explode(" ", "caref certref");
299
		$reqdfieldsn = array(gettext("Certificate Authority"),gettext("Certificate"));
300
	} elseif (!$pconfig['autokey_enable']) {
301
		/* We only need the shared key filled in if we are in shared key mode and autokey is not selected. */
302
		$reqdfields = array('shared_key');
303
		$reqdfieldsn = array(gettext('Shared key'));
304
	}
305

    
306
	if ($pconfig['dev_mode'] != "tap") {
307
		$reqdfields[] = 'tunnel_network';
308
		$reqdfieldsn[] = gettext('Tunnel network');
309
	} else {
310
		if ($pconfig['serverbridge_dhcp'] && $pconfig['tunnel_network'])
311
			$input_errors[] = gettext("Using a tunnel network and server bridge settings together is not allowed.");
312
		if (($pconfig['serverbridge_dhcp_start'] && !$pconfig['serverbridge_dhcp_end']) 
313
		|| (!$pconfig['serverbridge_dhcp_start'] && $pconfig['serverbridge_dhcp_end']))
314
			$input_errors[] = gettext("Server Bridge DHCP Start and End must both be empty, or defined.");
315
		if (($pconfig['serverbridge_dhcp_start'] && !is_ipaddrv4($pconfig['serverbridge_dhcp_start'])))
316
			$input_errors[] = gettext("Server Bridge DHCP Start must be an IPv4 address.");
317
		if (($pconfig['serverbridge_dhcp_end'] && !is_ipaddrv4($pconfig['serverbridge_dhcp_end'])))
318
			$input_errors[] = gettext("Server Bridge DHCP End must be an IPv4 address.");
319
		if (ip2ulong($pconfig['serverbridge_dhcp_start']) > ip2ulong($pconfig['serverbridge_dhcp_end']))
320
			$input_errors[] = gettext("The Server Bridge DHCP range is invalid (start higher than end).");
321
	}
322
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
323
	
324
	if (!$input_errors) {
325

    
326
		$server = array();
327

    
328
		if ($id && $pconfig['dev_mode'] <> $a_server[$id]['dev_mode'])
329
			openvpn_delete('server', $a_server[$id]);// delete(rename) old interface so a new TUN or TAP interface can be created.
330

    
331
		if ($vpnid)
332
			$server['vpnid'] = $vpnid;
333
		else
334
			$server['vpnid'] = openvpn_vpnid_next();
335

    
336
		if ($_POST['disable'] == "yes")
337
			$server['disable'] = true;
338
		$server['mode'] = $pconfig['mode'];
339
		if (!empty($pconfig['authmode']))
340
			$server['authmode'] = implode(",", $pconfig['authmode']);
341
		$server['protocol'] = $pconfig['protocol'];
342
		$server['dev_mode'] = $pconfig['dev_mode'];
343
		list($server['interface'], $server['ipaddr']) = explode ("|",$pconfig['interface']);
344
		$server['local_port'] = $pconfig['local_port'];
345
		$server['description'] = $pconfig['description'];
346
		$server['custom_options'] = str_replace("\r\n", "\n", $pconfig['custom_options']);
347

    
348
		if ($tls_mode) {
349
			if ($pconfig['tlsauth_enable']) {
350
				if ($pconfig['autotls_enable'])
351
					$pconfig['tls'] = openvpn_create_key();
352
				$server['tls'] = base64_encode($pconfig['tls']);
353
			}
354
			$server['caref'] = $pconfig['caref'];
355
			$server['crlref'] = $pconfig['crlref'];
356
			$server['certref'] = $pconfig['certref'];
357
			$server['dh_length'] = $pconfig['dh_length'];
358
			$server['cert_depth'] = $pconfig['cert_depth'];
359
			if ($pconfig['mode'] == "server_tls_user")
360
				$server['strictusercn'] = $pconfig['strictusercn'];
361
		} else {
362
			$server['shared_key'] = base64_encode($pconfig['shared_key']);
363
		}
364
		$server['crypto'] = $pconfig['crypto'];
365
		$server['engine'] = $pconfig['engine'];
366

    
367
		$server['tunnel_network'] = $pconfig['tunnel_network'];
368
		$server['tunnel_networkv6'] = $pconfig['tunnel_networkv6'];
369
		$server['remote_network'] = $pconfig['remote_network'];
370
		$server['remote_networkv6'] = $pconfig['remote_networkv6'];
371
		$server['gwredir'] = $pconfig['gwredir'];
372
		$server['local_network'] = $pconfig['local_network'];
373
		$server['local_networkv6'] = $pconfig['local_networkv6'];
374
		$server['maxclients'] = $pconfig['maxclients'];
375
		$server['compression'] = $pconfig['compression'];
376
		$server['passtos'] = $pconfig['passtos'];
377
		$server['client2client'] = $pconfig['client2client'];
378

    
379
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
380
		$server['pool_enable'] = $pconfig['pool_enable'];
381

    
382
		$server['serverbridge_dhcp'] = $pconfig['serverbridge_dhcp'];
383
		$server['serverbridge_interface'] = $pconfig['serverbridge_interface'];
384
		$server['serverbridge_dhcp_start'] = $pconfig['serverbridge_dhcp_start'];
385
		$server['serverbridge_dhcp_end'] = $pconfig['serverbridge_dhcp_end'];
386

    
387
		if ($pconfig['dns_domain_enable'])
388
			$server['dns_domain'] = $pconfig['dns_domain'];
389

    
390
		if ($pconfig['dns_server_enable']) {
391
			$server['dns_server1'] = $pconfig['dns_server1'];
392
			$server['dns_server2'] = $pconfig['dns_server2'];
393
			$server['dns_server3'] = $pconfig['dns_server3'];
394
			$server['dns_server4'] = $pconfig['dns_server4'];
395
		}
396

    
397
		if ($pconfig['ntp_server_enable']) {
398
			$server['ntp_server1'] = $pconfig['ntp_server1'];
399
			$server['ntp_server2'] = $pconfig['ntp_server2'];
400
		}
401

    
402
		$server['netbios_enable'] = $pconfig['netbios_enable'];
403
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
404
		$server['netbios_scope'] = $pconfig['netbios_scope'];
405

    
406
		if ($pconfig['netbios_enable']) {
407

    
408
			if ($pconfig['wins_server_enable']) {
409
				$server['wins_server1'] = $pconfig['wins_server1'];
410
				$server['wins_server2'] = $pconfig['wins_server2'];
411
			}
412

    
413
			if ($pconfig['dns_server_enable'])
414
				$server['nbdd_server1'] = $pconfig['nbdd_server1'];
415
		}
416

    
417
		if ($_POST['duplicate_cn'] == "yes")
418
			$server['duplicate_cn'] = true;
419

    
420
		if (isset($id) && $a_server[$id])
421
			$a_server[$id] = $server;
422
		else
423
			$a_server[] = $server;
424

    
425
		openvpn_resync('server', $server);
426
		write_config();
427
		
428
		header("Location: vpn_openvpn_server.php");
429
		exit;
430
	}
431
	if (!empty($pconfig['authmode']))
432
		$pconfig['authmode'] = implode(",", $pconfig['authmode']);
433
}
434
$pgtitle = array(gettext("OpenVPN"), gettext("Server"));
435
$shortcut_section = "openvpn";
436

    
437
include("head.inc");
438

    
439
?>
440

    
441
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
442
<?php include("fbegin.inc"); ?>
443
<script language="JavaScript">
444
<!--
445

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

    
530
function autokey_change() {
531

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

    
538
function tlsauth_change() {
539

    
540
<?php if (!$pconfig['tls']): ?>
541
	if (document.iform.tlsauth_enable.checked)
542
		document.getElementById("tlsauth_opts").style.display="";
543
	else
544
		document.getElementById("tlsauth_opts").style.display="none";
545
<?php endif; ?>
546

    
547
	autotls_change();
548
}
549

    
550
function autotls_change() {
551

    
552
<?php if (!$pconfig['tls']): ?>
553
	autocheck = document.iform.autotls_enable.checked;
554
<?php else: ?>
555
	autocheck = false;
556
<?php endif; ?>
557

    
558
	if (document.iform.tlsauth_enable.checked && !autocheck)
559
		document.getElementById("autotls_opts").style.display="";
560
	else
561
		document.getElementById("autotls_opts").style.display="none";
562
}
563

    
564
function gwredir_change() {
565

    
566
	if (document.iform.gwredir.checked) {
567
		document.getElementById("local_optsv4").style.display="none";
568
		document.getElementById("local_optsv6").style.display="none";
569
	} else {
570
		document.getElementById("local_optsv4").style.display="";
571
		document.getElementById("local_optsv6").style.display="";
572
	}
573
}
574

    
575
function dns_domain_change() {
576

    
577
	if (document.iform.dns_domain_enable.checked)
578
		document.getElementById("dns_domain_data").style.display="";
579
	else
580
		document.getElementById("dns_domain_data").style.display="none";
581
}
582

    
583
function dns_server_change() {
584

    
585
	if (document.iform.dns_server_enable.checked)
586
		document.getElementById("dns_server_data").style.display="";
587
	else
588
		document.getElementById("dns_server_data").style.display="none";
589
}
590

    
591
function wins_server_change() {
592

    
593
	if (document.iform.wins_server_enable.checked)
594
		document.getElementById("wins_server_data").style.display="";
595
	else
596
		document.getElementById("wins_server_data").style.display="none";
597
}
598

    
599
function ntp_server_change() {
600

    
601
	if (document.iform.ntp_server_enable.checked)
602
		document.getElementById("ntp_server_data").style.display="";
603
	else
604
		document.getElementById("ntp_server_data").style.display="none";
605
}
606

    
607
function netbios_change() {
608

    
609
	if (document.iform.netbios_enable.checked) {
610
		document.getElementById("netbios_data").style.display="";
611
		document.getElementById("wins_opts").style.display="";
612
	} else {
613
		document.getElementById("netbios_data").style.display="none";
614
		document.getElementById("wins_opts").style.display="none";
615
	}
616
}
617

    
618
function tuntap_change() {
619

    
620
	mindex = document.iform.mode.selectedIndex;
621
	mvalue = document.iform.mode.options[mindex].value;
622

    
623
	switch(mvalue) {
624
		case "p2p_tls":
625
		case "p2p_shared_key":
626
			p2p = true;
627
			break;
628
		default:
629
			p2p = false;
630
			break;
631
	}
632

    
633
	index = document.iform.dev_mode.selectedIndex;
634
	value = document.iform.dev_mode.options[index].value;
635
	switch(value) {
636
		case "tun":
637
			document.getElementById("ipv4_tunnel_network").className="vncellreq";
638
			document.getElementById("serverbridge_dhcp").style.display="none";
639
			document.getElementById("serverbridge_interface").style.display="none";
640
			document.getElementById("serverbridge_dhcp_start").style.display="none";
641
			document.getElementById("serverbridge_dhcp_end").style.display="none";
642
			break;
643
		case "tap":
644
			document.getElementById("ipv4_tunnel_network").className="vncell";
645
			if (!p2p) {
646
				document.getElementById("serverbridge_dhcp").style.display="";
647
				document.getElementById("serverbridge_interface").style.display="";
648
				document.getElementById("serverbridge_dhcp_start").style.display="";
649
				document.getElementById("serverbridge_dhcp_end").style.display="";
650
				if (document.iform.serverbridge_dhcp.checked) {
651
					document.iform.serverbridge_interface.disabled = false;
652
					document.iform.serverbridge_dhcp_start.disabled = false;
653
					document.iform.serverbridge_dhcp_end.disabled = false;
654
				} else {
655
					document.iform.serverbridge_interface.disabled = true;
656
					document.iform.serverbridge_dhcp_start.disabled = true;
657
					document.iform.serverbridge_dhcp_end.disabled = true;
658
				}
659
			} else {
660
				document.iform.serverbridge_dhcp.disabled = true;
661
				document.iform.serverbridge_interface.disabled = true;
662
				document.iform.serverbridge_dhcp_start.disabled = true;
663
				document.iform.serverbridge_dhcp_end.disabled = true;
664
			}
665
			break;
666
	}
667
}
668
//-->
669
</script>
670
<?php
671
if (!$savemsg)
672
	$savemsg = "";
673

    
674
if ($input_errors)
675
	print_input_errors($input_errors);
676
if ($savemsg)
677
	print_info_box_np($savemsg);
678
?>
679
<table width="100%" border="0" cellpadding="0" cellspacing="0">
680
	<tr>
681
		<td class="tabnavtbl">
682
			<ul id="tabnav">
683
			<?php 
684
				$tab_array = array();
685
				$tab_array[] = array(gettext("Server"), true, "vpn_openvpn_server.php");
686
				$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
687
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
688
				$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
689
				add_package_tabs("OpenVPN", $tab_array);
690
				display_top_tabs($tab_array);
691
			?>
692
			</ul>
693
		</td>
694
	</tr>    
695
	<tr>
696
		<td class="tabcont">
697

    
698
			<?php if($act=="new" || $act=="edit"): ?>
699

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

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

    
1599
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1600
					<tr>
1601
						<td colspan="2" class="list" height="12"></td>
1602
					</tr>
1603
					<tr>
1604
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
1605
					</tr>
1606
					<tr>
1607
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1608
						<td width="78%" class="vtable">
1609
							<table border="0" cellpadding="2" cellspacing="0">
1610
								<tr>
1611
									<td>
1612
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=htmlspecialchars($pconfig['custom_options']);?></textarea><br/>
1613
										<?=gettext("Enter any additional options you would like to add to the OpenVPN server configuration here, separated by a semicolon"); ?><br/>
1614
										<?=gettext("EXAMPLE: push \"route 10.0.0.0 255.255.255.0\""); ?>;
1615
									</td>
1616
								</tr>
1617
							</table>
1618
						</td>
1619
					</tr>
1620
				</table>
1621

    
1622
				<br/>
1623
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
1624
					<tr>
1625
						<td width="22%" valign="top">&nbsp;</td>
1626
						<td width="78%"> 
1627
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>"> 
1628
							<input name="act" type="hidden" value="<?=$act;?>">
1629
							<?php if (isset($id) && $a_server[$id]): ?>
1630
							<input name="id" type="hidden" value="<?=$id;?>">
1631
							<?php endif; ?>
1632
						</td>
1633
					</tr>
1634
				</table>
1635
			</form>
1636

    
1637
			<?php else: ?>
1638

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

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

    
1699
			<?php endif; ?>
1700

    
1701
		</td>
1702
	</tr>
1703
</table>
1704
<script language="JavaScript">
1705
<!--
1706
mode_change();
1707
autokey_change();
1708
tlsauth_change();
1709
gwredir_change();
1710
dns_domain_change();
1711
dns_server_change();
1712
wins_server_change();
1713
ntp_server_change();
1714
netbios_change();
1715
tuntap_change();
1716
//-->
1717
</script>
1718
</body>
1719
<?php include("fend.inc"); ?>
1720

    
1721
<?php
1722

    
1723
/* local utility functions */
1724

    
1725
function set_checked($var,& $chk) {
1726
    if($var)
1727
        $chk = 'checked';
1728
    else
1729
        $chk = '';
1730
}
1731

    
1732
?>
(242-242/249)