Project

General

Profile

Download (72.3 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
if (is_numericint($_GET['id']))
65
	$id = $_GET['id'];
66
if (isset($_POST['id']) && is_numericint($_POST['id']))
67
	$id = $_POST['id'];
68

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

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

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

    
80
	if (!isset($a_server[$id])) {
81
		pfSenseHeader("vpn_openvpn_server.php");
82
		exit;
83
	}
84
	if (!empty($a_server[$id]))
85
		openvpn_delete('server', $a_server[$id]);
86
	unset($a_server[$id]);
87
	write_config();
88
	$savemsg = gettext("Server successfully deleted")."<br />";
89
}
90

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

    
105
if($_GET['act']=="edit"){
106

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

    
121
		if ($pconfig['mode'] != "p2p_shared_key") {
122
			if ($a_server[$id]['tls']) {
123
				$pconfig['tlsauth_enable'] = "yes";
124
				$pconfig['tls'] = base64_decode($a_server[$id]['tls']);
125
			}
126
			$pconfig['caref'] = $a_server[$id]['caref'];
127
			$pconfig['crlref'] = $a_server[$id]['crlref'];
128
			$pconfig['certref'] = $a_server[$id]['certref'];
129
			$pconfig['dh_length'] = $a_server[$id]['dh_length'];
130
			if (isset($a_server[$id]['cert_depth']))
131
				$pconfig['cert_depth'] = $a_server[$id]['cert_depth'];
132
			else
133
				$pconfig['cert_depth'] = 1;
134
			if ($pconfig['mode'] == "server_tls_user")
135
				$pconfig['strictusercn'] = $a_server[$id]['strictusercn'];
136
		} else
137
			$pconfig['shared_key'] = base64_decode($a_server[$id]['shared_key']);
138
		$pconfig['crypto'] = $a_server[$id]['crypto'];
139
		// OpenVPN Defaults to SHA1 if unset
140
		$pconfig['digest'] = !empty($a_server[$id]['digest']) ? $a_server[$id]['digest'] : "SHA1";
141
		$pconfig['engine'] = $a_server[$id]['engine'];
142

    
143
		$pconfig['tunnel_network'] = $a_server[$id]['tunnel_network'];
144
		$pconfig['tunnel_networkv6'] = $a_server[$id]['tunnel_networkv6'];
145

    
146
		$pconfig['remote_network'] = $a_server[$id]['remote_network'];
147
		$pconfig['remote_networkv6'] = $a_server[$id]['remote_networkv6'];
148
		$pconfig['gwredir'] = $a_server[$id]['gwredir'];
149
		$pconfig['local_network'] = $a_server[$id]['local_network'];
150
		$pconfig['local_networkv6'] = $a_server[$id]['local_networkv6'];
151
		$pconfig['maxclients'] = $a_server[$id]['maxclients'];
152
		$pconfig['compression'] = $a_server[$id]['compression'];
153
		$pconfig['passtos'] = $a_server[$id]['passtos'];
154
		$pconfig['client2client'] = $a_server[$id]['client2client'];
155

    
156
		$pconfig['dynamic_ip'] = $a_server[$id]['dynamic_ip'];
157
		$pconfig['pool_enable'] = $a_server[$id]['pool_enable'];
158
		$pconfig['topology_subnet'] = $a_server[$id]['topology_subnet'];
159

    
160
		$pconfig['serverbridge_dhcp'] = $a_server[$id]['serverbridge_dhcp'];
161
		$pconfig['serverbridge_interface'] = $a_server[$id]['serverbridge_interface'];
162
		$pconfig['serverbridge_dhcp_start'] = $a_server[$id]['serverbridge_dhcp_start'];
163
		$pconfig['serverbridge_dhcp_end'] = $a_server[$id]['serverbridge_dhcp_end'];
164

    
165
		$pconfig['dns_domain'] = $a_server[$id]['dns_domain'];
166
		if ($pconfig['dns_domain'])
167
			$pconfig['dns_domain_enable'] = true;
168

    
169
		$pconfig['dns_server1'] = $a_server[$id]['dns_server1'];
170
		$pconfig['dns_server2'] = $a_server[$id]['dns_server2'];
171
		$pconfig['dns_server3'] = $a_server[$id]['dns_server3'];
172
		$pconfig['dns_server4'] = $a_server[$id]['dns_server4'];
173
		if ($pconfig['dns_server1'] ||
174
			$pconfig['dns_server2'] ||
175
			$pconfig['dns_server3'] ||
176
			$pconfig['dns_server4'])
177
			$pconfig['dns_server_enable'] = true;
178

    
179
		$pconfig['ntp_server1'] = $a_server[$id]['ntp_server1'];
180
		$pconfig['ntp_server2'] = $a_server[$id]['ntp_server2'];
181
		if ($pconfig['ntp_server1'] ||
182
			$pconfig['ntp_server2'])
183
			$pconfig['ntp_server_enable'] = true;
184

    
185
		$pconfig['netbios_enable'] = $a_server[$id]['netbios_enable'];
186
		$pconfig['netbios_ntype'] = $a_server[$id]['netbios_ntype'];
187
		$pconfig['netbios_scope'] = $a_server[$id]['netbios_scope'];
188

    
189
		$pconfig['wins_server1'] = $a_server[$id]['wins_server1'];
190
		$pconfig['wins_server2'] = $a_server[$id]['wins_server2'];
191
		if ($pconfig['wins_server1'] ||
192
			$pconfig['wins_server2'])
193
			$pconfig['wins_server_enable'] = true;
194

    
195
		$pconfig['client_mgmt_port'] = $a_server[$id]['client_mgmt_port'];
196
		if ($pconfig['client_mgmt_port'])
197
			$pconfig['client_mgmt_port_enable'] = true;
198

    
199
		$pconfig['nbdd_server1'] = $a_server[$id]['nbdd_server1'];
200
		if ($pconfig['nbdd_server1'])
201
			$pconfig['nbdd_server_enable'] = true;
202

    
203
		// just in case the modes switch
204
		$pconfig['autokey_enable'] = "yes";
205
		$pconfig['autotls_enable'] = "yes";
206

    
207
		$pconfig['duplicate_cn'] = isset($a_server[$id]['duplicate_cn']);
208
	}
