Projet

Général

Profil

Télécharger (73,6 ko) Statistiques
| Branche: | Tag: | Révision:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
350
		$server = array();
351

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
466
include("head.inc");
467

    
468
?>
469

    
470
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
471
<?php include("fbegin.inc"); ?>
472
<script type="text/javascript">
473
//<![CDATA[
474

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

    
559
function autokey_change() {
560

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

    
567
function tlsauth_change() {
568

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

    
576
	autotls_change();
577
}
578

    
579
function autotls_change() {
580

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

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

    
593
function gwredir_change() {
594

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

    
604
function dns_domain_change() {
605

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

    
612
function dns_server_change() {
613

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

    
620
function wins_server_change() {
621

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

    
628
function client_mgmt_port_change() {
629

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

    
636
function ntp_server_change() {
637

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

    
644
function netbios_change() {
645

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

    
655
function tuntap_change() {
656

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

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

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

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

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

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

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

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

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

    
1744
			<?php else: ?>
1745

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

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

    
1807
			<?php endif; ?>
1808

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

    
1832
/* local utility functions */
1833

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

    
1841
?>
(248-248/255)