Projet

Général

Profil

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
357
		$server = array();
358

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

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

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

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

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

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

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

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

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

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

    
435
		$server['netbios_enable'] = $pconfig['netbios_enable'];
436
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
437
		$server['netbios_scope'] = $pconfig['netbios_scope'];
438
		 
439
		$server['no_tun_ipv6'] = $pconfig['no_tun_ipv6'];
440
		$server['verbosity_level'] = $pconfig['verbosity_level'];
441

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

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

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

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

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

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

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

    
476
include("head.inc");
477

    
478
?>
479

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

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

    
569
function autokey_change() {
570

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

    
577
function tlsauth_change() {
578

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

    
586
	autotls_change();
587
}
588

    
589
function autotls_change() {
590

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

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

    
603
function gwredir_change() {
604

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

    
614
function dns_domain_change() {
615

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

    
622
function dns_server_change() {
623

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

    
630
function wins_server_change() {
631

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

    
638
function client_mgmt_port_change() {
639

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

    
646
function ntp_server_change() {
647

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

    
654
function netbios_change() {
655

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

    
665
function tuntap_change() {
666

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

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

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

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

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

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

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

    
1432
				</table>
1433

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

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

    
1760
					<tr id="comboboxVerbosityLevel">
1761
							<td width="22%" valign="top" class="vncell"><?=gettext("Verbosity level");?></td>
1762
							<td width="78%" class="vtable">
1763
							<select name="verbosity_level" class="formselect">
1764
							<?php
1765
								foreach ($openvpn_verbosity_level as $verb_value => $verb_desc):
1766
									$selected = "";
1767
									if ($pconfig['verbosity_level'] == $verb_value)
1768
										$selected = "selected=\"selected\"";
1769
							?>
1770
								<option value="<?=$verb_value;?>" <?=$selected;?>><?=$verb_desc;?></option>
1771
							<?php endforeach; ?>
1772
							</select>
1773
							<br />
1774
							<?=gettext("Each level shows all info from the previous levels. Level 3 is recommended if you want a good summary of what's happening without being swamped by output"); ?>.<br /> <br />
1775
							<strong>none</strong> -- <?=gettext("No output except fatal errors"); ?>. <br />
1776
							<strong>default</strong>-<strong>4</strong> -- <?=gettext("Normal usage range"); ?>. <br />
1777
							<strong>5</strong> -- <?=gettext("Output R and W characters to the console for each packet read and write, uppercase is used for TCP/UDP packets and lowercase is used for TUN/TAP packets"); ?>. <br />
1778
							<strong>6</strong>-<strong>11</strong> -- <?=gettext("Debug info range"); ?>.
1779
							</td>
1780
					</tr>
1781

    
1782
				</table>
1783

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

    
1799
			<?php else: ?>
1800

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

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

    
1862
			<?php endif; ?>
1863

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

    
1887
/* local utility functions */
1888

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

    
1896
?>
(248-248/255)