209
}
210
if ($_POST) {
211

    
212
	unset($input_errors);
213
	$pconfig = $_POST;
214

    
215
	if (isset($id) && $a_server[$id])
216
		$vpnid = $a_server[$id]['vpnid'];
217
	else
218
		$vpnid = 0;
219

    
220
	list($iv_iface, $iv_ip) = explode ("|",$pconfig['interface']);
221
	if (is_ipaddrv4($iv_ip) && (stristr($pconfig['protocol'], "6") !== false)) {
222
		$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv6 protocol and an IPv4 IP address.");
223
	} elseif (is_ipaddrv6($iv_ip) && (stristr($pconfig['protocol'], "6") === false)) {
224
		$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv4 protocol and an IPv6 IP address.");
225
	} elseif ((stristr($pconfig['protocol'], "6") === false) && !get_interface_ip($iv_iface) && ($pconfig['interface'] != "any")) {
226
		$input_errors[] = gettext("An IPv4 protocol was selected, but the selected interface has no IPv4 address.");
227
	} elseif ((stristr($pconfig['protocol'], "6") !== false) && !get_interface_ipv6($iv_iface) && ($pconfig['interface'] != "any")) {
228
		$input_errors[] = gettext("An IPv6 protocol was selected, but the selected interface has no IPv6 address.");
229
	}
230

    
231
	if ($pconfig['mode'] != "p2p_shared_key")
232
		$tls_mode = true;
233
	else
234
		$tls_mode = false;
235

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

    
239
	/* input validation */
240
	if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
241
		$input_errors[] = $result;
242

    
243
	if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'IPv4 Tunnel Network', false, "ipv4"))
244
		$input_errors[] = $result;
245

    
246
	if ($result = openvpn_validate_cidr($pconfig['tunnel_networkv6'], 'IPv6 Tunnel Network', false, "ipv6"))
247
		$input_errors[] = $result;
248

    
249
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'IPv4 Remote Network', true, "ipv4"))
250
		$input_errors[] = $result;
251

    
252
	if ($result = openvpn_validate_cidr($pconfig['remote_networkv6'], 'IPv6 Remote Network', true, "ipv6"))
253
		$input_errors[] = $result;
254

    
255
	if ($result = openvpn_validate_cidr($pconfig['local_network'], 'IPv4 Local Network', true, "ipv4"))
256
		$input_errors[] = $result;
257

    
258
	if ($result = openvpn_validate_cidr($pconfig['local_networkv6'], 'IPv6 Local Network', true, "ipv6"))
259
		$input_errors[] = $result;
260

    
261
	$portused = openvpn_port_used($pconfig['protocol'], $pconfig['interface'], $pconfig['local_port'], $vpnid);
262
	if (($portused != $vpnid) && ($portused != 0))
263
		$input_errors[] = gettext("The specified 'Local port' is in use. Please select another value");
264

    
265
	if ($pconfig['autokey_enable'])
266
		$pconfig['shared_key'] = openvpn_create_key();
267

    
268
	if (!$tls_mode && !$pconfig['autokey_enable'])
269
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
270
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
271
			$input_errors[] = gettext("The field 'Shared Key' does not appear to be valid");
272

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

    
278
	if ($pconfig['dns_server_enable']) {
279
		if (!empty($pconfig['dns_server1']) && !is_ipaddr(trim($pconfig['dns_server1'])))
280
			$input_errors[] = gettext("The field 'DNS Server #1' must contain a valid IP address");
281
		if (!empty($pconfig['dns_server2']) && !is_ipaddr(trim($pconfig['dns_server2'])))
282
			$input_errors[] = gettext("The field 'DNS Server #2' must contain a valid IP address");
283
		if (!empty($pconfig['dns_server3']) && !is_ipaddr(trim($pconfig['dns_server3'])))
284
			$input_errors[] = gettext("The field 'DNS Server #3' must contain a valid IP address");
285
		if (!empty($pconfig['dns_server4']) && !is_ipaddr(trim($pconfig['dns_server4'])))
286
			$input_errors[] = gettext("The field 'DNS Server #4' must contain a valid IP address");
287
	}
288

    
289
	if ($pconfig['ntp_server_enable']) {
290
		if (!empty($pconfig['ntp_server1']) && !is_ipaddr(trim($pconfig['ntp_server1'])))
291
			$input_errors[] = gettext("The field 'NTP Server #1' must contain a valid IP address");
292
		if (!empty($pconfig['ntp_server2']) && !is_ipaddr(trim($pconfig['ntp_server2'])))
293
			$input_errors[] = gettext("The field 'NTP Server #2' must contain a valid IP address");
294
		if (!empty($pconfig['ntp_server3']) && !is_ipaddr(trim($pconfig['ntp_server3'])))
295
			$input_errors[] = gettext("The field 'NTP Server #3' must contain a valid IP address");
296
		if (!empty($pconfig['ntp_server4']) && !is_ipaddr(trim($pconfig['ntp_server4'])))
297
			$input_errors[] = gettext("The field 'NTP Server #4' must contain a valid IP address");
298
	}
299

    
300
	if ($pconfig['netbios_enable']) {
301
		if ($pconfig['wins_server_enable']) {
302
			if (!empty($pconfig['wins_server1']) && !is_ipaddr(trim($pconfig['wins_server1'])))
303
				$input_errors[] = gettext("The field 'WINS Server #1' must contain a valid IP address");
304
			if (!empty($pconfig['wins_server2']) && !is_ipaddr(trim($pconfig['wins_server2'])))
305
				$input_errors[] = gettext("The field 'WINS Server #2' must contain a valid IP address");
306
		}
307
		if ($pconfig['nbdd_server_enable'])
308
			if (!empty($pconfig['nbdd_server1']) && !is_ipaddr(trim($pconfig['nbdd_server1'])))
309
				$input_errors[] = gettext("The field 'NetBIOS Data Distribution Server #1' must contain a valid IP address");
310
	}
