Project

General

Profile

Download (75.9 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php 
2
/*
3
	vpn_openvpn_server.php
4

    
5
	Copyright (C) 2008 Shrew Soft Inc.
6
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
7
	All rights reserved. 
8

    
9
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11
	
12
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14
	
15
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18
	
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30

    
31
##|+PRIV
32
##|*IDENT=page-openvpn-server
33
##|*NAME=OpenVPN: Server page
34
##|*DESCR=Allow access to the 'OpenVPN: Server' page.
35
##|*MATCH=vpn_openvpn_server.php*
36
##|-PRIV
37

    
38
require("guiconfig.inc");
39
require_once("openvpn.inc");
40
require_once("pkg-utils.inc");
41

    
42
if (!is_array($config['openvpn']['openvpn-server']))
43
	$config['openvpn']['openvpn-server'] = array();
44

    
45
$a_server = &$config['openvpn']['openvpn-server'];
46

    
47
if (!is_array($config['ca']))
48
	$config['ca'] = array();
49

    
50
$a_ca =& $config['ca'];
51

    
52
if (!is_array($config['cert']))
53
	$config['cert'] = array();
54

    
55
$a_cert =& $config['cert'];
56

    
57
if (!is_array($config['crl']))
58
	$config['crl'] = array();
59

    
60
$a_crl =& $config['crl'];
61

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

    
66
if (is_numericint($_GET['id']))
67
	$id = $_GET['id'];
68
if (isset($_POST['id']) && is_numericint($_POST['id']))
69
	$id = $_POST['id'];
70

    
71
$act = $_GET['act'];
72
if (isset($_POST['act']))
73
	$act = $_POST['act'];
74

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

    
80
if ($_GET['act'] == "del") {
81

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

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

    
108
if($_GET['act']=="edit") {
109

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

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

    
146
		$pconfig['tunnel_network'] = $a_server[$id]['tunnel_network'];
147
		$pconfig['tunnel_networkv6'] = $a_server[$id]['tunnel_networkv6'];
148

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

    
159
		$pconfig['dynamic_ip'] = $a_server[$id]['dynamic_ip'];
160
		$pconfig['pool_enable'] = $a_server[$id]['pool_enable'];
161
		$pconfig['topology_subnet'] = $a_server[$id]['topology_subnet'];
162

    
163
		$pconfig['serverbridge_dhcp'] = $a_server[$id]['serverbridge_dhcp'];
164
		$pconfig['serverbridge_interface'] = $a_server[$id]['serverbridge_interface'];
165
		$pconfig['serverbridge_dhcp_start'] = $a_server[$id]['serverbridge_dhcp_start'];
166
		$pconfig['serverbridge_dhcp_end'] = $a_server[$id]['serverbridge_dhcp_end'];
167

    
168
		$pconfig['dns_domain'] = $a_server[$id]['dns_domain'];
169
		if ($pconfig['dns_domain'])
170
			$pconfig['dns_domain_enable'] = true;
171

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

    
182
		$pconfig['ntp_server1'] = $a_server[$id]['ntp_server1'];
183
		$pconfig['ntp_server2'] = $a_server[$id]['ntp_server2'];
184
		if ($pconfig['ntp_server1'] ||
185
			$pconfig['ntp_server2'])
186
			$pconfig['ntp_server_enable'] = true;
187

    
188
		$pconfig['netbios_enable'] = $a_server[$id]['netbios_enable'];
189
		$pconfig['netbios_ntype'] = $a_server[$id]['netbios_ntype'];
190
		$pconfig['netbios_scope'] = $a_server[$id]['netbios_scope'];
191

    
192
		$pconfig['wins_server1'] = $a_server[$id]['wins_server1'];
193
		$pconfig['wins_server2'] = $a_server[$id]['wins_server2'];
194
		if ($pconfig['wins_server1'] ||
195
			$pconfig['wins_server2'])
196
			$pconfig['wins_server_enable'] = true;
197

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

    
202
		$pconfig['nbdd_server1'] = $a_server[$id]['nbdd_server1'];
203
		if ($pconfig['nbdd_server1'])
204
			$pconfig['nbdd_server_enable'] = true;
205

    
206
		// just in case the modes switch
207
		$pconfig['autokey_enable'] = "yes";
208
		$pconfig['autotls_enable'] = "yes";
209

    
210
		$pconfig['duplicate_cn'] = isset($a_server[$id]['duplicate_cn']);
211
		
212
		$pconfig['no_tun_ipv6'] = $a_server[$id]['no_tun_ipv6'];
213
		if (isset($a_server[$id]['verbosity_level']))
214
			$pconfig['verbosity_level'] = $a_server[$id]['verbosity_level'];
215
		else
216
			$pconfig['verbosity_level'] = 1; // Default verbosity is 1
217
		
218
		$pconfig['push_register_dns'] = $a_server[$id]['push_register_dns'];
219
	}
220
}
221
if ($_POST) {
222

    
223
	unset($input_errors);
224
	$pconfig = $_POST;
225

    
226
	if (isset($id) && $a_server[$id])
227
		$vpnid = $a_server[$id]['vpnid'];
228
	else
229
		$vpnid = 0;
230

    
231
	list($iv_iface, $iv_ip) = explode ("|",$pconfig['interface']);
232
	if (is_ipaddrv4($iv_ip) && (stristr($pconfig['protocol'], "6") !== false)) {
233
		$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv6 protocol and an IPv4 IP address.");
234
	} elseif (is_ipaddrv6($iv_ip) && (stristr($pconfig['protocol'], "6") === false)) {
235
		$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv4 protocol and an IPv6 IP address.");
236
	} elseif ((stristr($pconfig['protocol'], "6") === false) && !get_interface_ip($iv_iface) && ($pconfig['interface'] != "any")) {
237
		$input_errors[] = gettext("An IPv4 protocol was selected, but the selected interface has no IPv4 address.");
238
	} elseif ((stristr($pconfig['protocol'], "6") !== false) && !get_interface_ipv6($iv_iface) && ($pconfig['interface'] != "any")) {
239
		$input_errors[] = gettext("An IPv6 protocol was selected, but the selected interface has no IPv6 address.");
240
	}
241

    
242
	if ($pconfig['mode'] != "p2p_shared_key")
243
		$tls_mode = true;
244
	else
245
		$tls_mode = false;
246

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

    
250
	/* input validation */
251
	if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
252
		$input_errors[] = $result;
253

    
254
	if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'IPv4 Tunnel Network', false, "ipv4"))
255
		$input_errors[] = $result;
256

    
257
	if ($result = openvpn_validate_cidr($pconfig['tunnel_networkv6'], 'IPv6 Tunnel Network', false, "ipv6"))
