Project

General

Profile

Download (72.2 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
	// OpenVPN Defaults to SHA1
101
	$pconfig['digest'] = "SHA1";
102
}
103

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
349
		$server = array();
350

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
465
include("head.inc");
466

    
467
?>
468

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

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

    
558
function autokey_change() {
559

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

    
566
function tlsauth_change() {
567

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

    
575
	autotls_change();
576
}
577

    
578
function autotls_change() {
579

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

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

    
592
function gwredir_change() {
593

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

    
603
function dns_domain_change() {
604

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

    
611
function dns_server_change() {
612

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

    
619
function wins_server_change() {
620

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

    
627
function client_mgmt_port_change() {
628

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

    
635
function ntp_server_change() {
636

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

    
643
function netbios_change() {
644

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

    
654
function tuntap_change() {
655

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

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

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

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

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

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

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

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

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

    
1745
			<?php else: ?>
1746

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

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

    
1807
			<?php endif; ?>
1808

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

    
1830
<?php
1831

    
1832
/* local utility functions */
1833

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

    
1841
?>
(244-244/251)