Project

General

Profile

Download (71.1 KB) Statistics
| Branch: | Tag: | Revision:
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
$id = $_GET['id'];
65
if (isset($_POST['id']))
66
	$id = $_POST['id'];
67

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

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

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

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

    
90
if($_GET['act']=="new"){
91
	$pconfig['autokey_enable'] = "yes";
92
	$pconfig['tlsauth_enable'] = "yes";
93
	$pconfig['autotls_enable'] = "yes";
94
	$pconfig['dh_length'] = 1024;
95
	$pconfig['dev_mode'] = "tun";
96
	$pconfig['interface'] = "wan";
97
	$pconfig['local_port'] = openvpn_port_next('UDP');
98
	$pconfig['pool_enable'] = "yes";
99
	$pconfig['cert_depth'] = 1;
100
}
101

    
102
if($_GET['act']=="edit"){
103

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

    
118
		if ($pconfig['mode'] != "p2p_shared_key") {
119
			if ($a_server[$id]['tls']) {
120
				$pconfig['tlsauth_enable'] = "yes";
121
				$pconfig['tls'] = base64_decode($a_server[$id]['tls']);
122
			}
123
			$pconfig['caref'] = $a_server[$id]['caref'];
124
			$pconfig['crlref'] = $a_server[$id]['crlref'];
125
			$pconfig['certref'] = $a_server[$id]['certref'];
126
			$pconfig['dh_length'] = $a_server[$id]['dh_length'];
127
			if (isset($a_server[$id]['cert_depth']))
128
				$pconfig['cert_depth'] = $a_server[$id]['cert_depth'];
129
			else
130
				$pconfig['cert_depth'] = 1;
131
			if ($pconfig['mode'] == "server_tls_user")
132
				$pconfig['strictusercn'] = $a_server[$id]['strictusercn'];
133
		} else
134
			$pconfig['shared_key'] = base64_decode($a_server[$id]['shared_key']);
135
		$pconfig['crypto'] = $a_server[$id]['crypto'];
136
		$pconfig['engine'] = $a_server[$id]['engine'];
137

    
138
		$pconfig['tunnel_network'] = $a_server[$id]['tunnel_network'];
139
		$pconfig['tunnel_networkv6'] = $a_server[$id]['tunnel_networkv6'];
140

    
141
		$pconfig['remote_network'] = $a_server[$id]['remote_network'];
142
		$pconfig['remote_networkv6'] = $a_server[$id]['remote_networkv6'];
143
		$pconfig['gwredir'] = $a_server[$id]['gwredir'];
144
		$pconfig['local_network'] = $a_server[$id]['local_network'];
145
		$pconfig['local_networkv6'] = $a_server[$id]['local_networkv6'];
146
		$pconfig['maxclients'] = $a_server[$id]['maxclients'];
147
		$pconfig['compression'] = $a_server[$id]['compression'];
148
		$pconfig['passtos'] = $a_server[$id]['passtos'];
149
		$pconfig['client2client'] = $a_server[$id]['client2client'];
150

    
151
		$pconfig['dynamic_ip'] = $a_server[$id]['dynamic_ip'];
152
		$pconfig['pool_enable'] = $a_server[$id]['pool_enable'];
153
		$pconfig['topology_subnet'] = $a_server[$id]['topology_subnet'];
154

    
155
		$pconfig['serverbridge_dhcp'] = $a_server[$id]['serverbridge_dhcp'];
156
		$pconfig['serverbridge_interface'] = $a_server[$id]['serverbridge_interface'];
157
		$pconfig['serverbridge_dhcp_start'] = $a_server[$id]['serverbridge_dhcp_start'];
158
		$pconfig['serverbridge_dhcp_end'] = $a_server[$id]['serverbridge_dhcp_end'];
159

    
160
		$pconfig['dns_domain'] = $a_server[$id]['dns_domain'];
161
		if ($pconfig['dns_domain'])
162
			$pconfig['dns_domain_enable'] = true;
163

    
164
		$pconfig['dns_server1'] = $a_server[$id]['dns_server1'];
165
		$pconfig['dns_server2'] = $a_server[$id]['dns_server2'];
166
		$pconfig['dns_server3'] = $a_server[$id]['dns_server3'];
167
		$pconfig['dns_server4'] = $a_server[$id]['dns_server4'];
168
		if ($pconfig['dns_server1'] ||
169
			$pconfig['dns_server2'] ||
170
			$pconfig['dns_server3'] ||
171
			$pconfig['dns_server4'])
172
			$pconfig['dns_server_enable'] = true;
173

    
174
		$pconfig['ntp_server1'] = $a_server[$id]['ntp_server1'];
175
		$pconfig['ntp_server2'] = $a_server[$id]['ntp_server2'];
176
		if ($pconfig['ntp_server1'] ||
177
			$pconfig['ntp_server2'])
178
			$pconfig['ntp_server_enable'] = true;
179

    
180
		$pconfig['netbios_enable'] = $a_server[$id]['netbios_enable'];
181
		$pconfig['netbios_ntype'] = $a_server[$id]['netbios_ntype'];
182
		$pconfig['netbios_scope'] = $a_server[$id]['netbios_scope'];
183

    
184
		$pconfig['wins_server1'] = $a_server[$id]['wins_server1'];
185
		$pconfig['wins_server2'] = $a_server[$id]['wins_server2'];
186
		if ($pconfig['wins_server1'] ||
187
			$pconfig['wins_server2'])
188
			$pconfig['wins_server_enable'] = true;
189

    
190
		$pconfig['client_mgmt_port'] = $a_server[$id]['client_mgmt_port'];
191
		if ($pconfig['client_mgmt_port'])
192
			$pconfig['client_mgmt_port_enable'] = true;
193

    
194
		$pconfig['nbdd_server1'] = $a_server[$id]['nbdd_server1'];
195
		if ($pconfig['nbdd_server1'])
196
			$pconfig['nbdd_server_enable'] = true;
197

    
198
		// just in case the modes switch
199
		$pconfig['autokey_enable'] = "yes";
200
		$pconfig['autotls_enable'] = "yes";
201

    
202
		$pconfig['duplicate_cn'] = isset($a_server[$id]['duplicate_cn']);
203
	}
