Projet

Général

Profil

Télécharger (76 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / vpn_openvpn_server.php @ caf58ced

1
<?php 
2
/*
3
	vpn_openvpn_server.php
4

    
5
	Copyright (C) 2008 Shrew Soft Inc.
6
	All rights reserved. 
7

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

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

    
37
require("guiconfig.inc");
38
require_once("openvpn.inc");
39

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
208
		$pconfig['duplicate_cn'] = isset($a_server[$id]['duplicate_cn']);
209
		
210
		// New features
211
		$pconfig['no_tun_ipv6'] = $a_server[$id]['no_tun_ipv6'];
212
		$pconfig['verbosity_level'] = $a_server[$id]['verbosity_level'];		
213
	}
214
}
215
if ($_POST) {
216

    
217
	unset($input_errors);
218
	$pconfig = $_POST;
219

    
220
	if (isset($id) && $a_server[$id])
221
		$vpnid = $a_server[$id]['vpnid'];
222
	else
223
		$vpnid = 0;
224

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

    
236
	if ($pconfig['mode'] != "p2p_shared_key")
237
		$tls_mode = true;
238
	else
239
		$tls_mode = false;
240

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

    
244
	/* input validation */
245
	if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
246
		$input_errors[] = $result;
247

    
248
	if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'IPv4 Tunnel Network', false, "ipv4"))
249
		$input_errors[] = $result;
250

    
251
	if ($result = openvpn_validate_cidr($pconfig['tunnel_networkv6'], 'IPv6 Tunnel Network', false, "ipv6"))
252
		$input_errors[] = $result;
253

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

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

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

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

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

    
270
	if ($pconfig['autokey_enable'])
271
		$pconfig['shared_key'] = openvpn_create_key();
272

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

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

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

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

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

    
317
	if ($pconfig['client_mgmt_port_enable']) {
318
		if ($result = openvpn_validate_port($pconfig['client_mgmt_port'], 'Client management port'))
319
			$input_errors[] = $result;
320
	}
321

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

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

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

    
355
		$server = array();
356

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

    
360
		if ($vpnid)
361
			$server['vpnid'] = $vpnid;
362
		else
363
			$server['vpnid'] = openvpn_vpnid_next();
364

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

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

    
397
		$server['tunnel_network'] = $pconfig['tunnel_network'];
398
		$server['tunnel_networkv6'] = $pconfig['tunnel_networkv6'];
399
		$server['remote_network'] = $pconfig['remote_network'];
400
		$server['remote_networkv6'] = $pconfig['remote_networkv6'];
401
		$server['gwredir'] = $pconfig['gwredir'];
402
		$server['local_network'] = $pconfig['local_network'];
403
		$server['local_networkv6'] = $pconfig['local_networkv6'];
404
		$server['maxclients'] = $pconfig['maxclients'];
405
		$server['compression'] = $pconfig['compression'];
406
		$server['passtos'] = $pconfig['passtos'];
407
		$server['client2client'] = $pconfig['client2client'];
408

    
409
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
410
		$server['pool_enable'] = $pconfig['pool_enable'];
411
		$server['topology_subnet'] = $pconfig['topology_subnet'];
412

    
413
		$server['serverbridge_dhcp'] = $pconfig['serverbridge_dhcp'];
414
		$server['serverbridge_interface'] = $pconfig['serverbridge_interface'];
415
		$server['serverbridge_dhcp_start'] = $pconfig['serverbridge_dhcp_start'];
416
		$server['serverbridge_dhcp_end'] = $pconfig['serverbridge_dhcp_end'];
417

    
418
		if ($pconfig['dns_domain_enable'])
419
			$server['dns_domain'] = $pconfig['dns_domain'];
420

    
421
		if ($pconfig['dns_server_enable']) {
422
			$server['dns_server1'] = $pconfig['dns_server1'];
423
			$server['dns_server2'] = $pconfig['dns_server2'];
424
			$server['dns_server3'] = $pconfig['dns_server3'];
425
			$server['dns_server4'] = $pconfig['dns_server4'];
426
		}
427

    
428
		if ($pconfig['ntp_server_enable']) {
429
			$server['ntp_server1'] = $pconfig['ntp_server1'];
430
			$server['ntp_server2'] = $pconfig['ntp_server2'];
431
		}
432

    
433
		$server['netbios_enable'] = $pconfig['netbios_enable'];
