Projet

Général

Profil

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

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

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
		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
}
218
if ($_POST) {
219

    
220
	unset($input_errors);
221
	$pconfig = $_POST;
222

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

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

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

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

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

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

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

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

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

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

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

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

    
273
	if ($pconfig['autokey_enable'])
274
		$pconfig['shared_key'] = openvpn_create_key();
275

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

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

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

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

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

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

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

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

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

    
358
		$server = array();
359

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

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

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

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

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

    
412
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
413
		$server['pool_enable'] = $pconfig['pool_enable'];
414
		$server['topology_subnet'] = $pconfig['topology_subnet'];
415

    
416
		$server['serverbridge_dhcp'] = $pconfig['serverbridge_dhcp'];
417
		$server['serverbridge_interface'] = $pconfig['serverbridge_interface'];
418
		$server['serverbridge_dhcp_start'] = $pconfig['serverbridge_dhcp_start'];
419
		$server['serverbridge_dhcp_end'] = $pconfig['serverbridge_dhcp_end'];
420

    
421
		if ($pconfig['dns_domain_enable'])
422
			$server['dns_domain'] = $pconfig['dns_domain'];
423

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

    
431
		if ($pconfig['ntp_server_enable']) {
432
			$server['ntp_server1'] = $pconfig['ntp_server1'];
433
			$server['ntp_server2'] = $pconfig['ntp_server2'];
434
		}
435

    
436
		$server['netbios_enable'] = $pconfig['netbios_enable'];
437
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
438
		$server['netbios_scope'] = $pconfig['netbios_scope'];
439
		 
440
		// New features
441
		$server['no_tun_ipv6'] = $pconfig['no_tun_ipv6'];
442
		$server['verbosity_level'] = $pconfig['verbosity_level'];
443

    
444
		if ($pconfig['netbios_enable']) {
445

    
446
			if ($pconfig['wins_server_enable']) {
447
				$server['wins_server1'] = $pconfig['wins_server1'];
448
				$server['wins_server2'] = $pconfig['wins_server2'];
449
			}
450

    
451
			if ($pconfig['dns_server_enable'])
452
				$server['nbdd_server1'] = $pconfig['nbdd_server1'];
453
		}
454

    
455
		if ($pconfig['client_mgmt_port_enable'])
456
			$server['client_mgmt_port'] = $pconfig['client_mgmt_port'];
457

    
458
		if ($_POST['duplicate_cn'] == "yes")
459
			$server['duplicate_cn'] = true;
460

    
461
		if (isset($id) && $a_server[$id])
462
			$a_server[$id] = $server;
463
		else
464
			$a_server[] = $server;
465

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

    
478
include("head.inc");
479

    
480
?>
481

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

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

    
571
function autokey_change() {
572

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

    
579
function tlsauth_change() {
580

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

    
588
	autotls_change();
589
}
590

    
591
function autotls_change() {
592

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

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

    
605
function gwredir_change() {
606

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

    
616
function dns_domain_change() {
617

    
618
	if (document.iform.dns_domain_enable.checked)
619
		document.getElementById("dns_domain_data").style.display="";
620
	else
621
		document.getElementById("dns_domain_data").style.display="none";
622
}
623

    
624
function dns_server_change() {
625

    
626
	if (document.iform.dns_server_enable.checked)
627
		document.getElementById("dns_server_data").style.display="";
628
	else
629
		document.getElementById("dns_server_data").style.display="none";
630
}
631

    
632
function wins_server_change() {
633

    
634
	if (document.iform.wins_server_enable.checked)
635
		document.getElementById("wins_server_data").style.display="";
636
	else
637
		document.getElementById("wins_server_data").style.display="none";
638
}
639

    
640
function client_mgmt_port_change() {
641

    
642
	if (document.iform.client_mgmt_port_enable.checked)
643
		document.getElementById("client_mgmt_port_data").style.display="";
644
	else
645
		document.getElementById("client_mgmt_port_data").style.display="none";
646
}
647

    
648
function ntp_server_change() {
649

    
650
	if (document.iform.ntp_server_enable.checked)
651
		document.getElementById("ntp_server_data").style.display="";
652
	else
653
		document.getElementById("ntp_server_data").style.display="none";
654
}
655

    
656
function netbios_change() {
657

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

    
667
function tuntap_change() {
668

    
669
	mindex = document.iform.mode.selectedIndex;
670
	mvalue = document.iform.mode.options[mindex].value;
671

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

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

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

    
751
			<?php if($act=="new" || $act=="edit"): ?>
752

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

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

    
1434
				</table>
1435

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

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

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

    
1784
				</table>
1785

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

    
1801
			<?php else: ?>
1802

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

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

    
1864
			<?php endif; ?>
1865

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

    
1889
/* local utility functions */
1890

    
1891
function set_checked($var,& $chk) {
1892
    if($var)
1893
        $chk = "checked=\"checked\"";
1894
    else
1895
        $chk = "";
1896
}
1897

    
1898
?>
(248-248/255)