311

    
312
	if ($pconfig['client_mgmt_port_enable']) {
313
		if ($result = openvpn_validate_port($pconfig['client_mgmt_port'], 'Client management port'))
314
			$input_errors[] = $result;
315
	}
316

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

    
320
	/* If we are not in shared key mode, then we need the CA/Cert. */
321
	if ($pconfig['mode'] != "p2p_shared_key") {
322
		$reqdfields = explode(" ", "caref certref");
323
		$reqdfieldsn = array(gettext("Certificate Authority"),gettext("Certificate"));
324
	} elseif (!$pconfig['autokey_enable']) {
325
		/* We only need the shared key filled in if we are in shared key mode and autokey is not selected. */
326
		$reqdfields = array('shared_key');
327
		$reqdfieldsn = array(gettext('Shared key'));
328
	}
329

    
330
	if ($pconfig['dev_mode'] != "tap") {
331
		$reqdfields[] = 'tunnel_network';
332
		$reqdfieldsn[] = gettext('Tunnel network');
333
	} else {
334
		if ($pconfig['serverbridge_dhcp'] && $pconfig['tunnel_network'])
335
			$input_errors[] = gettext("Using a tunnel network and server bridge settings together is not allowed.");
336
		if (($pconfig['serverbridge_dhcp_start'] && !$pconfig['serverbridge_dhcp_end']) 
337
		|| (!$pconfig['serverbridge_dhcp_start'] && $pconfig['serverbridge_dhcp_end']))
338
			$input_errors[] = gettext("Server Bridge DHCP Start and End must both be empty, or defined.");
339
		if (($pconfig['serverbridge_dhcp_start'] && !is_ipaddrv4($pconfig['serverbridge_dhcp_start'])))
340
			$input_errors[] = gettext("Server Bridge DHCP Start must be an IPv4 address.");
341
		if (($pconfig['serverbridge_dhcp_end'] && !is_ipaddrv4($pconfig['serverbridge_dhcp_end'])))
342
			$input_errors[] = gettext("Server Bridge DHCP End must be an IPv4 address.");
343
		if (ip2ulong($pconfig['serverbridge_dhcp_start']) > ip2ulong($pconfig['serverbridge_dhcp_end']))
344
			$input_errors[] = gettext("The Server Bridge DHCP range is invalid (start higher than end).");
345
	}
346
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
347
	
348
	if (!$input_errors) {
349

    
350
		$server = array();
351

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

    
355
		if ($vpnid)
356
			$server['vpnid'] = $vpnid;
357
		else
358
			$server['vpnid'] = openvpn_vpnid_next();
359

    
360
		if ($_POST['disable'] == "yes")
361
			$server['disable'] = true;
362
		$server['mode'] = $pconfig['mode'];
363
		if (!empty($pconfig['authmode']))
364
			$server['authmode'] = implode(",", $pconfig['authmode']);
365
		$server['protocol'] = $pconfig['protocol'];
366
		$server['dev_mode'] = $pconfig['dev_mode'];
367
		list($server['interface'], $server['ipaddr']) = explode ("|",$pconfig['interface']);
368
		$server['local_port'] = $pconfig['local_port'];
369
		$server['description'] = $pconfig['description'];
370
		$server['custom_options'] = str_replace("\r\n", "\n", $pconfig['custom_options']);
371

    
372
		if ($tls_mode) {
373
			if ($pconfig['tlsauth_enable']) {
374
				if ($pconfig['autotls_enable'])
375
					$pconfig['tls'] = openvpn_create_key();
376
				$server['tls'] = base64_encode($pconfig['tls']);
377
			}
378
			$server['caref'] = $pconfig['caref'];
379
			$server['crlref'] = $pconfig['crlref'];
380
			$server['certref'] = $pconfig['certref'];
381
			$server['dh_length'] = $pconfig['dh_length'];
382
			$server['cert_depth'] = $pconfig['cert_depth'];
383
			if ($pconfig['mode'] == "server_tls_user")
384
				$server['strictusercn'] = $pconfig['strictusercn'];
385
		} else {
386
			$server['shared_key'] = base64_encode($pconfig['shared_key']);
387
		}
388
		$server['crypto'] = $pconfig['crypto'];
389
		$server['digest'] = $pconfig['digest'];
390
		$server['engine'] = $pconfig['engine'];
391

    
392
		$server['tunnel_network'] = $pconfig['tunnel_network'];
393
		$server['tunnel_networkv6'] = $pconfig['tunnel_networkv6'];
394
		$server['remote_network'] = $pconfig['remote_network'];
395
		$server['remote_networkv6'] = $pconfig['remote_networkv6'];
396
		$server['gwredir'] = $pconfig['gwredir'];
397
		$server['local_network'] = $pconfig['local_network'];
398
		$server['local_networkv6'] = $pconfig['local_networkv6'];
399
		$server['maxclients'] = $pconfig['maxclients'];
400
		$server['compression'] = $pconfig['compression'];
401
		$server['passtos'] = $pconfig['passtos'];
402
		$server['client2client'] = $pconfig['client2client'];
403

    
404
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
405
		$server['pool_enable'] = $pconfig['pool_enable'];
406
		$server['topology_subnet'] = $pconfig['topology_subnet'];
407

    
408
		$server['serverbridge_dhcp'] = $pconfig['serverbridge_dhcp'];
409
		$server['serverbridge_interface'] = $pconfig['serverbridge_interface'];
410
		$server['serverbridge_dhcp_start'] = $pconfig['serverbridge_dhcp_start'];
411
		$server['serverbridge_dhcp_end'] = $pconfig['serverbridge_dhcp_end'];
412

    
413
		if ($pconfig['dns_domain_enable'])
414
			$server['dns_domain'] = $pconfig['dns_domain'];
415

    
416
		if ($pconfig['dns_server_enable']) {
417
			$server['dns_server1'] = $pconfig['dns_server1'];
418
			$server['dns_server2'] = $pconfig['dns_server2'];
419
			$server['dns_server3'] = $pconfig['dns_server3'];
420
			$server['dns_server4'] = $pconfig['dns_server4'];
421
		}
422

    
423
		if ($pconfig['ntp_server_enable']) {
424
			$server['ntp_server1'] = $pconfig['ntp_server1'];
425
			$server['ntp_server2'] = $pconfig['ntp_server2'];
426
		}
427

    
428
		$server['netbios_enable'] = $pconfig['netbios_enable'];
429
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
430
		$server['netbios_scope'] = $pconfig['netbios_scope'];
431

    
432
		if ($pconfig['netbios_enable']) {
433

    
434
			if ($pconfig['wins_server_enable']) {
435
				$server['wins_server1'] = $pconfig['wins_server1'];
436
				$server['wins_server2'] = $pconfig['wins_server2'];
437
			}
438

    
439
			if ($pconfig['dns_server_enable'])
440
				$server['nbdd_server1'] = $pconfig['nbdd_server1'];
441
		}
442

    
443
		if ($pconfig['client_mgmt_port_enable'])
444
			$server['client_mgmt_port'] = $pconfig['client_mgmt_port'];
445

    
446
		if ($_POST['duplicate_cn'] == "yes")
447
			$server['duplicate_cn'] = true;
448

    
449
		if (isset($id) && $a_server[$id])
450
			$a_server[$id] = $server;
451
		else
452
			$a_server[] = $server;
453

    
454
		openvpn_resync('server', $server);
455
		write_config();
456
		
457
		header("Location: vpn_openvpn_server.php");
458
		exit;
459
	}