258
		$input_errors[] = $result;
259

    
260
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'IPv4 Remote Network', true, "ipv4"))
261
		$input_errors[] = $result;
262

    
263
	if ($result = openvpn_validate_cidr($pconfig['remote_networkv6'], 'IPv6 Remote Network', true, "ipv6"))
264
		$input_errors[] = $result;
265

    
266
	if ($result = openvpn_validate_cidr($pconfig['local_network'], 'IPv4 Local Network', true, "ipv4"))
267
		$input_errors[] = $result;
268

    
269
	if ($result = openvpn_validate_cidr($pconfig['local_networkv6'], 'IPv6 Local Network', true, "ipv6"))
270
		$input_errors[] = $result;
271

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

    
276
	if ($pconfig['autokey_enable'])
277
		$pconfig['shared_key'] = openvpn_create_key();
278

    
279
	if (!$tls_mode && !$pconfig['autokey_enable'])
280
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
281
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
282
			$input_errors[] = gettext("The field 'Shared Key' does not appear to be valid");
283

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

    
289
	if ($pconfig['dns_server_enable']) {
290
		if (!empty($pconfig['dns_server1']) && !is_ipaddr(trim($pconfig['dns_server1'])))
291
			$input_errors[] = gettext("The field 'DNS Server #1' must contain a valid IP address");
292
		if (!empty($pconfig['dns_server2']) && !is_ipaddr(trim($pconfig['dns_server2'])))
293
			$input_errors[] = gettext("The field 'DNS Server #2' must contain a valid IP address");
294
		if (!empty($pconfig['dns_server3']) && !is_ipaddr(trim($pconfig['dns_server3'])))
295
			$input_errors[] = gettext("The field 'DNS Server #3' must contain a valid IP address");
296
		if (!empty($pconfig['dns_server4']) && !is_ipaddr(trim($pconfig['dns_server4'])))
297
			$input_errors[] = gettext("The field 'DNS Server #4' must contain a valid IP address");
298
	}
299

    
300
	if ($pconfig['ntp_server_enable']) {
301
		if (!empty($pconfig['ntp_server1']) && !is_ipaddr(trim($pconfig['ntp_server1'])))
302
			$input_errors[] = gettext("The field 'NTP Server #1' must contain a valid IP address");
303
		if (!empty($pconfig['ntp_server2']) && !is_ipaddr(trim($pconfig['ntp_server2'])))
304
			$input_errors[] = gettext("The field 'NTP Server #2' must contain a valid IP address");
305
		if (!empty($pconfig['ntp_server3']) && !is_ipaddr(trim($pconfig['ntp_server3'])))
306
			$input_errors[] = gettext("The field 'NTP Server #3' must contain a valid IP address");
307
		if (!empty($pconfig['ntp_server4']) && !is_ipaddr(trim($pconfig['ntp_server4'])))
308
			$input_errors[] = gettext("The field 'NTP Server #4' must contain a valid IP address");
309
	}
310

    
311
	if ($pconfig['netbios_enable']) {
312
		if ($pconfig['wins_server_enable']) {
313
			if (!empty($pconfig['wins_server1']) && !is_ipaddr(trim($pconfig['wins_server1'])))
314
				$input_errors[] = gettext("The field 'WINS Server #1' must contain a valid IP address");
315
			if (!empty($pconfig['wins_server2']) && !is_ipaddr(trim($pconfig['wins_server2'])))
316
				$input_errors[] = gettext("The field 'WINS Server #2' must contain a valid IP address");
317
		}
318
		if ($pconfig['nbdd_server_enable'])
319
			if (!empty($pconfig['nbdd_server1']) && !is_ipaddr(trim($pconfig['nbdd_server1'])))
320
				$input_errors[] = gettext("The field 'NetBIOS Data Distribution Server #1' must contain a valid IP address");
321
	}
322

    
323
	if ($pconfig['client_mgmt_port_enable']) {
324
		if ($result = openvpn_validate_port($pconfig['client_mgmt_port'], 'Client management port'))
325
			$input_errors[] = $result;
326
	}
327

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

    
331
	/* If we are not in shared key mode, then we need the CA/Cert. */
332
	if ($pconfig['mode'] != "p2p_shared_key") {
333
		$reqdfields = explode(" ", "caref certref");
334
		$reqdfieldsn = array(gettext("Certificate Authority"),gettext("Certificate"));
335
	} elseif (!$pconfig['autokey_enable']) {
336
		/* We only need the shared key filled in if we are in shared key mode and autokey is not selected. */
337
		$reqdfields = array('shared_key');
338
		$reqdfieldsn = array(gettext('Shared key'));
339
	}
340

    
341
	if ($pconfig['dev_mode'] != "tap") {
342
		$reqdfields[] = 'tunnel_network';
343
		$reqdfieldsn[] = gettext('Tunnel network');
344
	} else {
345
		if ($pconfig['serverbridge_dhcp'] && $pconfig['tunnel_network'])
346
			$input_errors[] = gettext("Using a tunnel network and server bridge settings together is not allowed.");
347
		if (($pconfig['serverbridge_dhcp_start'] && !$pconfig['serverbridge_dhcp_end']) 
348
		|| (!$pconfig['serverbridge_dhcp_start'] && $pconfig['serverbridge_dhcp_end']))
349
			$input_errors[] = gettext("Server Bridge DHCP Start and End must both be empty, or defined.");
350
		if (($pconfig['serverbridge_dhcp_start'] && !is_ipaddrv4($pconfig['serverbridge_dhcp_start'])))
351
			$input_errors[] = gettext("Server Bridge DHCP Start must be an IPv4 address.");
352
		if (($pconfig['serverbridge_dhcp_end'] && !is_ipaddrv4($pconfig['serverbridge_dhcp_end'])))
353
			$input_errors[] = gettext("Server Bridge DHCP End must be an IPv4 address.");
354
		if (ip2ulong($pconfig['serverbridge_dhcp_start']) > ip2ulong($pconfig['serverbridge_dhcp_end']))
355
			$input_errors[] = gettext("The Server Bridge DHCP range is invalid (start higher than end).");
356
	}
357
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
358
	