204
}
205
if ($_POST) {
206

    
207
	unset($input_errors);
208
	$pconfig = $_POST;
209

    
210
	if (isset($id) && $a_server[$id])
211
		$vpnid = $a_server[$id]['vpnid'];
212
	else
213
		$vpnid = 0;
214

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

    
226
	if ($pconfig['mode'] != "p2p_shared_key")
227
		$tls_mode = true;
228
	else
229
		$tls_mode = false;
230

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

    
234
	/* input validation */
235
	if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
236
		$input_errors[] = $result;
237

    
238
	if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'IPv4 Tunnel Network', false, "ipv4"))
239
		$input_errors[] = $result;
240

    
241
	if ($result = openvpn_validate_cidr($pconfig['tunnel_networkv6'], 'IPv6 Tunnel Network', false, "ipv6"))
242
		$input_errors[] = $result;
243

    
244
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'IPv4 Remote Network', true, "ipv4"))
245
		$input_errors[] = $result;
246

    
247
	if ($result = openvpn_validate_cidr($pconfig['remote_networkv6'], 'IPv6 Remote Network', true, "ipv6"))
248
		$input_errors[] = $result;
249

    
250
	if ($result = openvpn_validate_cidr($pconfig['local_network'], 'IPv4 Local Network', true, "ipv4"))
251
		$input_errors[] = $result;
252

    
253
	if ($result = openvpn_validate_cidr($pconfig['local_networkv6'], 'IPv6 Local Network', true, "ipv6"))
254
		$input_errors[] = $result;
255

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

    
260
	if ($pconfig['autokey_enable'])
261
		$pconfig['shared_key'] = openvpn_create_key();
262

    
263
	if (!$tls_mode && !$pconfig['autokey_enable'])
264
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
265
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
266
			$input_errors[] = gettext("The field 'Shared Key' does not appear to be valid");
267

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

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

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

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

    
307
	if ($pconfig['client_mgmt_port_enable']) {
308
		if ($result = openvpn_validate_port($pconfig['client_mgmt_port'], 'Client management port'))
309
			$input_errors[] = $result;
310
	}
311

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

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

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

    
345
		$server = array();
346

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

    
350
		if ($vpnid)
351
			$server['vpnid'] = $vpnid;