460
	if (!empty($pconfig['authmode']))
461
		$pconfig['authmode'] = implode(",", $pconfig['authmode']);
462
}
463
$pgtitle = array(gettext("OpenVPN"), gettext("Server"));
464
$shortcut_section = "openvpn";
465

    
466
include("head.inc");
467

    
468
?>
469

    
470
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
471
<?php include("fbegin.inc"); ?>
472
<script language="JavaScript">
473
<!--
474

    
475
function mode_change() {
476
	index = document.iform.mode.selectedIndex;
477
	value = document.iform.mode.options[index].value;
478
	switch(value) {
479
		case "p2p_tls":
480
		case "server_tls":
481
		case "server_user":
482
			document.getElementById("tls").style.display="";
483
			document.getElementById("tls_ca").style.display="";
484
			document.getElementById("tls_crl").style.display="";
485
			document.getElementById("tls_cert").style.display="";
486
			document.getElementById("tls_dh").style.display="";
487
			document.getElementById("cert_depth").style.display="";
488
			document.getElementById("strictusercn").style.display="none";
489
			document.getElementById("psk").style.display="none";
490
			break;
491
		case "server_tls_user":
492
			document.getElementById("tls").style.display="";
493
			document.getElementById("tls_ca").style.display="";
494
			document.getElementById("tls_crl").style.display="";
495
			document.getElementById("tls_cert").style.display="";
496
			document.getElementById("tls_dh").style.display="";
497
			document.getElementById("cert_depth").style.display="";
498
			document.getElementById("strictusercn").style.display="";
499
			document.getElementById("psk").style.display="none";
500
			break;
501
		case "p2p_shared_key":
502
			document.getElementById("tls").style.display="none";
503
			document.getElementById("tls_ca").style.display="none";
504
			document.getElementById("tls_crl").style.display="none";
505
			document.getElementById("tls_cert").style.display="none";
506
			document.getElementById("tls_dh").style.display="none";
507
			document.getElementById("cert_depth").style.display="none";
508
			document.getElementById("strictusercn").style.display="none";
509
			document.getElementById("psk").style.display="";
510
			break;
511
	}
512
	switch(value) {
513
		case "p2p_shared_key":
514
			document.getElementById("client_opts").style.display="none";
515
			document.getElementById("remote_optsv4").style.display="";
516
			document.getElementById("remote_optsv6").style.display="";
517
			document.getElementById("gwredir_opts").style.display="none";
518
			document.getElementById("local_optsv4").style.display="none";
519
			document.getElementById("local_optsv6").style.display="none";
520
			document.getElementById("authmodetr").style.display="none";
521
			document.getElementById("inter_client_communication").style.display="none";
522
			break;
523
		case "p2p_tls":
524
			document.getElementById("client_opts").style.display="none";
525
			document.getElementById("remote_optsv4").style.display="";
526
			document.getElementById("remote_optsv6").style.display="";
527
			document.getElementById("gwredir_opts").style.display="";
528
			document.getElementById("local_optsv4").style.display="";
529
			document.getElementById("local_optsv6").style.display="";
530
			document.getElementById("authmodetr").style.display="none";
531
			document.getElementById("inter_client_communication").style.display="none";
532
			break;
533
		case "server_user":
534
                case "server_tls_user":
535
			document.getElementById("authmodetr").style.display="";
536
			document.getElementById("client_opts").style.display="";
537
			document.getElementById("remote_optsv4").style.display="none";
538
			document.getElementById("remote_optsv6").style.display="none";
539
			document.getElementById("gwredir_opts").style.display="";
540
			document.getElementById("local_optsv4").style.display="";
541
			document.getElementById("local_optsv6").style.display="";
542
			document.getElementById("inter_client_communication").style.display="";
543
			break;
544
		case "server_tls":
545
			document.getElementById("authmodetr").style.display="none";
546
		default:
547
			document.getElementById("client_opts").style.display="";
548
			document.getElementById("remote_optsv4").style.display="none";
549
			document.getElementById("remote_optsv6").style.display="none";
550
			document.getElementById("gwredir_opts").style.display="";
551
			document.getElementById("local_optsv4").style.display="";
552
			document.getElementById("local_optsv6").style.display="";
553
			document.getElementById("inter_client_communication").style.display="";
554
			break;
555
	}
556
	gwredir_change();
557
}
558

    
559
function autokey_change() {
560

    
561
	if ((document.iform.autokey_enable != null) && (document.iform.autokey_enable.checked))
562
		document.getElementById("autokey_opts").style.display="none";
563
	else
564
		document.getElementById("autokey_opts").style.display="";
565
}
566

    
567
function tlsauth_change() {
568

    
569
<?php if (!$pconfig['tls']): ?>
570
	if (document.iform.tlsauth_enable.checked)
571
		document.getElementById("tlsauth_opts").style.display="";
572
	else
573
		document.getElementById("tlsauth_opts").style.display="none";
574
<?php endif; ?>
575

    
576
	autotls_change();
577
}
578

    
579
function autotls_change() {
580

    
581
<?php if (!$pconfig['tls']): ?>
582
	autocheck = document.iform.autotls_enable.checked;
583
<?php else: ?>
584
	autocheck = false;
585
<?php endif; ?>
586

    
587
	if (document.iform.tlsauth_enable.checked && !autocheck)
588
		document.getElementById("autotls_opts").style.display="";
589
	else
590
		document.getElementById("autotls_opts").style.display="none";
591
}
592

    
593
function gwredir_change() {
594

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

    
604
function dns_domain_change() {
605

    
606
	if (document.iform.dns_domain_enable.checked)
607
		document.getElementById("dns_domain_data").style.display="";
608
	else
609
		document.getElementById("dns_domain_data").style.display="none";
610
}
611

    
612
function dns_server_change() {
613

    
614
	if (document.iform.dns_server_enable.checked)
615
		document.getElementById("dns_server_data").style.display="";
616
	else
617
		document.getElementById("dns_server_data").style.display="none";
618
}
619

    
620
function wins_server_change() {
621

    
622
	if (document.iform.wins_server_enable.checked)
623
		document.getElementById("wins_server_data").style.display="";
624
	else
625
		document.getElementById("wins_server_data").style.display="none";
626
}
627

    
628
function client_mgmt_port_change() {
629

    
630
	if (document.iform.client_mgmt_port_enable.checked)
631
		document.getElementById("client_mgmt_port_data").style.display="";
632
	else
633
		document.getElementById("client_mgmt_port_data").style.display="none";
634
}
635

    
636
function ntp_server_change() {
637

    
638
	if (document.iform.ntp_server_enable.checked)
639
		document.getElementById("ntp_server_data").style.display="";
640
	else
641
		document.getElementById("ntp_server_data").style.display="none";
642
}
643

    
644
function netbios_change() {
645

    
646
	if (document.iform.netbios_enable.checked) {
647
		document.getElementById("netbios_data").style.display="";
648
		document.getElementById("wins_opts").style.display="";
649
	} else {
650
		document.getElementById("netbios_data").style.display="none";
651
		document.getElementById("wins_opts").style.display="none";
652
	}
653
}
654

    
655
function tuntap_change() {
656

    
657
	mindex = document.iform.mode.selectedIndex;
658
	mvalue = document.iform.mode.options[mindex].value;
659

    
660
	switch(mvalue) {
661
		case "p2p_tls":
662
		case "p2p_shared_key":
663
			p2p = true;
664
			break;
665
		default:
666
			p2p = false;
667
			break;
668
	}
669

    
670
	index = document.iform.dev_mode.selectedIndex;
671
	value = document.iform.dev_mode.options[index].value;
672
	switch(value) {
673
		case "tun":
674
			document.getElementById("ipv4_tunnel_network").className="vncellreq";
675
			document.getElementById("serverbridge_dhcp").style.display="none";
676
			document.getElementById("serverbridge_interface").style.display="none";
677
			document.getElementById("serverbridge_dhcp_start").style.display="none";
678
			document.getElementById("serverbridge_dhcp_end").style.display="none";
679
			document.getElementById("topology_subnet_opt").style.display="";
680
			break;
681
		case "tap":
682
			document.getElementById("ipv4_tunnel_network").className="vncell";
683
			if (!p2p) {
684
				document.getElementById("serverbridge_dhcp").style.display="";
685
				document.getElementById("serverbridge_interface").style.display="";
686
				document.getElementById("serverbridge_dhcp_start").style.display="";
687
				document.getElementById("serverbridge_dhcp_end").style.display="";
688
				document.getElementById("topology_subnet_opt").style.display="none";
689
				document.iform.serverbridge_dhcp.disabled = false;
690
				if (document.iform.serverbridge_dhcp.checked) {
691
					document.iform.serverbridge_interface.disabled = false;
692
					document.iform.serverbridge_dhcp_start.disabled = false;
693
					document.iform.serverbridge_dhcp_end.disabled = false;
694
				} else {
695
					document.iform.serverbridge_interface.disabled = true;
696
					document.iform.serverbridge_dhcp_start.disabled = true;
697
					document.iform.serverbridge_dhcp_end.disabled = true;
698
				}
699
			} else {
700
				document.getElementById("topology_subnet_opt").style.display="none";
701
				document.iform.serverbridge_dhcp.disabled = true;
702
				document.iform.serverbridge_interface.disabled = true;
703
				document.iform.serverbridge_dhcp_start.disabled = true;
704
				document.iform.serverbridge_dhcp_end.disabled = true;
705
			}
706
			break;
707
	}
708
}
709
//-->
710
</script>
711
<?php
712
if (!$savemsg)
713
	$savemsg = "";
714

    
715
if ($input_errors)
716
	print_input_errors($input_errors);
717
if ($savemsg)
718
	print_info_box_np($savemsg);
719
?>
720
<table width="100%" border="0" cellpadding="0" cellspacing="0">
721
	<tr>
722
		<td class="tabnavtbl">
723
			<ul id="tabnav">
724
			<?php 
725
				$tab_array = array();
726
				$tab_array[] = array(gettext("Server"), true, "vpn_openvpn_server.php");
727
				$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
728
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
729
				$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
730
				add_package_tabs("OpenVPN", $tab_array);
731
				display_top_tabs($tab_array);
732
			?>
733
			</ul>
734
		</td>
735
	</tr>    
736
	<tr>
737
		<td class="tabcont">
738

    
739
			<?php if($act=="new" || $act=="edit"): ?>
740

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

    
1404
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1405
					<tr>
1406
						<td colspan="2" class="list" height="12"></td>
1407
					</tr>
1408
					<tr>
1409
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Client Settings"); ?></td>
1410
					</tr>
1411
					<tr>
1412
						<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic IP"); ?></td>
1413
						<td width="78%" class="vtable">
1414
							<table border="0" cellpadding="2" cellspacing="0">
1415
								<tr>
1416
									<td>
1417
										<?php set_checked($pconfig['dynamic_ip'],$chk); ?>
1418
										<input name="dynamic_ip" type="checkbox" id="dynamic_ip" value="yes" <?=$chk;?>/>
1419
									</td>
1420
									<td>
1421
										<span class="vexpl">
1422
											<?=gettext("Allow connected clients to retain their connections if their IP address changes"); ?>.<br />
1423
										</span>
1424
									</td>
1425
								</tr>
1426
							</table>
1427
						</td>
1428
					</tr>
1429
					<tr>
1430
						<td width="22%" valign="top" class="vncell"><?=gettext("Address Pool"); ?></td>
1431
						<td width="78%" class="vtable">
1432
							<table border="0" cellpadding="2" cellspacing="0">
1433
								<tr>
1434
									<td>
1435
										<?php set_checked($pconfig['pool_enable'],$chk); ?>
1436
										<input name="pool_enable" type="checkbox" id="pool_enable" value="yes" <?=$chk;?>/>
1437
									</td>
1438
									<td>
1439
										<span class="vexpl">
1440
											<?=gettext("Provide a virtual adapter IP address to clients (see Tunnel Network)"); ?><br />
1441
										</span>
1442
									</td>
1443
								</tr>
1444
							</table>
1445
						</td>
1446
					</tr>
1447
					<tr id="topology_subnet_opt">
1448
						<td width="22%" valign="top" class="vncell"><?=gettext("Topology"); ?></td>
1449
						<td width="78%" class="vtable">
1450
							<table border="0" cellpadding="2" cellspacing="0">
1451
								<tr>
1452
									<td>
1453
										<?php set_checked($pconfig['topology_subnet'],$chk); ?>
1454
										<input name="topology_subnet" type="checkbox" id="topology_subnet" value="yes" <?=$chk;?>/>
1455
									</td>
1456
									<td>
1457
										<span class="vexpl">
1458
											<?=gettext("Allocate only one IP per client (topology subnet), rather than an isolated subnet per client (topology net30)."); ?><br />
1459
										</span>
1460
									</td>
1461
								</tr>
1462
								<tr>
1463
									<td>&nbsp;</td>
1464
									<td>
1465
										<?=gettext("Relevant when supplying a virtual adapter IP address to clients when using tun mode on IPv4."); ?><br />
1466
										<?=gettext("Some clients may require this even for IPv6, such as OpenVPN Connect (iOS/Android). Others may break if it is present, such as older versions of OpenVPN or clients such as Yealink phones."); ?><br />
1467
									</td>
1468
								</tr>
1469
							</table>
1470
						</td>
1471
					</tr>
1472
					<tr>
1473
						<td width="22%" valign="top" class="vncell"><?=gettext("DNS Default Domain"); ?></td>
1474
						<td width="78%" class="vtable">
1475
							<table border="0" cellpadding="2" cellspacing="0">
1476
								<tr>
1477
									<td>
1478
										<?php set_checked($pconfig['dns_domain_enable'],$chk); ?>
1479
										<input name="dns_domain_enable" type="checkbox" id="dns_domain_enable" value="yes" <?=$chk;?> onClick="dns_domain_change()">
1480
									</td>
1481
									<td>
1482
										<span class="vexpl">
1483
	                                        <?=gettext("Provide a default domain name to clients"); ?><br />
1484
										</span>
1485
									</td>
1486
								</tr>
1487
							</table>
1488
							<table border="0" cellpadding="2" cellspacing="0" id="dns_domain_data">
1489
								<tr>
1490
									<td>
1491
										<input name="dns_domain" type="text" class="formfld unknown" id="dns_domain" size="30" value="<?=htmlspecialchars($pconfig['dns_domain']);?>">
1492
									</td>
1493
								</tr>
1494
							</table>
1495
						</td>
1496
					</tr>
1497
					<tr>
1498
						<td width="22%" valign="top" class="vncell"><?=gettext("DNS Servers"); ?></td>
1499
						<td width="78%" class="vtable">
1500
							<table border="0" cellpadding="2" cellspacing="0">
1501
								<tr>
1502
									<td>
1503
										<?php set_checked($pconfig['dns_server_enable'],$chk); ?>
1504
										<input name="dns_server_enable" type="checkbox" id="dns_server_enable" value="yes" <?=$chk;?> onClick="dns_server_change()">
1505
									</td>
1506
									<td>
1507
										<span class="vexpl">
1508
											<?=gettext("Provide a DNS server list to clients"); ?><br />
1509
										</span>
1510
									</td>
1511
								</tr>
1512
							</table>
1513
							<table border="0" cellpadding="2" cellspacing="0" id="dns_server_data">
1514
								<tr>
1515
									<td>
1516
										<span class="vexpl">
1517
											<?=gettext("Server"); ?> #1:&nbsp;
1518
										</span>
1519
										<input name="dns_server1" type="text" class="formfld unknown" id="dns_server1" size="20" value="<?=htmlspecialchars($pconfig['dns_server1']);?>">
1520
									</td>
1521
								</tr>
1522
								<tr>
1523
									<td>
1524
										<span class="vexpl">
1525
											<?=gettext("Server"); ?> #2:&nbsp;
1526
										</span>
1527
										<input name="dns_server2" type="text" class="formfld unknown" id="dns_server2" size="20" value="<?=htmlspecialchars($pconfig['dns_server2']);?>">
1528
									</td>
1529
								</tr>
1530
								<tr>
1531
									<td>
1532
										<span class="vexpl">
1533
											<?=gettext("Server"); ?> #3:&nbsp;
1534
										</span>
1535
										<input name="dns_server3" type="text" class="formfld unknown" id="dns_server3" size="20" value="<?=htmlspecialchars($pconfig['dns_server3']);?>">
1536
									</td>
1537
								</tr>
1538
								<tr>
1539
									<td>
1540
										<span class="vexpl">
1541
											<?=gettext("Server"); ?> #4:&nbsp;
1542
										</span>
1543
										<input name="dns_server4" type="text" class="formfld unknown" id="dns_server4" size="20" value="<?=htmlspecialchars($pconfig['dns_server4']);?>">
1544
									</td>
1545
								</tr>
1546
							</table>
1547
						</td>
1548
					</tr>
1549
					<tr>
1550
						<td width="22%" valign="top" class="vncell"><?=gettext("NTP Servers"); ?></td>
1551
						<td width="78%" class="vtable">
1552
							<table border="0" cellpadding="2" cellspacing="0">
1553
								<tr>
1554
									<td>
1555
										<?php set_checked($pconfig['ntp_server_enable'],$chk); ?>
1556
										<input name="ntp_server_enable" type="checkbox" id="ntp_server_enable" value="yes" <?=$chk;?> onClick="ntp_server_change()">
1557
									</td>
1558
									<td>
1559
										<span class="vexpl">
1560
											<?=gettext("Provide a NTP server list to clients"); ?><br />
1561
										</span>
1562
									</td>
1563
								</tr>
1564
							</table>
1565
							<table border="0" cellpadding="2" cellspacing="0" id="ntp_server_data">
1566
								<tr>
1567
									<td>
1568
										<span class="vexpl">
1569
											<?=gettext("Server"); ?> #1:&nbsp;
1570
										</span>
1571
										<input name="ntp_server1" type="text" class="formfld unknown" id="ntp_server1" size="20" value="<?=htmlspecialchars($pconfig['ntp_server1']);?>">
1572
									</td>
1573
								</tr>
1574
								<tr>
1575
									<td>
1576
										<span class="vexpl">
1577
											<?=gettext("Server"); ?> #2:&nbsp;
1578
										</span>
1579
										<input name="ntp_server2" type="text" class="formfld unknown" id="ntp_server2" size="20" value="<?=htmlspecialchars($pconfig['ntp_server2']);?>">
1580
									</td>
1581
								</tr>
1582
							</table>
1583
						</td>
1584
					</tr>
1585
					<tr>
1586
						<td width="22%" valign="top" class="vncell"><?=gettext("NetBIOS Options"); ?></td>
1587
						<td width="78%" class="vtable">
1588
							<table border="0" cellpadding="2" cellspacing="0">
1589
								<tr>
1590
									<td>
1591
										<?php set_checked($pconfig['netbios_enable'],$chk); ?>
1592
										<input name="netbios_enable" type="checkbox" id="netbios_enable" value="yes" <?=$chk;?> onClick="netbios_change()">
1593
									</td>
1594
									<td>
1595
										<span class="vexpl">
1596
											<?=gettext("Enable NetBIOS over TCP/IP"); ?><br />
1597
										</span>
1598
									</td>
1599
								</tr>
1600
							</table>
1601
							<?=gettext("If this option is not set, all NetBIOS-over-TCP/IP options (including WINS) will be disabled"); ?>.
1602
							<br />
1603
							<table border="0" cellpadding="2" cellspacing="0" id="netbios_data">
1604
								<tr>
1605
									<td>
1606
										<br />
1607
										<span class="vexpl">
1608
											<?=gettext("Node Type"); ?>:&nbsp;
1609
										</span>
1610
										<select name='netbios_ntype' class="formselect">
1611
										<?php
1612
											foreach ($netbios_nodetypes as $type => $name):
1613
												$selected = "";
1614
												if ($pconfig['netbios_ntype'] == $type)
1615
													$selected = "selected";
1616
										?>
1617
											<option value="<?=$type;?>" <?=$selected;?>><?=$name;?></option>
1618
										<?php endforeach; ?>
1619
										</select>
1620
										<br />
1621
										<?=gettext("Possible options: b-node (broadcasts), p-node " .
1622
										"(point-to-point name queries to a WINS server), " .
1623
										"m-node (broadcast then query name server), and " .
1624
										"h-node (query name server, then broadcast)"); ?>.
1625
									</td>
1626
								</tr>
1627
								<tr>
1628
									<td>
1629
										<br />
1630
										<span class="vexpl">
1631
											<?=gettext("Scope ID"); ?>:&nbsp;
1632
										</span>
1633
										<input name="netbios_scope" type="text" class="formfld unknown" id="netbios_scope" size="30" value="<?=htmlspecialchars($pconfig['netbios_scope']);?>">
1634
										<br />
1635
										<?=gettext("A NetBIOS Scope	ID provides an extended naming " .
1636
										"service for	NetBIOS over TCP/IP. The NetBIOS " .
1637
										"scope ID isolates NetBIOS traffic on a single " .
1638
										"network to only those nodes with the same " .
1639
										"NetBIOS scope ID"); ?>.
1640
									</td>
1641
								</tr>
1642
							</table>
1643
						</td>
1644
					</tr>
1645
					<tr id="wins_opts">
1646
						<td width="22%" valign="top" class="vncell"><?=gettext("WINS Servers"); ?></td>
1647
						<td width="78%" class="vtable">
1648
							<table border="0" cellpadding="2" cellspacing="0">
1649
								<tr>
1650
									<td>
1651
										<?php set_checked($pconfig['wins_server_enable'],$chk); ?>
1652
										<input name="wins_server_enable" type="checkbox" id="wins_server_enable" value="yes" <?=$chk;?> onClick="wins_server_change()">
1653
									</td>
1654
									<td>
1655
										<span class="vexpl">
1656
											<?=gettext("Provide a WINS server list to clients"); ?><br />
1657
										</span>
1658
									</td>
1659
								</tr>
1660
							</table>
1661
							<table border="0" cellpadding="2" cellspacing="0" id="wins_server_data">
1662
								<tr>
1663
									<td>
1664
										<span class="vexpl">
1665
											<?=gettext("Server"); ?> #1:&nbsp;
1666
										</span>
1667
										<input name="wins_server1" type="text" class="formfld unknown" id="wins_server1" size="20" value="<?=htmlspecialchars($pconfig['wins_server1']);?>">
1668
									</td>
1669
								</tr>
1670
								<tr>
1671
									<td>
1672
										<span class="vexpl">
1673
											<?=gettext("Server"); ?> #2:&nbsp;
1674
										</span>
1675
										<input name="wins_server2" type="text" class="formfld unknown" id="wins_server2" size="20" value="<?=htmlspecialchars($pconfig['wins_server2']);?>">
1676
									</td>
1677
								</tr>
1678
							</table>
1679
						</td>
1680
					</tr>
1681
					<tr>
1682
						<td width="22%" valign="top" class="vncell"><?=gettext("Client Management Port"); ?></td>
1683
						<td width="78%" class="vtable">
1684
							<table border="0" cellpadding="2" cellspacing="0">
1685
								<tr>
1686
									<td>
1687
										<?php set_checked($pconfig['client_mgmt_port_enable'],$chk); ?>
1688
										<input name="client_mgmt_port_enable" type="checkbox" id="client_mgmt_port_enable" value="yes" <?=$chk;?> onClick="client_mgmt_port_change()">
1689
									</td>
1690
									<td>
1691
										<span class="vexpl">
1692
	                                        <?=gettext("Use a different management port on clients. The default port is 166. Specify a different port if the client machines need to select from multiple OpenVPN links."); ?><br />
1693
										</span>
1694
									</td>
1695
								</tr>
1696
							</table>
1697
							<table border="0" cellpadding="2" cellspacing="0" id="client_mgmt_port_data">
1698
								<tr>
1699
									<td>
1700
										<input name="client_mgmt_port" type="text" class="formfld unknown" id="client_mgmt_port" size="30" value="<?=htmlspecialchars($pconfig['client_mgmt_port']);?>">
1701
									</td>
1702
								</tr>
1703
							</table>
1704
						</td>
1705
					</tr>
1706
				</table>
1707

    
1708
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1709
					<tr>
1710
						<td colspan="2" class="list" height="12"></td>
1711
					</tr>
1712
					<tr>
1713
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
1714
					</tr>
1715
					<tr>
1716
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1717
						<td width="78%" class="vtable">
1718
							<table border="0" cellpadding="2" cellspacing="0">
1719
								<tr>
1720
									<td>
1721
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=htmlspecialchars($pconfig['custom_options']);?></textarea><br />
1722
										<?=gettext("Enter any additional options you would like to add to the OpenVPN server configuration here, separated by a semicolon"); ?><br />
1723
										<?=gettext("EXAMPLE: push \"route 10.0.0.0 255.255.255.0\""); ?>;
1724
									</td>
1725
								</tr>
1726
							</table>
1727
						</td>
1728
					</tr>
1729
				</table>
1730

    
1731
				<br />
1732
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
1733
					<tr>
1734
						<td width="22%" valign="top">&nbsp;</td>
1735
						<td width="78%"> 
1736
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>"> 
1737
							<input name="act" type="hidden" value="<?=$act;?>">
1738
							<?php if (isset($id) && $a_server[$id]): ?>
1739
							<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>">
1740
							<?php endif; ?>
1741
						</td>
1742
					</tr>
1743
				</table>
1744
			</form>
1745

    
1746
			<?php else: ?>
1747

    
1748
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
1749
				<thead>
1750
				<tr>
1751
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
1752
					<td width="10%" class="listhdrr"><?=gettext("Protocol / Port"); ?></td>
1753
					<td width="30%" class="listhdrr"><?=gettext("Tunnel Network"); ?></td>
1754
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
1755
					<td width="10%" class="list"></td>
1756
				</tr>
1757
				</thead>
1758
				<tbody>
1759
				<?php
1760
					$i = 0;
1761
					foreach($a_server as $server):
1762
						$disabled = "NO";
1763
						if (isset($server['disable']))
1764
							$disabled = "YES";
1765
				?>
1766
				<tr>
1767
					<td class="listlr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1768
						<?=$disabled;?>
1769
					</td>
1770
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1771
						<?=htmlspecialchars($server['protocol']);?> / <?=htmlspecialchars($server['local_port']);?>
1772
					</td>
1773
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1774
						<?=htmlspecialchars($server['tunnel_network']);?><br />
1775
						<?=htmlspecialchars($server['tunnel_networkv6']);?><br />
1776
					</td>
1777
					<td class="listbg" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1778
						<?=htmlspecialchars($server['description']);?>
1779
					</td>
1780
					<td valign="middle" nowrap class="list">
1781
						<a href="vpn_openvpn_server.php?act=edit&id=<?=$i;?>">
1782
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit server"); ?>" width="17" height="17" border="0">
1783
						</a>
1784
						&nbsp;
1785
						<a href="vpn_openvpn_server.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this server?"); ?>')">