359
	if (!$input_errors) {
360

    
361
		$server = array();
362

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

    
366
		if ($vpnid)
367
			$server['vpnid'] = $vpnid;
368
		else
369
			$server['vpnid'] = openvpn_vpnid_next();
370

    
371
		if ($_POST['disable'] == "yes")
372
			$server['disable'] = true;
373
		$server['mode'] = $pconfig['mode'];
374
		if (!empty($pconfig['authmode']) && (($pconfig['mode'] == "server_user") || ($pconfig['mode'] == "server_tls_user")))
375
			$server['authmode'] = implode(",", $pconfig['authmode']);
376
		$server['protocol'] = $pconfig['protocol'];
377
		$server['dev_mode'] = $pconfig['dev_mode'];
378
		list($server['interface'], $server['ipaddr']) = explode ("|",$pconfig['interface']);
379
		$server['local_port'] = $pconfig['local_port'];
380
		$server['description'] = $pconfig['description'];
381
		$server['custom_options'] = str_replace("\r\n", "\n", $pconfig['custom_options']);
382

    
383
		if ($tls_mode) {
384
			if ($pconfig['tlsauth_enable']) {
385
				if ($pconfig['autotls_enable'])
386
					$pconfig['tls'] = openvpn_create_key();
387
				$server['tls'] = base64_encode($pconfig['tls']);
388
			}
389
			$server['caref'] = $pconfig['caref'];
390
			$server['crlref'] = $pconfig['crlref'];
391
			$server['certref'] = $pconfig['certref'];
392
			$server['dh_length'] = $pconfig['dh_length'];
393
			$server['cert_depth'] = $pconfig['cert_depth'];
394
			if ($pconfig['mode'] == "server_tls_user")
395
				$server['strictusercn'] = $pconfig['strictusercn'];
396
		} else {
397
			$server['shared_key'] = base64_encode($pconfig['shared_key']);
398
		}
399
		$server['crypto'] = $pconfig['crypto'];
400
		$server['digest'] = $pconfig['digest'];
401
		$server['engine'] = $pconfig['engine'];
402

    
403
		$server['tunnel_network'] = $pconfig['tunnel_network'];
404
		$server['tunnel_networkv6'] = $pconfig['tunnel_networkv6'];
405
		$server['remote_network'] = $pconfig['remote_network'];
406
		$server['remote_networkv6'] = $pconfig['remote_networkv6'];
407
		$server['gwredir'] = $pconfig['gwredir'];
408
		$server['local_network'] = $pconfig['local_network'];
409
		$server['local_networkv6'] = $pconfig['local_networkv6'];
410
		$server['maxclients'] = $pconfig['maxclients'];
411
		$server['compression'] = $pconfig['compression'];
412
		$server['passtos'] = $pconfig['passtos'];
413
		$server['client2client'] = $pconfig['client2client'];
414

    
415
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
416
		$server['pool_enable'] = $pconfig['pool_enable'];
417
		$server['topology_subnet'] = $pconfig['topology_subnet'];
418

    
419
		$server['serverbridge_dhcp'] = $pconfig['serverbridge_dhcp'];
420
		$server['serverbridge_interface'] = $pconfig['serverbridge_interface'];
421
		$server['serverbridge_dhcp_start'] = $pconfig['serverbridge_dhcp_start'];
422
		$server['serverbridge_dhcp_end'] = $pconfig['serverbridge_dhcp_end'];
423

    
424
		if ($pconfig['dns_domain_enable'])
425
			$server['dns_domain'] = $pconfig['dns_domain'];
426

    
427
		if ($pconfig['dns_server_enable']) {
428
			$server['dns_server1'] = $pconfig['dns_server1'];
429
			$server['dns_server2'] = $pconfig['dns_server2'];
430
			$server['dns_server3'] = $pconfig['dns_server3'];
431
			$server['dns_server4'] = $pconfig['dns_server4'];
432
		}
433

    
434
		if ($pconfig['push_register_dns'])
435
			$server['push_register_dns'] = $pconfig['push_register_dns'];
436

    
437
		if ($pconfig['ntp_server_enable']) {
438
			$server['ntp_server1'] = $pconfig['ntp_server1'];
439
			$server['ntp_server2'] = $pconfig['ntp_server2'];
440
		}
441

    
442
		$server['netbios_enable'] = $pconfig['netbios_enable'];
443
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
444
		$server['netbios_scope'] = $pconfig['netbios_scope'];
445
		 
446
		$server['no_tun_ipv6'] = $pconfig['no_tun_ipv6'];
447
		$server['verbosity_level'] = $pconfig['verbosity_level'];
448

    
449
		if ($pconfig['netbios_enable']) {
450

    
451
			if ($pconfig['wins_server_enable']) {
452
				$server['wins_server1'] = $pconfig['wins_server1'];
453
				$server['wins_server2'] = $pconfig['wins_server2'];
454
			}
455

    
456
			if ($pconfig['dns_server_enable'])
457
				$server['nbdd_server1'] = $pconfig['nbdd_server1'];
458
		}
459

    
460
		if ($pconfig['client_mgmt_port_enable'])
461
			$server['client_mgmt_port'] = $pconfig['client_mgmt_port'];
462

    
463
		if ($_POST['duplicate_cn'] == "yes")
464
			$server['duplicate_cn'] = true;
465

    
466
		if (isset($id) && $a_server[$id])
467
			$a_server[$id] = $server;
468
		else
469
			$a_server[] = $server;
470

    
471
		openvpn_resync('server', $server);
472
		write_config();
473
		
474
		header("Location: vpn_openvpn_server.php");
475
		exit;
476
	}
477
	if (!empty($pconfig['authmode']))
478
		$pconfig['authmode'] = implode(",", $pconfig['authmode']);