352
		else
353
			$server['vpnid'] = openvpn_vpnid_next();
354

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

    
367
		if ($tls_mode) {
368
			if ($pconfig['tlsauth_enable']) {
369
				if ($pconfig['autotls_enable'])
370
					$pconfig['tls'] = openvpn_create_key();
371
				$server['tls'] = base64_encode($pconfig['tls']);
372
			}
373
			$server['caref'] = $pconfig['caref'];
374
			$server['crlref'] = $pconfig['crlref'];
375
			$server['certref'] = $pconfig['certref'];
376
			$server['dh_length'] = $pconfig['dh_length'];
377
			$server['cert_depth'] = $pconfig['cert_depth'];
378
			if ($pconfig['mode'] == "server_tls_user")
379
				$server['strictusercn'] = $pconfig['strictusercn'];
380
		} else {
381
			$server['shared_key'] = base64_encode($pconfig['shared_key']);
382
		}
383
		$server['crypto'] = $pconfig['crypto'];
384
		$server['engine'] = $pconfig['engine'];
385

    
386
		$server['tunnel_network'] = $pconfig['tunnel_network'];
387
		$server['tunnel_networkv6'] = $pconfig['tunnel_networkv6'];
388
		$server['remote_network'] = $pconfig['remote_network'];
389
		$server['remote_networkv6'] = $pconfig['remote_networkv6'];
390
		$server['gwredir'] = $pconfig['gwredir'];
391
		$server['local_network'] = $pconfig['local_network'];
392
		$server['local_networkv6'] = $pconfig['local_networkv6'];
393
		$server['maxclients'] = $pconfig['maxclients'];
394
		$server['compression'] = $pconfig['compression'];
395
		$server['passtos'] = $pconfig['passtos'];
396
		$server['client2client'] = $pconfig['client2client'];
397

    
398
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
399
		$server['pool_enable'] = $pconfig['pool_enable'];
400
		$server['topology_subnet'] = $pconfig['topology_subnet'];
401

    
402
		$server['serverbridge_dhcp'] = $pconfig['serverbridge_dhcp'];
403
		$server['serverbridge_interface'] = $pconfig['serverbridge_interface'];
404
		$server['serverbridge_dhcp_start'] = $pconfig['serverbridge_dhcp_start'];
405
		$server['serverbridge_dhcp_end'] = $pconfig['serverbridge_dhcp_end'];
406

    
407
		if ($pconfig['dns_domain_enable'])
408
			$server['dns_domain'] = $pconfig['dns_domain'];
409

    
410
		if ($pconfig['dns_server_enable']) {
411
			$server['dns_server1'] = $pconfig['dns_server1'];
412
			$server['dns_server2'] = $pconfig['dns_server2'];
413
			$server['dns_server3'] = $pconfig['dns_server3'];
414
			$server['dns_server4'] = $pconfig['dns_server4'];
415
		}
416

    
417
		if ($pconfig['ntp_server_enable']) {
418
			$server['ntp_server1'] = $pconfig['ntp_server1'];
419
			$server['ntp_server2'] = $pconfig['ntp_server2'];
420
		}
421

    
422
		$server['netbios_enable'] = $pconfig['netbios_enable'];
423
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
424
		$server['netbios_scope'] = $pconfig['netbios_scope'];
425

    
426
		if ($pconfig['netbios_enable']) {
427

    
428
			if ($pconfig['wins_server_enable']) {
429
				$server['wins_server1'] = $pconfig['wins_server1'];
430
				$server['wins_server2'] = $pconfig['wins_server2'];
431
			}
432

    
433
			if ($pconfig['dns_server_enable'])
434
				$server['nbdd_server1'] = $pconfig['nbdd_server1'];
435
		}
436

    
437
		if ($pconfig['client_mgmt_port_enable'])
438
			$server['client_mgmt_port'] = $pconfig['client_mgmt_port'];
439

    
440
		if ($_POST['duplicate_cn'] == "yes")
441
			$server['duplicate_cn'] = true;
442

    
443
		if (isset($id) && $a_server[$id])
444
			$a_server[$id] = $server;
445
		else
446
			$a_server[] = $server;
447

    
448
		openvpn_resync('server', $server);
449
		write_config();
450
		
451
		header("Location: vpn_openvpn_server.php");