434
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
435
		$server['netbios_scope'] = $pconfig['netbios_scope'];
436
		 
437
		// New features
438
		$server['no_tun_ipv6'] = $pconfig['no_tun_ipv6'];
439
		$server['verbosity_level'] = $pconfig['verbosity_level'];
440

    
441
		if ($pconfig['netbios_enable']) {
442

    
443
			if ($pconfig['wins_server_enable']) {
444
				$server['wins_server1'] = $pconfig['wins_server1'];
445
				$server['wins_server2'] = $pconfig['wins_server2'];
446
			}
447

    
448
			if ($pconfig['dns_server_enable'])
449
				$server['nbdd_server1'] = $pconfig['nbdd_server1'];
450
		}
451

    
452
		if ($pconfig['client_mgmt_port_enable'])
453
			$server['client_mgmt_port'] = $pconfig['client_mgmt_port'];
454

    
455
		if ($_POST['duplicate_cn'] == "yes")
456
			$server['duplicate_cn'] = true;
457

    
458
		if (isset($id) && $a_server[$id])
459
			$a_server[$id] = $server;
460
		else
461
			$a_server[] = $server;
462

    
463
		openvpn_resync('server', $server);
464
		write_config();
465
		
466
		header("Location: vpn_openvpn_server.php");
467
		exit;
468
	}
469
	if (!empty($pconfig['authmode']))
470
		$pconfig['authmode'] = implode(",", $pconfig['authmode']);
