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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
360
		$server = array();
361

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
482
include("head.inc");
483

    
484
?>
485

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

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

    
575
function autokey_change() {
576

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

    
583
function tlsauth_change() {
584

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

    
592
	autotls_change();
593
}
594

    
595
function autotls_change() {
596

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

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

    
609
function gwredir_change() {
610

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

    
620
function dns_domain_change() {
621

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

    
628
function dns_server_change() {
629

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

    
636
function wins_server_change() {
637

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

    
644
function client_mgmt_port_change() {
645

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

    
652
function ntp_server_change() {
653

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

    
660
function netbios_change() {
661

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

    
671
function tuntap_change() {
672

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

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

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

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

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

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

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

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

    
1443
				</table>
1444

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

    
1591
					<tr id="chkboxPushRegisterDNS">
1592
						<td width="22%" valign="top" class="vncell"><?=gettext("Force DNS cache update"); ?></td>
1593
						<td width="78%" class="vtable">
1594
							<table border="0" cellpadding="2" cellspacing="0" summary="push register dns">
1595
								<tr>
1596
									<td>
1597
										<?php set_checked($pconfig['push_register_dns'],$chk); ?>
1598
										<input name="push_register_dns" type="checkbox" value="yes" <?=$chk;?> />
1599
									</td>
1600
									<td>
1601
										<span class="vexpl">
1602
											<?=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 />
1603
										</span>
1604
									</td>
1605
								</tr>
1606
							</table>
1607
						</td>
1608
					</tr>
1609

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

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

    
1791
					<tr id="comboboxVerbosityLevel">
1792
						<td width="22%" valign="top" class="vncell"><?=gettext("Verbosity level");?></td>
1793
						<td width="78%" class="vtable">
1794
							<select name="verbosity_level" class="formselect">
1795
							<?php
1796
								foreach ($openvpn_verbosity_level as $verb_value => $verb_desc):
1797
									$selected = "";
1798
									if ($pconfig['verbosity_level'] == $verb_value)
1799
										$selected = "selected=\"selected\"";
1800
							?>
1801
								<option value="<?=$verb_value;?>" <?=$selected;?>><?=$verb_desc;?></option>
1802
							<?php endforeach; ?>
1803
							</select>
1804
							<br />
1805
							<?=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 />
1806
							<strong>none</strong> -- <?=gettext("No output except fatal errors"); ?>. <br />
1807
							<strong>default</strong>-<strong>4</strong> -- <?=gettext("Normal usage range"); ?>. <br />
1808
							<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 />
1809
							<strong>6</strong>-<strong>11</strong> -- <?=gettext("Debug info range"); ?>.
1810
						</td>
1811
					</tr>
1812

    
1813
				</table>
1814

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

    
1830
			<?php else: ?>
1831

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

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

    
1893
			<?php endif; ?>
1894

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

    
1918
/* local utility functions */
1919

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

    
1927
?>
(245-245/252)