452
		exit;
453
	}
454
	if (!empty($pconfig['authmode']))
455
		$pconfig['authmode'] = implode(",", $pconfig['authmode']);
456
}
457
$pgtitle = array(gettext("OpenVPN"), gettext("Server"));
458
$shortcut_section = "openvpn";
459

    
460
include("head.inc");
461

    
462
?>
463

    
464
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
465
<?php include("fbegin.inc"); ?>
466
<script language="JavaScript">
467
<!--
468

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

    
553
function autokey_change() {
554

    
555
	if ((document.iform.autokey_enable != null) && (document.iform.autokey_enable.checked))
556
		document.getElementById("autokey_opts").style.display="none";
557
	else
558
		document.getElementById("autokey_opts").style.display="";
559
}
560

    
561
function tlsauth_change() {
562

    
563
<?php if (!$pconfig['tls']): ?>
564
	if (document.iform.tlsauth_enable.checked)
565
		document.getElementById("tlsauth_opts").style.display="";
566
	else
567
		document.getElementById("tlsauth_opts").style.display="none";
568
<?php endif; ?>
569

    
570
	autotls_change();
571
}
572

    
573
function autotls_change() {
574

    
575
<?php if (!$pconfig['tls']): ?>
576
	autocheck = document.iform.autotls_enable.checked;
577
<?php else: ?>
578
	autocheck = false;
579
<?php endif; ?>
580

    
581
	if (document.iform.tlsauth_enable.checked && !autocheck)
582
		document.getElementById("autotls_opts").style.display="";
583
	else
584
		document.getElementById("autotls_opts").style.display="none";
585
}
586

    
587
function gwredir_change() {
588

    
589
	if (document.iform.gwredir.checked) {
590
		document.getElementById("local_optsv4").style.display="none";
591
		document.getElementById("local_optsv6").style.display="none";
592
	} else {
593
		document.getElementById("local_optsv4").style.display="";
594
		document.getElementById("local_optsv6").style.display="";
595
	}
596
}
597

    
598
function dns_domain_change() {
599

    
600
	if (document.iform.dns_domain_enable.checked)
601
		document.getElementById("dns_domain_data").style.display="";
602
	else
603
		document.getElementById("dns_domain_data").style.display="none";
604
}
605

    
606
function dns_server_change() {
607

    
608
	if (document.iform.dns_server_enable.checked)
609
		document.getElementById("dns_server_data").style.display="";
610
	else
611
		document.getElementById("dns_server_data").style.display="none";
612
}
613

    
614
function wins_server_change() {
615

    
616
	if (document.iform.wins_server_enable.checked)
617
		document.getElementById("wins_server_data").style.display="";
618
	else
619
		document.getElementById("wins_server_data").style.display="none";
620
}
621

    
622
function client_mgmt_port_change() {
623

    
624
	if (document.iform.client_mgmt_port_enable.checked)
625
		document.getElementById("client_mgmt_port_data").style.display="";
626
	else
627
		document.getElementById("client_mgmt_port_data").style.display="none";
628
}
629

    
630
function ntp_server_change() {
631

    
632
	if (document.iform.ntp_server_enable.checked)
633
		document.getElementById("ntp_server_data").style.display="";
634
	else
635
		document.getElementById("ntp_server_data").style.display="none";
636
}
637

    
638
function netbios_change() {
639

    
640
	if (document.iform.netbios_enable.checked) {
641
		document.getElementById("netbios_data").style.display="";
642
		document.getElementById("wins_opts").style.display="";
643
	} else {
644
		document.getElementById("netbios_data").style.display="none";
645
		document.getElementById("wins_opts").style.display="none";
646
	}
647
}
648

    
649
function tuntap_change() {
650

    
651
	mindex = document.iform.mode.selectedIndex;
652
	mvalue = document.iform.mode.options[mindex].value;
653

    
654
	switch(mvalue) {
655
		case "p2p_tls":
656
		case "p2p_shared_key":
657
			p2p = true;
658
			break;
659
		default:
660
			p2p = false;
661
			break;
662
	}
663

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

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

    
733
			<?php if($act=="new" || $act=="edit"): ?>
734

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

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

    
1685
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1686
					<tr>
1687
						<td colspan="2" class="list" height="12"></td>
1688
					</tr>
1689
					<tr>
1690
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
1691
					</tr>
1692
					<tr>
1693
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1694
						<td width="78%" class="vtable">
1695
							<table border="0" cellpadding="2" cellspacing="0">
1696
								<tr>
1697
									<td>
1698
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=htmlspecialchars($pconfig['custom_options']);?></textarea><br/>
1699
										<?=gettext("Enter any additional options you would like to add to the OpenVPN server configuration here, separated by a semicolon"); ?><br/>
1700
										<?=gettext("EXAMPLE: push \"route 10.0.0.0 255.255.255.0\""); ?>;
1701
									</td>
1702
								</tr>
1703
							</table>
1704
						</td>
1705
					</tr>
1706
				</table>
1707

    
1708
				<br/>
1709
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
1710
					<tr>
1711
						<td width="22%" valign="top">&nbsp;</td>
1712
						<td width="78%"> 
1713
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>"> 
1714
							<input name="act" type="hidden" value="<?=$act;?>">
1715
							<?php if (isset($id) && $a_server[$id]): ?>
1716
							<input name="id" type="hidden" value="<?=$id;?>">
1717
							<?php endif; ?>
1718
						</td>
1719
					</tr>
1720
				</table>
1721
			</form>
1722

    
1723
			<?php else: ?>
1724

    
1725
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
1726
				<thead>
1727
				<tr>
1728
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
1729
					<td width="10%" class="listhdrr"><?=gettext("Protocol / Port"); ?></td>
1730
					<td width="30%" class="listhdrr"><?=gettext("Tunnel Network"); ?></td>
1731
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
1732
					<td width="10%" class="list"></td>
1733
				</tr>
1734
				</thead>
1735
				<tbody>
1736
				<?php
1737
					$i = 0;
1738
					foreach($a_server as $server):
1739
						$disabled = "NO";
1740
						if (isset($server['disable']))
1741
							$disabled = "YES";
1742
				?>
1743
				<tr>
1744
					<td class="listlr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1745
						<?=$disabled;?>
1746
					</td>
1747
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1748
						<?=htmlspecialchars($server['protocol']);?> / <?=htmlspecialchars($server['local_port']);?>
1749
					</td>
1750
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1751
						<?=htmlspecialchars($server['tunnel_network']);?><br/>
1752
						<?=htmlspecialchars($server['tunnel_networkv6']);?><br/>
1753
					</td>
1754
					<td class="listbg" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1755
						<?=htmlspecialchars($server['description']);?>
1756
					</td>
1757
					<td valign="middle" nowrap class="list">
1758
						<a href="vpn_openvpn_server.php?act=edit&id=<?=$i;?>">
1759
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit server"); ?>" width="17" height="17" border="0">
1760
						</a>
1761
						&nbsp;
1762
						<a href="vpn_openvpn_server.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this server?"); ?>')">