479
}
480
$pgtitle = array(gettext("OpenVPN"), gettext("Server"));
481
$shortcut_section = "openvpn";
482

    
483
include("head.inc");
484

    
485
?>
486

    
487
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
488
<?php include("fbegin.inc"); ?>
489
<script type="text/javascript">
490
//<![CDATA[
491

    
492
function mode_change() {
493
	index = document.iform.mode.selectedIndex;
494
	value = document.iform.mode.options[index].value;
495
	switch(value) {
496
		case "p2p_tls":
497
		case "server_tls":
498
		case "server_user":
499
			document.getElementById("tls").style.display="";
500
			document.getElementById("tls_ca").style.display="";
501
			document.getElementById("tls_crl").style.display="";
502
			document.getElementById("tls_cert").style.display="";
503
			document.getElementById("tls_dh").style.display="";
504
			document.getElementById("cert_depth").style.display="";
505
			document.getElementById("strictusercn").style.display="none";
506
			document.getElementById("psk").style.display="none";
507
			break;
508
		case "server_tls_user":
509
			document.getElementById("tls").style.display="";
510
			document.getElementById("tls_ca").style.display="";
511
			document.getElementById("tls_crl").style.display="";
512
			document.getElementById("tls_cert").style.display="";
513
			document.getElementById("tls_dh").style.display="";
514
			document.getElementById("cert_depth").style.display="";
515
			document.getElementById("strictusercn").style.display="";
516
			document.getElementById("psk").style.display="none";
517
			break;
518
		case "p2p_shared_key":
519
			document.getElementById("tls").style.display="none";
520
			document.getElementById("tls_ca").style.display="none";
521
			document.getElementById("tls_crl").style.display="none";
522
			document.getElementById("tls_cert").style.display="none";
523
			document.getElementById("tls_dh").style.display="none";
524
			document.getElementById("cert_depth").style.display="none";
525
			document.getElementById("strictusercn").style.display="none";
526
			document.getElementById("psk").style.display="";
527
			break;
528
	}
529
	switch(value) {
530
		case "p2p_shared_key":
531
			document.getElementById("client_opts").style.display="none";
532
			document.getElementById("remote_optsv4").style.display="";
533
			document.getElementById("remote_optsv6").style.display="";
534
			document.getElementById("gwredir_opts").style.display="none";
535
			document.getElementById("local_optsv4").style.display="none";
536
			document.getElementById("local_optsv6").style.display="none";
537
			document.getElementById("authmodetr").style.display="none";
538
			document.getElementById("inter_client_communication").style.display="none";
539
			break;
540
		case "p2p_tls":
541
			document.getElementById("client_opts").style.display="none";
542
			document.getElementById("remote_optsv4").style.display="";
543
			document.getElementById("remote_optsv6").style.display="";
544
			document.getElementById("gwredir_opts").style.display="";
545
			document.getElementById("local_optsv4").style.display="";
546
			document.getElementById("local_optsv6").style.display="";
547
			document.getElementById("authmodetr").style.display="none";
548
			document.getElementById("inter_client_communication").style.display="none";
549
			break;
550
		case "server_user":
551
		case "server_tls_user":
552
			document.getElementById("authmodetr").style.display="";
553
			document.getElementById("client_opts").style.display="";
554
			document.getElementById("remote_optsv4").style.display="none";
555
			document.getElementById("remote_optsv6").style.display="none";
556
			document.getElementById("gwredir_opts").style.display="";
557
			document.getElementById("local_optsv4").style.display="";
558
			document.getElementById("local_optsv6").style.display="";
559
			document.getElementById("inter_client_communication").style.display="";
560
			break;
561
		case "server_tls":
562
			document.getElementById("authmodetr").style.display="none";
563
		default:
564
			document.getElementById("client_opts").style.display="";
565
			document.getElementById("remote_optsv4").style.display="none";
566
			document.getElementById("remote_optsv6").style.display="none";
567
			document.getElementById("gwredir_opts").style.display="";
568
			document.getElementById("local_optsv4").style.display="";
569
			document.getElementById("local_optsv6").style.display="";
570
			document.getElementById("inter_client_communication").style.display="";
571
			break;
572
	}
573
	gwredir_change();
574
}
575

    
576
function autokey_change() {
577

    
578
	if ((document.iform.autokey_enable != null) && (document.iform.autokey_enable.checked))
579
		document.getElementById("autokey_opts").style.display="none";
580
	else
581
		document.getElementById("autokey_opts").style.display="";
582
}
583

    
584
function tlsauth_change() {
585

    
586
<?php if (!$pconfig['tls']): ?>
587
	if (document.iform.tlsauth_enable.checked)
588
		document.getElementById("tlsauth_opts").style.display="";
589
	else
590
		document.getElementById("tlsauth_opts").style.display="none";
591
<?php endif; ?>
592

    
593
	autotls_change();
594
}
595

    
596
function autotls_change() {
597

    
598
<?php if (!$pconfig['tls']): ?>
599
	autocheck = document.iform.autotls_enable.checked;
600
<?php else: ?>
601
	autocheck = false;
602
<?php endif; ?>
603

    
604
	if (document.iform.tlsauth_enable.checked && !autocheck)
605
		document.getElementById("autotls_opts").style.display="";
606
	else
607
		document.getElementById("autotls_opts").style.display="none";
608
}
609

    
610
function gwredir_change() {
611

    
612
	if (document.iform.gwredir.checked) {
613
		document.getElementById("local_optsv4").style.display="none";
614
		document.getElementById("local_optsv6").style.display="none";
615
	} else {
616
		document.getElementById("local_optsv4").style.display="";
617
		document.getElementById("local_optsv6").style.display="";
618
	}
619
}
620

    
621
function dns_domain_change() {
622

    
623
	if (document.iform.dns_domain_enable.checked)
624
		document.getElementById("dns_domain_data").style.display="";
625
	else
626
		document.getElementById("dns_domain_data").style.display="none";
627
}
628

    
629
function dns_server_change() {
630

    
631
	if (document.iform.dns_server_enable.checked)
632
		document.getElementById("dns_server_data").style.display="";
633
	else
634
		document.getElementById("dns_server_data").style.display="none";
635
}
636

    
637
function wins_server_change() {
638

    
639
	if (document.iform.wins_server_enable.checked)
640
		document.getElementById("wins_server_data").style.display="";
641
	else
642
		document.getElementById("wins_server_data").style.display="none";
643
}
644

    
645
function client_mgmt_port_change() {
646

    
647
	if (document.iform.client_mgmt_port_enable.checked)
648
		document.getElementById("client_mgmt_port_data").style.display="";
649
	else
650
		document.getElementById("client_mgmt_port_data").style.display="none";
651
}
652

    
653
function ntp_server_change() {
654

    
655
	if (document.iform.ntp_server_enable.checked)
656
		document.getElementById("ntp_server_data").style.display="";
657
	else
658
		document.getElementById("ntp_server_data").style.display="none";
659
}
660

    
661
function netbios_change() {
662

    
663
	if (document.iform.netbios_enable.checked) {
664
		document.getElementById("netbios_data").style.display="";
665
		document.getElementById("wins_opts").style.display="";
666
	} else {
667
		document.getElementById("netbios_data").style.display="none";
668
		document.getElementById("wins_opts").style.display="none";
669
	}
670
}
671

    
672
function tuntap_change() {
673

    
674
	mindex = document.iform.mode.selectedIndex;
675
	mvalue = document.iform.mode.options[mindex].value;
676

    
677
	switch(mvalue) {
678
		case "p2p_tls":
679
		case "p2p_shared_key":
680
			p2p = true;
681
			break;
682
		default:
683
			p2p = false;
684
			break;
685
	}
686

    
687
	index = document.iform.dev_mode.selectedIndex;
688
	value = document.iform.dev_mode.options[index].value;
689
	switch(value) {
690
		case "tun":
691
			document.getElementById("chkboxNoTunIPv6").style.display="";
692
			document.getElementById("ipv4_tunnel_network").className="vncellreq";
693
			document.getElementById("serverbridge_dhcp").style.display="none";
694
			document.getElementById("serverbridge_interface").style.display="none";
695
			document.getElementById("serverbridge_dhcp_start").style.display="none";
696
			document.getElementById("serverbridge_dhcp_end").style.display="none";
697
			document.getElementById("topology_subnet_opt").style.display="";
698
			break;
699
		case "tap":
700
			document.getElementById("chkboxNoTunIPv6").style.display="none";
701
			document.getElementById("ipv4_tunnel_network").className="vncell";
702
			if (!p2p) {
703
				document.getElementById("serverbridge_dhcp").style.display="";
704
				document.getElementById("serverbridge_interface").style.display="";
705
				document.getElementById("serverbridge_dhcp_start").style.display="";
706
				document.getElementById("serverbridge_dhcp_end").style.display="";
707
				document.getElementById("topology_subnet_opt").style.display="none";
708
				document.iform.serverbridge_dhcp.disabled = false;
709
				if (document.iform.serverbridge_dhcp.checked) {
710
					document.iform.serverbridge_interface.disabled = false;
711
					document.iform.serverbridge_dhcp_start.disabled = false;
712
					document.iform.serverbridge_dhcp_end.disabled = false;
713
				} else {
714
					document.iform.serverbridge_interface.disabled = true;
715
					document.iform.serverbridge_dhcp_start.disabled = true;
716
					document.iform.serverbridge_dhcp_end.disabled = true;
717
				}
718
			} else {
719
				document.getElementById("topology_subnet_opt").style.display="none";
720
				document.iform.serverbridge_dhcp.disabled = true;
721
				document.iform.serverbridge_interface.disabled = true;
722
				document.iform.serverbridge_dhcp_start.disabled = true;
723
				document.iform.serverbridge_dhcp_end.disabled = true;
724
			}
725
			break;
726
	}
727
}
728
//]]>
729
</script>
730
<?php
731
if (!$savemsg)
732
	$savemsg = "";