1786
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete server"); ?>" width="17" height="17" border="0">
1787
						</a>
1788
					</td>
1789
				</tr>
1790
				<?php
1791
					$i++;
1792
					endforeach;
1793
				?>
1794
				</tbody>
1795
				<tfoot>
1796
				<tr>
1797
					<td class="list" colspan="4"></td>
1798
					<td class="list">
1799
						<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">
1800
						</a>
1801
					</td>
1802
				</tr>
1803
				</tfoot>
1804
			</table>
1805

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

    
1808
			<?php endif; ?>
1809

    
1810
		</td>
1811
	</tr>
1812
</table>
1813
<script language="JavaScript">
1814
<!--
1815
mode_change();
1816
autokey_change();
1817
tlsauth_change();
1818
gwredir_change();
1819
dns_domain_change();
1820
dns_server_change();
1821
wins_server_change();
1822
client_mgmt_port_change();
1823
ntp_server_change();
1824
netbios_change();
1825
tuntap_change();
1826
//-->
1827
</script>
1828
</body>
1829
<?php include("fend.inc"); ?>
1830

    
1831
<?php
1832

    
1833
/* local utility functions */
1834

    
1835
function set_checked($var,& $chk) {
1836
    if($var)
1837
        $chk = 'checked';
1838
    else
1839
        $chk = '';
1840
}
1841

    
1842
?>
(244-244/251)