471
}
472
$pgtitle = array(gettext("OpenVPN"), gettext("Server"));
473
$shortcut_section = "openvpn";
474

    
475
include("head.inc");
476

    
477
?>
478

    
479
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
480
<?php include("fbegin.inc"); ?>
481
<script type="text/javascript">
482
//<![CDATA[
483

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

    
568
function autokey_change() {
569

    
570
	if ((document.iform.autokey_enable != null) && (document.iform.autokey_enable.checked))
571
		document.getElementById("autokey_opts").style.display="none";
572
	else
573
		document.getElementById("autokey_opts").style.display="";
574
}
575

    
576
function tlsauth_change() {
577

    
578
<?php if (!$pconfig['tls']): ?>
579
	if (document.iform.tlsauth_enable.checked)
580
		document.getElementById("tlsauth_opts").style.display="";
581
	else
582
		document.getElementById("tlsauth_opts").style.display="none";
583
<?php endif; ?>
584

    
585
	autotls_change();
586
}
587

    
588
function autotls_change() {
589

    
590
<?php if (!$pconfig['tls']): ?>
591
	autocheck = document.iform.autotls_enable.checked;
592
<?php else: ?>
593
	autocheck = false;
594
<?php endif; ?>
595

    
596
	if (document.iform.tlsauth_enable.checked && !autocheck)
597
		document.getElementById("autotls_opts").style.display="";
598
	else
599
		document.getElementById("autotls_opts").style.display="none";
600
}
601

    
602
function gwredir_change() {
603

    
604
	if (document.iform.gwredir.checked) {
605
		document.getElementById("local_optsv4").style.display="none";
606
		document.getElementById("local_optsv6").style.display="none";
607
	} else {
608
		document.getElementById("local_optsv4").style.display="";
609
		document.getElementById("local_optsv6").style.display="";
610
	}
611
}
612

    
613
function dns_domain_change() {
614

    
615
	if (document.iform.dns_domain_enable.checked)
616
		document.getElementById("dns_domain_data").style.display="";
617
	else
618
		document.getElementById("dns_domain_data").style.display="none";
619
}
620

    
621
function dns_server_change() {
622

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

    
629
function wins_server_change() {
630

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

    
637
function client_mgmt_port_change() {
638

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

    
645
function ntp_server_change() {
646

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

    
653
function netbios_change() {
654

    
655
	if (document.iform.netbios_enable.checked) {
656
		document.getElementById("netbios_data").style.display="";
657
		document.getElementById("wins_opts").style.display="";
658
	} else {
659
		document.getElementById("netbios_data").style.display="none";
660
		document.getElementById("wins_opts").style.display="none";
661
	}
662
}
663

    
664
function tuntap_change() {
665

    
666
	mindex = document.iform.mode.selectedIndex;
667
	mvalue = document.iform.mode.options[mindex].value;
668

    
669
	switch(mvalue) {
670
		case "p2p_tls":
671
		case "p2p_shared_key":
672
			p2p = true;
673
			break;
674
		default:
675
			p2p = false;
676
			break;
677
	}
678

    
679
	index = document.iform.dev_mode.selectedIndex;
680
	value = document.iform.dev_mode.options[index].value;
681
	switch(value) {
682
		case "tun":
683
			document.getElementById("chkboxNoTunIPv6").style.display="";
684
			document.getElementById("ipv4_tunnel_network").className="vncellreq";
685
			document.getElementById("serverbridge_dhcp").style.display="none";
686
			document.getElementById("serverbridge_interface").style.display="none";
687
			document.getElementById("serverbridge_dhcp_start").style.display="none";
688
			document.getElementById("serverbridge_dhcp_end").style.display="none";
689
			document.getElementById("topology_subnet_opt").style.display="";
690
			break;
691
		case "tap":
692
			document.getElementById("chkboxNoTunIPv6").style.display="none";
693
			document.getElementById("ipv4_tunnel_network").className="vncell";
694
			if (!p2p) {
695
				document.getElementById("serverbridge_dhcp").style.display="";
696
				document.getElementById("serverbridge_interface").style.display="";
697
				document.getElementById("serverbridge_dhcp_start").style.display="";
698
				document.getElementById("serverbridge_dhcp_end").style.display="";
699
				document.getElementById("topology_subnet_opt").style.display="none";
700
				document.iform.serverbridge_dhcp.disabled = false;
701
				if (document.iform.serverbridge_dhcp.checked) {
702
					document.iform.serverbridge_interface.disabled = false;
703
					document.iform.serverbridge_dhcp_start.disabled = false;
704
					document.iform.serverbridge_dhcp_end.disabled = false;
705
				} else {
706
					document.iform.serverbridge_interface.disabled = true;
707
					document.iform.serverbridge_dhcp_start.disabled = true;
708
					document.iform.serverbridge_dhcp_end.disabled = true;
709
				}
710
			} else {
711
				document.getElementById("topology_subnet_opt").style.display="none";
712
				document.iform.serverbridge_dhcp.disabled = true;
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
			break;
718
	}
719
}
720
//]]>
721
</script>
722
<?php
723
if (!$savemsg)
724
	$savemsg = "";
725

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

    
748
			<?php if($act=="new" || $act=="edit"): ?>
749

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

    
1412
					<tr id="chkboxNoTunIPv6">
1413
						<td width="22%" valign="top" class="vncell"><?=gettext("Disable IPv6"); ?></td>
1414
						<td width="78%" class="vtable">
1415
							<table border="0" cellpadding="2" cellspacing="0" summary="disable-ipv6-srv">
1416
								<tr>
1417
									<td>
1418
										<?php set_checked($pconfig['no_tun_ipv6'],$chk); ?>
1419
										<input name="no_tun_ipv6" type="checkbox" value="yes" <?=$chk;?> />
1420
									</td>
1421
									<td>
1422
										<span class="vexpl">
1423
											<?=gettext("Do not forward IPv6 traffic"); ?>.
1424
										</span>
1425
									</td>
1426
								</tr>
1427
							</table>
1428
						</td>
1429
					</tr>
1430

    
1431
				</table>
1432

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

    
1737
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts" summary="advance configuration">
1738
					<tr>
1739
						<td colspan="2" class="list" height="12"></td>
1740
					</tr>
1741
					<tr>
1742
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
1743
					</tr>
1744
					<tr>
1745
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1746
						<td width="78%" class="vtable">
1747
							<table border="0" cellpadding="2" cellspacing="0" summary="advance configuration">
1748
								<tr>
1749
									<td>
1750
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=htmlspecialchars($pconfig['custom_options']);?></textarea><br />
1751
										<?=gettext("Enter any additional options you would like to add to the OpenVPN server configuration here, separated by a semicolon"); ?><br />
1752
										<?=gettext("EXAMPLE: push \"route 10.0.0.0 255.255.255.0\""); ?>;
1753
									</td>
1754
								</tr>
1755
							</table>
1756
						</td>
1757
					</tr>
1758

    
1759
					<tr id="comboboxVerbosityLevel">
1760
							<td width="22%" valign="top" class="vncell"><?=gettext("Verbosity level");?></td>
1761
							<td width="78%" class="vtable">
1762
							<select name="verbosity_level" class="formselect">
1763
							<?php
1764
								foreach ($openvpn_verbosity_level as $verb_value => $verb_desc):
1765
									$selected = "";
1766
									if ($pconfig['verbosity_level'] == $verb_value)
1767
										$selected = "selected=\"selected\"";
1768
							?>
1769
								<option value="<?=$verb_value;?>" <?=$selected;?>><?=$verb_desc;?></option>
1770
							<?php endforeach; ?>
1771
							</select>
1772
							<br />
1773
							<?=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 />
1774
							<strong>none</strong> -- <?=gettext("No output except fatal errors"); ?>. <br />
1775
							<strong>default</strong>-<strong>4</strong> -- <?=gettext("Normal usage range"); ?>. <br />
1776
							<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 />
1777
							<strong>6</strong>-<strong>11</strong> -- <?=gettext("Debug info range"); ?>.
1778
							</td>
1779
					</tr>
1780

    
1781
				</table>
1782

    
1783
				<br />
1784
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="icons">
1785
					<tr>
1786
						<td width="22%" valign="top">&nbsp;</td>
1787
						<td width="78%"> 
1788
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" /> 
1789
							<input name="act" type="hidden" value="<?=$act;?>" />
1790
							<?php if (isset($id) && $a_server[$id]): ?>
1791
							<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
1792
							<?php endif; ?>
1793
						</td>
1794
					</tr>
1795
				</table>
1796
			</form>
1797

    
1798
			<?php else: ?>
1799

    
1800
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="list">
1801
				<thead>
1802
				<tr>
1803
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
1804
					<td width="10%" class="listhdrr"><?=gettext("Protocol / Port"); ?></td>
1805
					<td width="30%" class="listhdrr"><?=gettext("Tunnel Network"); ?></td>
1806
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
1807
					<td width="10%" class="list"></td>
1808
				</tr>
1809
				</thead>
1810
				<tfoot>
1811
				<tr>
1812
					<td class="list" colspan="4"></td>
1813
					<td class="list">
1814
						<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" />
1815
						</a>
1816
					</td>
1817
				</tr>
1818
				</tfoot>
1819
				<tbody>
1820
				<?php
1821
					$i = 0;
1822
					foreach($a_server as $server):
1823
						$disabled = "NO";
1824
						if (isset($server['disable']))
1825
							$disabled = "YES";
1826
				?>
1827
				<tr>
1828
					<td class="listlr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>'">
1829
						<?=$disabled;?>
1830
					</td>
1831
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>'">
1832
						<?=htmlspecialchars($server['protocol']);?> / <?=htmlspecialchars($server['local_port']);?>
1833
					</td>
1834
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>'">
1835
						<?=htmlspecialchars($server['tunnel_network']);?><br />
1836
						<?=htmlspecialchars($server['tunnel_networkv6']);?><br />
1837
					</td>
1838
					<td class="listbg" ondblclick="document.location='vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>'">
1839
						<?=htmlspecialchars($server['description']);?>
1840
					</td>
1841
					<td valign="middle" class="list nowrap">
1842
						<a href="vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>">
1843
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit server"); ?>" width="17" height="17" border="0" alt="edit" />
1844
						</a>
1845
						&nbsp;
1846
						<a href="vpn_openvpn_server.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this server?"); ?>')">
1847
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete server"); ?>" width="17" height="17" border="0" alt="delete" />
1848
						</a>
1849
					</td>
1850
				</tr>
1851
				<?php
1852
					$i++;
1853
					endforeach;
1854
				?>
1855
				<tr style="dispaly:none;"><td></td></tr>
1856
				</tbody>
1857
			</table>
1858

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

    
1861
			<?php endif; ?>
1862

    
1863
		</td>
1864
	</tr>
1865
</table>
1866
<script type="text/javascript">
1867
//<![CDATA[
1868
mode_change();
1869
autokey_change();
1870
tlsauth_change();
1871
gwredir_change();
1872
dns_domain_change();
1873
dns_server_change();
1874
wins_server_change();
1875
client_mgmt_port_change();
1876
ntp_server_change();
1877
netbios_change();
1878
tuntap_change();
1879
//]]>
1880
</script>
1881
<?php include("fend.inc"); ?>
1882
</body>
1883
</html>
1884
<?php
1885

    
1886
/* local utility functions */
1887

    
1888
function set_checked($var,& $chk) {
1889
    if($var)
1890
        $chk = "checked=\"checked\"";
1891
    else
1892
        $chk = "";
1893
}
1894

    
1895
?>
(248-248/255)