733

    
734
if ($input_errors)
735
	print_input_errors($input_errors);
736
if ($savemsg)
737
	print_info_box_np($savemsg);
738
?>
739
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn openvpn server">
740
	<tr>
741
		<td class="tabnavtbl">
742
			<?php 
743
				$tab_array = array();
744
				$tab_array[] = array(gettext("Server"), true, "vpn_openvpn_server.php");
745
				$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
746
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
747
				$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
748
				add_package_tabs("openvpn-client-export", $tab_array);
749
				display_top_tabs($tab_array);
750
			?>
751
		</td>
752
	</tr>    
753
	<tr>
754
		<td class="tabcont">
755

    
756
			<?php if($act=="new" || $act=="edit"): ?>
757

    
758
			<form action="vpn_openvpn_server.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
759
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="general information">
760
					<tr>
761
						<td colspan="2" valign="top" class="listtopic"><?=gettext("General information"); ?></td>
762
					</tr>
763
					<tr>
764
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td>
765
						<td width="78%" class="vtable">
766
							<table border="0" cellpadding="0" cellspacing="0" summary="enable disable server">
767
								<tr>
768
									<td>
769
										<?php set_checked($pconfig['disable'],$chk); ?>
770
										<input name="disable" type="checkbox" value="yes" <?=$chk;?> />
771
									</td>
772
									<td>
773
										&nbsp;
774
										<span class="vexpl">
775
											<strong><?=gettext("Disable this server"); ?></strong><br />
776
										</span>
777
									</td>
778
								</tr>
779
							</table>
780
							<?=gettext("Set this option to disable this server without removing it from the list"); ?>.
781
						</td>
782
					</tr>
783
					<tr>
784
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server Mode");?></td>
785
							<td width="78%" class="vtable">
786
							<select name='mode' id='mode' class="formselect" onchange='mode_change(); tuntap_change()'>
787
							<?php
788
								foreach ($openvpn_server_modes as $name => $desc):
789
									$selected = "";
790
									if ($pconfig['mode'] == $name)
791
										$selected = "selected=\"selected\"";
792
							?>
793
								<option value="<?=$name;?>" <?=$selected;?>><?=$desc;?></option>
794
							<?php endforeach; ?>
795
							</select>
796
						</td>
797
					</tr>
798
					<tr id="authmodetr" style="display:none">
799
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Backend for authentication");?></td>
800
						<td width="78%" class="vtable">
801
							<select name='authmode[]' id='authmode' class="formselect" multiple="multiple" size="<?php echo count($auth_servers); ?>">
802
							<?php
803
								$authmodes = explode(",", $pconfig['authmode']);
804
								$auth_servers = auth_get_authserver_list();
805
								// If no authmodes set then default to selecting the first entry in auth_servers
806
								if (empty($authmodes[0]) && !empty(key($auth_servers)))
807
									$authmodes[0] = key($auth_servers);
808

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

    
1425
					<tr id="chkboxNoTunIPv6">
1426
						<td width="22%" valign="top" class="vncell"><?=gettext("Disable IPv6"); ?></td>
1427
						<td width="78%" class="vtable">
1428
							<table border="0" cellpadding="2" cellspacing="0" summary="disable-ipv6-srv">
1429
								<tr>
1430
									<td>
1431
										<?php set_checked($pconfig['no_tun_ipv6'],$chk); ?>
1432
										<input name="no_tun_ipv6" type="checkbox" value="yes" <?=$chk;?> />
1433
									</td>
1434
									<td>
1435
										<span class="vexpl">
1436
											<?=gettext("Don't forward IPv6 traffic"); ?>.
1437
										</span>
1438
									</td>
1439
								</tr>
1440
							</table>
1441
						</td>
1442
					</tr>
1443

    
1444
				</table>
1445

    
1446
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts" summary="client settings">
1447
					<tr>
1448
						<td colspan="2" class="list" height="12"></td>
1449
					</tr>
1450
					<tr>
1451
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Client Settings"); ?></td>
1452
					</tr>
1453
					<tr>
1454
						<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic IP"); ?></td>
1455
						<td width="78%" class="vtable">
1456
							<table border="0" cellpadding="2" cellspacing="0" summary="dynamic ip">
1457
								<tr>
1458
									<td>
1459
										<?php set_checked($pconfig['dynamic_ip'],$chk); ?>
1460
										<input name="dynamic_ip" type="checkbox" id="dynamic_ip" value="yes" <?=$chk;?> />
1461
									</td>
1462
									<td>
1463
										<span class="vexpl">
1464
											<?=gettext("Allow connected clients to retain their connections if their IP address changes"); ?>.<br />
1465
										</span>
1466
									</td>
1467
								</tr>
1468
							</table>
1469
						</td>
1470
					</tr>
1471
					<tr>
1472
						<td width="22%" valign="top" class="vncell"><?=gettext("Address Pool"); ?></td>