1763
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete server"); ?>" width="17" height="17" border="0">
1764
						</a>
1765
					</td>
1766
				</tr>
1767
				<?php
1768
					$i++;
1769
					endforeach;
1770
				?>
1771
				</tbody>
1772
				<tfoot>
1773
				<tr>
1774
					<td class="list" colspan="4"></td>
1775
					<td class="list">
1776
						<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">
1777
						</a>
1778
					</td>
1779
				</tr>
1780
				</tfoot>
1781
			</table>
1782

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

    
1785
			<?php endif; ?>
1786

    
1787
		</td>
1788
	</tr>
1789
</table>
1790
<script language="JavaScript">
1791
<!--
1792
mode_change();
1793
autokey_change();
1794
tlsauth_change();
1795
gwredir_change();
1796
dns_domain_change();
1797
dns_server_change();
1798
wins_server_change();
1799
client_mgmt_port_change();
1800
ntp_server_change();
1801
netbios_change();
1802
tuntap_change();
1803
//-->
1804
</script>
1805
</body>
1806
<?php include("fend.inc"); ?>
1807

    
1808
<?php
1809

    
1810
/* local utility functions */
1811

    
1812
function set_checked($var,& $chk) {
1813
    if($var)
1814
        $chk = 'checked';
1815
    else
1816
        $chk = '';
1817
}
1818

    
1819
?>
(239-239/246)