1473
						<td width="78%" class="vtable">
1474
							<table border="0" cellpadding="2" cellspacing="0" summary="address pool">
1475
								<tr>
1476
									<td>
1477
										<?php set_checked($pconfig['pool_enable'],$chk); ?>
1478
										<input name="pool_enable" type="checkbox" id="pool_enable" value="yes" <?=$chk;?> />
1479
									</td>
1480
									<td>
1481
										<span class="vexpl">
1482
											<?=gettext("Provide a virtual adapter IP address to clients (see Tunnel Network)"); ?><br />
1483
										</span>
1484
									</td>
1485
								</tr>
1486
							</table>
1487
						</td>
1488
					</tr>
1489
					<tr id="topology_subnet_opt">
1490
						<td width="22%" valign="top" class="vncell"><?=gettext("Topology"); ?></td>
1491
						<td width="78%" class="vtable">
1492
							<table border="0" cellpadding="2" cellspacing="0" summary="topology">
1493
								<tr>
1494
									<td>
1495
										<?php set_checked($pconfig['topology_subnet'],$chk); ?>
1496
										<input name="topology_subnet" type="checkbox" id="topology_subnet" value="yes" <?=$chk;?> />
1497
									</td>
1498
									<td>
1499
										<span class="vexpl">
1500
											<?=gettext("Allocate only one IP per client (topology subnet), rather than an isolated subnet per client (topology net30)."); ?><br />
1501
										</span>
1502
									</td>
1503
								</tr>
1504
								<tr>
1505
									<td>&nbsp;</td>
1506
									<td>
1507
										<?=gettext("Relevant when supplying a virtual adapter IP address to clients when using tun mode on IPv4."); ?><br />
1508
										<?=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 />
1509
									</td>
1510
								</tr>
1511
							</table>
1512
						</td>
1513
					</tr>
1514
					<tr>
1515
						<td width="22%" valign="top" class="vncell"><?=gettext("DNS Default Domain"); ?></td>
1516
						<td width="78%" class="vtable">
1517
							<table border="0" cellpadding="2" cellspacing="0" summary="dns default domain">
1518
								<tr>
1519
									<td>
1520
										<?php set_checked($pconfig['dns_domain_enable'],$chk); ?>
1521
										<input name="dns_domain_enable" type="checkbox" id="dns_domain_enable" value="yes" <?=$chk;?> onclick="dns_domain_change()" />
1522
									</td>
1523
									<td>
1524
										<span class="vexpl">
1525
	                                        <?=gettext("Provide a default domain name to clients"); ?><br />
1526
										</span>
1527
									</td>
1528
								</tr>
1529
							</table>
1530
							<table border="0" cellpadding="2" cellspacing="0" id="dns_domain_data" summary="dns domain data">
1531
								<tr>
1532
									<td>
1533
										<input name="dns_domain" type="text" class="formfld unknown" id="dns_domain" size="30" value="<?=htmlspecialchars($pconfig['dns_domain']);?>" />
1534
									</td>
1535
								</tr>
1536
							</table>
1537
						</td>
1538
					</tr>
1539
					<tr>
1540
						<td width="22%" valign="top" class="vncell"><?=gettext("DNS Servers"); ?></td>
1541
						<td width="78%" class="vtable">
1542
							<table border="0" cellpadding="2" cellspacing="0" summary="dns servers">
1543
								<tr>
1544
									<td>
1545
										<?php set_checked($pconfig['dns_server_enable'],$chk); ?>
1546
										<input name="dns_server_enable" type="checkbox" id="dns_server_enable" value="yes" <?=$chk;?> onclick="dns_server_change()" />
1547
									</td>
1548
									<td>
1549
										<span class="vexpl">
1550
											<?=gettext("Provide a DNS server list to clients"); ?><br />
1551
										</span>
1552
									</td>
1553
								</tr>
1554
							</table>
1555
							<table border="0" cellpadding="2" cellspacing="0" id="dns_server_data" summary="dns servers">
1556
								<tr>
1557
									<td>
1558
										<span class="vexpl">
1559
											<?=gettext("Server"); ?> #1:&nbsp;
1560
										</span>
1561
										<input name="dns_server1" type="text" class="formfld unknown" id="dns_server1" size="20" value="<?=htmlspecialchars($pconfig['dns_server1']);?>" />
1562
									</td>
1563
								</tr>
1564
								<tr>
1565
									<td>
1566
										<span class="vexpl">
1567
											<?=gettext("Server"); ?> #2:&nbsp;
1568
										</span>
1569
										<input name="dns_server2" type="text" class="formfld unknown" id="dns_server2" size="20" value="<?=htmlspecialchars($pconfig['dns_server2']);?>" />
1570
									</td>
1571
								</tr>
1572
								<tr>
1573
									<td>
1574
										<span class="vexpl">
1575
											<?=gettext("Server"); ?> #3:&nbsp;
1576
										</span>
1577
										<input name="dns_server3" type="text" class="formfld unknown" id="dns_server3" size="20" value="<?=htmlspecialchars($pconfig['dns_server3']);?>" />
1578
									</td>
1579
								</tr>
1580
								<tr>
1581
									<td>
1582
										<span class="vexpl">
1583
											<?=gettext("Server"); ?> #4:&nbsp;
1584
										</span>
1585
										<input name="dns_server4" type="text" class="formfld unknown" id="dns_server4" size="20" value="<?=htmlspecialchars($pconfig['dns_server4']);?>" />
1586
									</td>
1587
								</tr>
1588
							</table>
1589
						</td>
1590
					</tr>
1591

    
1592
					<tr id="chkboxPushRegisterDNS">
1593
						<td width="22%" valign="top" class="vncell"><?=gettext("Force DNS cache update"); ?></td>
1594
						<td width="78%" class="vtable">
1595
							<table border="0" cellpadding="2" cellspacing="0" summary="push register dns">
1596
								<tr>
1597
									<td>
1598
										<?php set_checked($pconfig['push_register_dns'],$chk); ?>
1599
										<input name="push_register_dns" type="checkbox" value="yes" <?=$chk;?> />
1600
									</td>
1601
									<td>
1602
										<span class="vexpl">
1603
											<?=gettext("Run ''net stop dnscache'', ''net start dnscache'', ''ipconfig /flushdns'' and ''ipconfig /registerdns'' on connection initiation. This is known to kick Windows into recognizing pushed DNS servers."); ?><br />
1604
										</span>
1605
									</td>
1606
								</tr>
1607
							</table>
1608
						</td>
1609
					</tr>
1610

    
1611
					<tr>
1612
						<td width="22%" valign="top" class="vncell"><?=gettext("NTP Servers"); ?></td>
1613
						<td width="78%" class="vtable">
1614
							<table border="0" cellpadding="2" cellspacing="0" summary="ntp servers">
1615
								<tr>
1616
									<td>
1617
										<?php set_checked($pconfig['ntp_server_enable'],$chk); ?>
1618
										<input name="ntp_server_enable" type="checkbox" id="ntp_server_enable" value="yes" <?=$chk;?> onclick="ntp_server_change()" />
1619
									</td>
1620
									<td>
1621
										<span class="vexpl">
1622
											<?=gettext("Provide a NTP server list to clients"); ?><br />
1623
										</span>
1624
									</td>
1625
								</tr>
1626
							</table>
1627
							<table border="0" cellpadding="2" cellspacing="0" id="ntp_server_data" summary="ntp servers">
1628
								<tr>
1629
									<td>
1630
										<span class="vexpl">
1631
											<?=gettext("Server"); ?> #1:&nbsp;
1632
										</span>
1633
										<input name="ntp_server1" type="text" class="formfld unknown" id="ntp_server1" size="20" value="<?=htmlspecialchars($pconfig['ntp_server1']);?>" />
1634
									</td>
1635
								</tr>
1636
								<tr>
1637
									<td>
1638
										<span class="vexpl">
1639
											<?=gettext("Server"); ?> #2:&nbsp;
1640
										</span>
1641
										<input name="ntp_server2" type="text" class="formfld unknown" id="ntp_server2" size="20" value="<?=htmlspecialchars($pconfig['ntp_server2']);?>" />
1642
									</td>
1643
								</tr>
1644
							</table>
1645
						</td>
1646
					</tr>
1647
					<tr>
1648
						<td width="22%" valign="top" class="vncell"><?=gettext("NetBIOS Options"); ?></td>
1649
						<td width="78%" class="vtable">
1650
							<table border="0" cellpadding="2" cellspacing="0" summary="netboios options">
1651
								<tr>
1652
									<td>
1653
										<?php set_checked($pconfig['netbios_enable'],$chk); ?>
1654
										<input name="netbios_enable" type="checkbox" id="netbios_enable" value="yes" <?=$chk;?> onclick="netbios_change()" />
1655
									</td>
1656
									<td>
1657
										<span class="vexpl">
1658
											<?=gettext("Enable NetBIOS over TCP/IP"); ?><br />
1659
										</span>
1660
									</td>
1661
								</tr>
1662
							</table>
1663
							<?=gettext("If this option is not set, all NetBIOS-over-TCP/IP options (including WINS) will be disabled"); ?>.
1664
							<br />
1665
							<table border="0" cellpadding="2" cellspacing="0" id="netbios_data" summary="netboios options">
1666
								<tr>
1667
									<td>
1668
										<br />
1669
										<span class="vexpl">
1670
											<?=gettext("Node Type"); ?>:&nbsp;
1671
										</span>
1672
										<select name='netbios_ntype' class="formselect">
1673
										<?php
1674
											foreach ($netbios_nodetypes as $type => $name):
1675
												$selected = "";
1676
												if ($pconfig['netbios_ntype'] == $type)
1677
													$selected = "selected=\"selected\"";
1678
										?>
1679
											<option value="<?=$type;?>" <?=$selected;?>><?=$name;?></option>
1680
										<?php endforeach; ?>
1681
										</select>
1682
										<br />
1683
										<?=gettext("Possible options: b-node (broadcasts), p-node " .
1684
										"(point-to-point name queries to a WINS server), " .
1685
										"m-node (broadcast then query name server), and " .
1686
										"h-node (query name server, then broadcast)"); ?>.
1687
									</td>
1688
								</tr>
1689
								<tr>
1690
									<td>
1691
										<br />
1692
										<span class="vexpl">
1693
											<?=gettext("Scope ID"); ?>:&nbsp;
1694
										</span>
1695
										<input name="netbios_scope" type="text" class="formfld unknown" id="netbios_scope" size="30" value="<?=htmlspecialchars($pconfig['netbios_scope']);?>" />
1696
										<br />
1697
										<?=gettext("A NetBIOS Scope	ID provides an extended naming " .
1698
										"service for NetBIOS over TCP/IP. The NetBIOS " .
1699
										"scope ID isolates NetBIOS traffic on a single " .
1700
										"network to only those nodes with the same " .
1701
										"NetBIOS scope ID"); ?>.
1702
									</td>
1703
								</tr>
1704
							</table>
1705
						</td>
1706
					</tr>
1707
					<tr id="wins_opts">
1708
						<td width="22%" valign="top" class="vncell"><?=gettext("WINS Servers"); ?></td>
1709
						<td width="78%" class="vtable">
1710
							<table border="0" cellpadding="2" cellspacing="0" summary="wins servers">
1711
								<tr>
1712
									<td>
1713
										<?php set_checked($pconfig['wins_server_enable'],$chk); ?>
1714
										<input name="wins_server_enable" type="checkbox" id="wins_server_enable" value="yes" <?=$chk;?> onclick="wins_server_change()" />
1715
									</td>
1716
									<td>
1717
										<span class="vexpl">
1718
											<?=gettext("Provide a WINS server list to clients"); ?><br />
1719
										</span>
1720
									</td>
1721
								</tr>
1722
							</table>
1723
							<table border="0" cellpadding="2" cellspacing="0" id="wins_server_data" summary="wins servers">
1724
								<tr>
1725
									<td>
1726
										<span class="vexpl">
1727
											<?=gettext("Server"); ?> #1:&nbsp;
1728
										</span>
1729
										<input name="wins_server1" type="text" class="formfld unknown" id="wins_server1" size="20" value="<?=htmlspecialchars($pconfig['wins_server1']);?>" />
1730
									</td>
1731
								</tr>
1732
								<tr>
1733
									<td>
1734
										<span class="vexpl">
1735
											<?=gettext("Server"); ?> #2:&nbsp;
1736
										</span>
1737
										<input name="wins_server2" type="text" class="formfld unknown" id="wins_server2" size="20" value="<?=htmlspecialchars($pconfig['wins_server2']);?>" />
1738
									</td>
1739
								</tr>
1740
							</table>
1741
						</td>
1742
					</tr>
1743
					<tr>
1744
						<td width="22%" valign="top" class="vncell"><?=gettext("Client Management Port"); ?></td>
1745
						<td width="78%" class="vtable">
1746
							<table border="0" cellpadding="2" cellspacing="0" summary="client management port">
1747
								<tr>
1748
									<td>
1749
										<?php set_checked($pconfig['client_mgmt_port_enable'],$chk); ?>
1750
										<input name="client_mgmt_port_enable" type="checkbox" id="client_mgmt_port_enable" value="yes" <?=$chk;?> onclick="client_mgmt_port_change()" />
1751
									</td>
1752
									<td>
1753
										<span class="vexpl">
1754
	                                        <?=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 />
1755
										</span>
1756
									</td>
1757
								</tr>
1758
							</table>
1759
							<table border="0" cellpadding="2" cellspacing="0" id="client_mgmt_port_data" summary="client management port">
1760
								<tr>
1761
									<td>
1762
										<input name="client_mgmt_port" type="text" class="formfld unknown" id="client_mgmt_port" size="30" value="<?=htmlspecialchars($pconfig['client_mgmt_port']);?>" />
1763
									</td>
1764
								</tr>
1765
							</table>
1766
						</td>
1767
					</tr>
1768
				</table>
1769

    
1770
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts" summary="advance configuration">
1771
					<tr>
1772
						<td colspan="2" class="list" height="12"></td>
1773
					</tr>
1774
					<tr>
1775
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
1776
					</tr>
1777
					<tr>
1778
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1779
						<td width="78%" class="vtable">
1780
							<table border="0" cellpadding="2" cellspacing="0" summary="advance configuration">
1781
								<tr>
1782
									<td>
1783
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=htmlspecialchars($pconfig['custom_options']);?></textarea><br />
1784
										<?=gettext("Enter any additional options you would like to add to the OpenVPN server configuration here, separated by a semicolon"); ?><br />
1785
										<?=gettext("EXAMPLE: push \"route 10.0.0.0 255.255.255.0\""); ?>;
1786
									</td>
1787
								</tr>
1788
							</table>
1789
						</td>
1790
					</tr>
1791

    
1792
					<tr id="comboboxVerbosityLevel">
1793
						<td width="22%" valign="top" class="vncell"><?=gettext("Verbosity level");?></td>
1794
						<td width="78%" class="vtable">
1795
							<select name="verbosity_level" class="formselect">
1796
							<?php
1797
								foreach ($openvpn_verbosity_level as $verb_value => $verb_desc):
1798
									$selected = "";
1799
									if ($pconfig['verbosity_level'] == $verb_value)
1800
										$selected = "selected=\"selected\"";
1801
							?>
1802
								<option value="<?=$verb_value;?>" <?=$selected;?>><?=$verb_desc;?></option>
1803
							<?php endforeach; ?>
1804
							</select>
1805
							<br />
1806
							<?=gettext("Each level shows all info from the previous levels. Level 3 is recommended if you want a good summary of what's happening without being swamped by output"); ?>.<br /> <br />
1807
							<strong>none</strong> -- <?=gettext("No output except fatal errors"); ?>. <br />
1808
							<strong>default</strong>-<strong>4</strong> -- <?=gettext("Normal usage range"); ?>. <br />
1809
							<strong>5</strong> -- <?=gettext("Output R and W characters to the console for each packet read and write, uppercase is used for TCP/UDP packets and lowercase is used for TUN/TAP packets"); ?>. <br />
1810
							<strong>6</strong>-<strong>11</strong> -- <?=gettext("Debug info range"); ?>.
1811
						</td>
1812
					</tr>
1813

    
1814
				</table>
1815

    
1816
				<br />
1817
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="icons">
1818
					<tr>
1819
						<td width="22%" valign="top">&nbsp;</td>
1820
						<td width="78%"> 
1821
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" /> 
1822
							<input name="act" type="hidden" value="<?=$act;?>" />
1823
							<?php if (isset($id) && $a_server[$id]): ?>
1824
							<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
1825
							<?php endif; ?>
1826
						</td>
1827
					</tr>
1828
				</table>
1829
			</form>
1830

    
1831
			<?php else: ?>
1832

    
1833
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="list">
1834
				<thead>
1835
				<tr>
1836
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
1837
					<td width="10%" class="listhdrr"><?=gettext("Protocol / Port"); ?></td>
1838
					<td width="30%" class="listhdrr"><?=gettext("Tunnel Network"); ?></td>
1839
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
1840
					<td width="10%" class="list"></td>
1841
				</tr>
1842
				</thead>
1843
				<tfoot>
1844
				<tr>
1845
					<td class="list" colspan="4"></td>
1846
					<td class="list">
1847
						<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" alt="add" />
1848
						</a>
1849
					</td>
1850
				</tr>
1851
				</tfoot>
1852
				<tbody>
1853
				<?php
1854
					$i = 0;
1855
					foreach($a_server as $server):
1856
						$disabled = "NO";
1857
						if (isset($server['disable']))
1858
							$disabled = "YES";
1859
				?>
1860
				<tr>
1861
					<td class="listlr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>'">
1862
						<?=$disabled;?>
1863
					</td>
1864
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>'">
1865
						<?=htmlspecialchars($server['protocol']);?> / <?=htmlspecialchars($server['local_port']);?>
1866
					</td>
1867
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>'">
1868
						<?=htmlspecialchars($server['tunnel_network']);?><br />
1869
						<?=htmlspecialchars($server['tunnel_networkv6']);?><br />
1870
					</td>
1871
					<td class="listbg" ondblclick="document.location='vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>'">
1872
						<?=htmlspecialchars($server['description']);?>
1873
					</td>
1874
					<td valign="middle" class="list nowrap">
1875
						<a href="vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>">
1876
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit server"); ?>" width="17" height="17" border="0" alt="edit" />
1877
						</a>
1878
						&nbsp;
1879
						<a href="vpn_openvpn_server.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this server?"); ?>')">
1880
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete server"); ?>" width="17" height="17" border="0" alt="delete" />
1881
						</a>
1882
					</td>
1883
				</tr>
1884
				<?php
1885
					$i++;
1886
					endforeach;
1887
				?>
1888
				<tr style="display:none;"><td></td></tr>
1889
				</tbody>
1890
			</table>
1891

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

    
1894
			<?php endif; ?>
1895

    
1896
		</td>
1897
	</tr>
1898
</table>
1899
<script type="text/javascript">
1900
//<![CDATA[
1901
mode_change();
1902
autokey_change();
1903
tlsauth_change();
1904
gwredir_change();
1905
dns_domain_change();
1906
dns_server_change();
1907
wins_server_change();
1908
client_mgmt_port_change();
1909
ntp_server_change();
1910
netbios_change();
1911
tuntap_change();
1912
//]]>
1913
</script>
1914
<?php include("fend.inc"); ?>
1915
</body>
1916
</html>
1917
<?php
1918

    
1919
/* local utility functions */
1920

    
1921
function set_checked($var,& $chk) {
1922
	if($var)
1923
		$chk = "checked=\"checked\"";
1924
	else
1925
		$chk = "";
1926
}
1927

    
1928
?>
(249-249/256)