Project

General

Profile

Download (45.7 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	vpn_openvpn_client.php
4

    
5
	Copyright (C) 2008 Shrew Soft Inc.
6
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
7
	All rights reserved.
8

    
9
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11

    
12
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14

    
15
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18

    
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30

    
31
##|+PRIV
32
##|*IDENT=page-openvpn-client
33
##|*NAME=OpenVPN: Client page
34
##|*DESCR=Allow access to the 'OpenVPN: Client' page.
35
##|*MATCH=vpn_openvpn_client.php*
36
##|-PRIV
37

    
38
require("guiconfig.inc");
39
require_once("openvpn.inc");
40
require_once("pkg-utils.inc");
41

    
42
$pgtitle = array(gettext("OpenVPN"), gettext("Client"));
43
$shortcut_section = "openvpn";
44

    
45
if (!is_array($config['openvpn']['openvpn-client'])) {
46
	$config['openvpn']['openvpn-client'] = array();
47
}
48

    
49
$a_client = &$config['openvpn']['openvpn-client'];
50

    
51
if (!is_array($config['ca'])) {
52
	$config['ca'] = array();
53
}
54

    
55
$a_ca =& $config['ca'];
56

    
57
if (!is_array($config['cert'])) {
58
	$config['cert'] = array();
59
}
60

    
61
$a_cert =& $config['cert'];
62

    
63
if (!is_array($config['crl'])) {
64
	$config['crl'] = array();
65
}
66

    
67
$a_crl =& $config['crl'];
68

    
69
if (is_numericint($_GET['id'])) {
70
	$id = $_GET['id'];
71
}
72
if (isset($_POST['id']) && is_numericint($_POST['id'])) {
73
	$id = $_POST['id'];
74
}
75

    
76
$act = $_GET['act'];
77
if (isset($_POST['act'])) {
78
	$act = $_POST['act'];
79
}
80

    
81
if (isset($id) && $a_client[$id]) {
82
	$vpnid = $a_client[$id]['vpnid'];
83
} else {
84
	$vpnid = 0;
85
}
86

    
87
if ($_GET['act'] == "del") {
88

    
89
	if (!isset($a_client[$id])) {
90
		pfSenseHeader("vpn_openvpn_client.php");
91
		exit;
92
	}
93
	if (!empty($a_client[$id])) {
94
		openvpn_delete('client', $a_client[$id]);
95
	}
96
	unset($a_client[$id]);
97
	write_config();
98
	$savemsg = gettext("Client successfully deleted")."<br />";
99
}
100

    
101
if ($_GET['act'] == "new") {
102
	$pconfig['autokey_enable'] = "yes";
103
	$pconfig['tlsauth_enable'] = "yes";
104
	$pconfig['autotls_enable'] = "yes";
105
	$pconfig['interface'] = "wan";
106
	$pconfig['server_port'] = 1194;
107
	$pconfig['verbosity_level'] = 1; // Default verbosity is 1
108
	// OpenVPN Defaults to SHA1
109
	$pconfig['digest'] = "SHA1";
110
}
111

    
112
global $simplefields;
113
$simplefields = array('auth_user', 'auth_pass');
114

    
115
if ($_GET['act'] == "edit") {
116

    
117
	if (isset($id) && $a_client[$id]) {
118
		foreach ($simplefields as $stat) {
119
			$pconfig[$stat] = $a_client[$id][$stat];
120
		}
121

    
122
		$pconfig['disable'] = isset($a_client[$id]['disable']);
123
		$pconfig['mode'] = $a_client[$id]['mode'];
124
		$pconfig['protocol'] = $a_client[$id]['protocol'];
125
		$pconfig['interface'] = $a_client[$id]['interface'];
126
		if (!empty($a_client[$id]['ipaddr'])) {
127
			$pconfig['interface'] = $pconfig['interface'] . '|' . $a_client[$id]['ipaddr'];
128
		}
129
		$pconfig['local_port'] = $a_client[$id]['local_port'];
130
		$pconfig['server_addr'] = $a_client[$id]['server_addr'];
131
		$pconfig['server_port'] = $a_client[$id]['server_port'];
132
		$pconfig['resolve_retry'] = $a_client[$id]['resolve_retry'];
133
		$pconfig['proxy_addr'] = $a_client[$id]['proxy_addr'];
134
		$pconfig['proxy_port'] = $a_client[$id]['proxy_port'];
135
		$pconfig['proxy_user'] = $a_client[$id]['proxy_user'];
136
		$pconfig['proxy_passwd'] = $a_client[$id]['proxy_passwd'];
137
		$pconfig['proxy_authtype'] = $a_client[$id]['proxy_authtype'];
138
		$pconfig['description'] = $a_client[$id]['description'];
139
		$pconfig['custom_options'] = $a_client[$id]['custom_options'];
140
		$pconfig['ns_cert_type'] = $a_client[$id]['ns_cert_type'];
141
		$pconfig['dev_mode'] = $a_client[$id]['dev_mode'];
142

    
143
		if ($pconfig['mode'] != "p2p_shared_key") {
144
			$pconfig['caref'] = $a_client[$id]['caref'];
145
			$pconfig['certref'] = $a_client[$id]['certref'];
146
			if ($a_client[$id]['tls']) {
147
				$pconfig['tlsauth_enable'] = "yes";
148
				$pconfig['tls'] = base64_decode($a_client[$id]['tls']);
149
			}
150
		} else {
151
			$pconfig['shared_key'] = base64_decode($a_client[$id]['shared_key']);
152
		}
153
		$pconfig['crypto'] = $a_client[$id]['crypto'];
154
		// OpenVPN Defaults to SHA1 if unset
155
		$pconfig['digest'] = !empty($a_client[$id]['digest']) ? $a_client[$id]['digest'] : "SHA1";
156
		$pconfig['engine'] = $a_client[$id]['engine'];
157

    
158
		$pconfig['tunnel_network'] = $a_client[$id]['tunnel_network'];
159
		$pconfig['tunnel_networkv6'] = $a_client[$id]['tunnel_networkv6'];
160
		$pconfig['remote_network'] = $a_client[$id]['remote_network'];
161
		$pconfig['remote_networkv6'] = $a_client[$id]['remote_networkv6'];
162
		$pconfig['use_shaper'] = $a_client[$id]['use_shaper'];
163
		$pconfig['compression'] = $a_client[$id]['compression'];
164
		$pconfig['passtos'] = $a_client[$id]['passtos'];
165

    
166
		// just in case the modes switch
167
		$pconfig['autokey_enable'] = "yes";
168
		$pconfig['autotls_enable'] = "yes";
169

    
170
		$pconfig['no_tun_ipv6'] = $a_client[$id]['no_tun_ipv6'];
171
		$pconfig['route_no_pull'] = $a_client[$id]['route_no_pull'];
172
		$pconfig['route_no_exec'] = $a_client[$id]['route_no_exec'];
173
		if (isset($a_client[$id]['verbosity_level'])) {
174
			$pconfig['verbosity_level'] = $a_client[$id]['verbosity_level'];
175
		} else {
176
			$pconfig['verbosity_level'] = 1; // Default verbosity is 1
177
		}
178
	}
179
}
180

    
181
if ($_POST) {
182

    
183
	unset($input_errors);
184
	$pconfig = $_POST;
185

    
186
	if (isset($id) && $a_client[$id]) {
187
		$vpnid = $a_client[$id]['vpnid'];
188
	} else {
189
		$vpnid = 0;
190
	}
191

    
192
	list($iv_iface, $iv_ip) = explode ("|", $pconfig['interface']);
193
	if (is_ipaddrv4($iv_ip) && (stristr($pconfig['protocol'], "6") !== false)) {
194
		$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv6 protocol and an IPv4 IP address.");
195
	} elseif (is_ipaddrv6($iv_ip) && (stristr($pconfig['protocol'], "6") === false)) {
196
		$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv4 protocol and an IPv6 IP address.");
197
	} elseif ((stristr($pconfig['protocol'], "6") === false) && !get_interface_ip($iv_iface) && ($pconfig['interface'] != "any")) {
198
		$input_errors[] = gettext("An IPv4 protocol was selected, but the selected interface has no IPv4 address.");
199
	} elseif ((stristr($pconfig['protocol'], "6") !== false) && !get_interface_ipv6($iv_iface) && ($pconfig['interface'] != "any")) {
200
		$input_errors[] = gettext("An IPv6 protocol was selected, but the selected interface has no IPv6 address.");
201
	}
202

    
203
	if ($pconfig['mode'] != "p2p_shared_key") {
204
		$tls_mode = true;
205
	} else {
206
		$tls_mode = false;
207
	}
208

    
209
	/* input validation */
210
	if ($pconfig['local_port']) {
211

    
212
		if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port')) {
213
			$input_errors[] = $result;
214
		}
215

    
216
		$portused = openvpn_port_used($pconfig['protocol'], $pconfig['interface'], $pconfig['local_port'], $vpnid);
217
		if (($portused != $vpnid) && ($portused != 0)) {
218
			$input_errors[] = gettext("The specified 'Local port' is in use. Please select another value");
219
		}
220
	}
221

    
222
	if ($result = openvpn_validate_host($pconfig['server_addr'], 'Server host or address')) {
223
		$input_errors[] = $result;
224
	}
225

    
226
	if ($result = openvpn_validate_port($pconfig['server_port'], 'Server port')) {
227
		$input_errors[] = $result;
228
	}
229

    
230
	if ($pconfig['proxy_addr']) {
231

    
232
		if ($result = openvpn_validate_host($pconfig['proxy_addr'], 'Proxy host or address')) {
233
			$input_errors[] = $result;
234
		}
235

    
236
		if ($result = openvpn_validate_port($pconfig['proxy_port'], 'Proxy port')) {
237
			$input_errors[] = $result;
238
		}
239

    
240
		if ($pconfig['proxy_authtype'] != "none") {
241
			if (empty($pconfig['proxy_user']) || empty($pconfig['proxy_passwd'])) {
242
				$input_errors[] = gettext("User name and password are required for proxy with authentication.");
243
			}
244
		}
245
	}
246

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

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

    
259
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'IPv4 Remote Network', true, "ipv4")) {
260
		$input_errors[] = $result;
261
	}
262

    
263
	if ($result = openvpn_validate_cidr($pconfig['remote_networkv6'], 'IPv6 Remote Network', true, "ipv6")) {
264
		$input_errors[] = $result;
265
	}
266

    
267
	if (!empty($pconfig['use_shaper']) && (!is_numeric($pconfig['use_shaper']) || ($pconfig['use_shaper'] <= 0))) {
268
		$input_errors[] = gettext("The bandwidth limit must be a positive numeric value.");
269
	}
270

    
271
	if ($pconfig['autokey_enable']) {
272
		$pconfig['shared_key'] = openvpn_create_key();
273
	}
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
	}
281

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

    
289
	/* If we are not in shared key mode, then we need the CA/Cert. */
290
	if ($pconfig['mode'] != "p2p_shared_key") {
291
		$reqdfields = explode(" ", "caref");
292
		$reqdfieldsn = array(gettext("Certificate Authority"));
293
	} elseif (!$pconfig['autokey_enable']) {
294
		/* We only need the shared key filled in if we are in shared key mode and autokey is not selected. */
295
		$reqdfields = array('shared_key');
296
		$reqdfieldsn = array(gettext('Shared key'));
297
	}
298

    
299
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
300

    
301
	if (($pconfig['mode'] != "p2p_shared_key") && empty($pconfig['certref']) && empty($pconfig['auth_user']) && empty($pconfig['auth_pass'])) {
302
		$input_errors[] = gettext("If no Client Certificate is selected, a username and/or password must be entered.");
303
	}
304

    
305
	if (!$input_errors) {
306

    
307
		$client = array();
308

    
309
		foreach ($simplefields as $stat) {
310
			update_if_changed($stat, $client[$stat], $_POST[$stat]);
311
		}
312

    
313
		if ($vpnid) {
314
			$client['vpnid'] = $vpnid;
315
		} else {
316
			$client['vpnid'] = openvpn_vpnid_next();
317
		}
318

    
319
		if ($_POST['disable'] == "yes") {
320
			$client['disable'] = true;
321
		}
322
		$client['protocol'] = $pconfig['protocol'];
323
		$client['dev_mode'] = $pconfig['dev_mode'];
324
		list($client['interface'], $client['ipaddr']) = explode ("|", $pconfig['interface']);
325
		$client['local_port'] = $pconfig['local_port'];
326
		$client['server_addr'] = $pconfig['server_addr'];
327
		$client['server_port'] = $pconfig['server_port'];
328
		$client['resolve_retry'] = $pconfig['resolve_retry'];
329
		$client['proxy_addr'] = $pconfig['proxy_addr'];
330
		$client['proxy_port'] = $pconfig['proxy_port'];
331
		$client['proxy_authtype'] = $pconfig['proxy_authtype'];
332
		$client['proxy_user'] = $pconfig['proxy_user'];
333
		$client['proxy_passwd'] = $pconfig['proxy_passwd'];
334
		$client['description'] = $pconfig['description'];
335
		$client['mode'] = $pconfig['mode'];
336
		$client['custom_options'] = str_replace("\r\n", "\n", $pconfig['custom_options']);
337

    
338
		if ($tls_mode) {
339
			$client['caref'] = $pconfig['caref'];
340
			$client['certref'] = $pconfig['certref'];
341
			if ($pconfig['tlsauth_enable']) {
342
				if ($pconfig['autotls_enable']) {
343
					$pconfig['tls'] = openvpn_create_key();
344
				}
345
				$client['tls'] = base64_encode($pconfig['tls']);
346
			}
347
		} else {
348
			$client['shared_key'] = base64_encode($pconfig['shared_key']);
349
		}
350
		$client['crypto'] = $pconfig['crypto'];
351
		$client['digest'] = $pconfig['digest'];
352
		$client['engine'] = $pconfig['engine'];
353

    
354
		$client['tunnel_network'] = $pconfig['tunnel_network'];
355
		$client['tunnel_networkv6'] = $pconfig['tunnel_networkv6'];
356
		$client['remote_network'] = $pconfig['remote_network'];
357
		$client['remote_networkv6'] = $pconfig['remote_networkv6'];
358
		$client['use_shaper'] = $pconfig['use_shaper'];
359
		$client['compression'] = $pconfig['compression'];
360
		$client['passtos'] = $pconfig['passtos'];
361

    
362
		$client['no_tun_ipv6'] = $pconfig['no_tun_ipv6'];
363
		$client['route_no_pull'] = $pconfig['route_no_pull'];
364
		$client['route_no_exec'] = $pconfig['route_no_exec'];
365
		$client['verbosity_level'] = $pconfig['verbosity_level'];
366

    
367
		if (isset($id) && $a_client[$id]) {
368
			$a_client[$id] = $client;
369
		} else {
370
			$a_client[] = $client;
371
		}
372

    
373
		openvpn_resync('client', $client);
374
		write_config();
375

    
376
		header("Location: vpn_openvpn_client.php");
377
		exit;
378
	}
379
}
380

    
381
include("head.inc");
382

    
383
?>
384

    
385
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
386
<?php include("fbegin.inc"); ?>
387
<script type="text/javascript">
388
//<![CDATA[
389

    
390
function mode_change() {
391
	index = document.iform.mode.selectedIndex;
392
	value = document.iform.mode.options[index].value;
393
	switch (value) {
394
		case "p2p_tls":
395
			document.getElementById("tls").style.display="";
396
			document.getElementById("tls_ca").style.display="";
397
			document.getElementById("tls_cert").style.display="";
398
			document.getElementById("userpass").style.display="";
399
			document.getElementById("userpassheader").style.display="";
400
			document.getElementById("psk").style.display="none";
401
			break;
402
		case "p2p_shared_key":
403
			document.getElementById("tls").style.display="none";
404
			document.getElementById("tls_ca").style.display="none";
405
			document.getElementById("tls_cert").style.display="none";
406
			document.getElementById("userpass").style.display="none";
407
			document.getElementById("userpassheader").style.display="none";
408
			document.getElementById("psk").style.display="";
409
			break;
410
	}
411
}
412

    
413
function dev_mode_change() {
414
	index = document.iform.dev_mode.selectedIndex;
415
	value = document.iform.dev_mode.options[index].value;
416
	switch (value) {
417
		case "tun":
418
			document.getElementById("chkboxNoTunIPv6").style.display="";
419
			break;
420
		case "tap":
421
			document.getElementById("chkboxNoTunIPv6").style.display="none";
422
			break;
423
	}
424
}
425

    
426
function autokey_change() {
427
	if (document.iform.autokey_enable.checked) {
428
		document.getElementById("autokey_opts").style.display="none";
429
	} else {
430
		document.getElementById("autokey_opts").style.display="";
431
	}
432
}
433

    
434
function useproxy_changed() {
435

    
436
	if (jQuery('#proxy_authtype').val() != 'none') {
437
		jQuery('#proxy_authtype_opts').show();
438
	} else {
439
		jQuery('#proxy_authtype_opts').hide();
440
	}
441
}
442

    
443
function tlsauth_change() {
444

    
445
<?php if (!$pconfig['tls']): ?>
446
	if (document.iform.tlsauth_enable.checked) {
447
		document.getElementById("tlsauth_opts").style.display="";
448
	} else {
449
		document.getElementById("tlsauth_opts").style.display="none";
450
	}
451
<?php endif; ?>
452

    
453
	autotls_change();
454
}
455

    
456
function autotls_change() {
457

    
458
<?php if (!$pconfig['tls']): ?>
459
	autocheck = document.iform.autotls_enable.checked;
460
<?php else: ?>
461
	autocheck = false;
462
<?php endif; ?>
463

    
464
	if (document.iform.tlsauth_enable.checked && !autocheck) {
465
		document.getElementById("autotls_opts").style.display="";
466
	} else {
467
		document.getElementById("autotls_opts").style.display="none";
468
	}
469
}
470

    
471
//]]>
472
</script>
473
<?php
474
if (!$savemsg) {
475
	$savemsg = "";
476
}
477

    
478
if ($input_errors) {
479
	print_input_errors($input_errors);
480
}
481
if ($savemsg) {
482
	print_info_box($savemsg);
483
}
484
?>
485
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn openvpn client">
486
	<tr>
487
		<td class="tabnavtbl">
488
			<?php
489
				$tab_array = array();
490
				$tab_array[] = array(gettext("Server"), false, "vpn_openvpn_server.php");
491
				$tab_array[] = array(gettext("Client"), true, "vpn_openvpn_client.php");
492
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
493
				$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
494
				add_package_tabs("openvpn-client-export", $tab_array);
495
				display_top_tabs($tab_array);
496
			?>
497
		</td>
498
	</tr>
499
	<tr>
500
		<td class="tabcont">
501

    
502
			<?php if ($act == "new" || $act == "edit"): ?>
503

    
504
			<form action="vpn_openvpn_client.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
505
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="general information">
506
					<tr>
507
						<td colspan="2" valign="top" class="listtopic"><?=gettext("General information"); ?></td>
508
					</tr>
509
					<tr>
510
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td>
511
						<td width="78%" class="vtable">
512
							<table border="0" cellpadding="0" cellspacing="0" summary="enable disable client">
513
								<tr>
514
									<td>
515
										<?php set_checked($pconfig['disable'], $chk); ?>
516
										<input name="disable" type="checkbox" value="yes" <?=$chk;?> />
517
									</td>
518
									<td>
519
										&nbsp;
520
										<span class="vexpl">
521
											<strong><?=gettext("Disable this client"); ?></strong><br />
522
										</span>
523
									</td>
524
								</tr>
525
							</table>
526
							<?=gettext("Set this option to disable this client without removing it from the list"); ?>.
527
						</td>
528
					</tr>
529
					<tr>
530
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server Mode");?></td>
531
						<td width="78%" class="vtable">
532
							<select name="mode" id="mode" class="formselect" onchange="mode_change()">
533
							<?php
534
								foreach ($openvpn_client_modes as $name => $desc):
535
									$selected = "";
536
									if ($pconfig['mode'] == $name) {
537
										$selected = "selected=\"selected\"";
538
									}
539
							?>
540
								<option value="<?=$name;?>" <?=$selected;?>><?=$desc;?></option>
541
							<?php endforeach; ?>
542
							</select>
543
						</td>
544
					</tr>
545
					<tr>
546
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
547
						<td width="78%" class="vtable">
548
							<select name='protocol' class="formselect">
549
							<?php
550
								foreach ($openvpn_prots as $prot):
551
									$selected = "";
552
									if ($pconfig['protocol'] == $prot) {
553
										$selected = "selected=\"selected\"";
554
									}
555
							?>
556
								<option value="<?=$prot;?>" <?=$selected;?>><?=$prot;?></option>
557
							<?php endforeach; ?>
558
							</select>
559
						</td>
560
					</tr>
561
					<tr>
562
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Device mode");?></td>
563
						<td width="78%" class="vtable">
564
							<select name='dev_mode' class="formselect" onchange="dev_mode_change()">
565
							<?php
566
								foreach ($openvpn_dev_mode as $mode):
567
									$selected = "";
568
									if ($pconfig['dev_mode'] == $mode) {
569
										$selected = "selected=\"selected\"";
570
									}
571
							?>
572
								<option value="<?=$mode;?>" <?=$selected;?>><?=$mode;?></option>
573
							<?php endforeach; ?>
574
							</select>
575
						</td>
576
					</tr>
577
					<tr>
578
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
579
						<td width="78%" class="vtable">
580
							<select name="interface" class="formselect">
581
								<?php
582
									$interfaces = get_configured_interface_with_descr();
583
									$carplist = get_configured_carp_interface_list();
584
									foreach ($carplist as $cif => $carpip) {
585
										$interfaces[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")";
586
									}
587
									$aliaslist = get_configured_ip_aliases_list();
588
									foreach ($aliaslist as $aliasip => $aliasif) {
589
										$interfaces[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
590
									}
591
									$grouplist = return_gateway_groups_array();
592
									foreach ($grouplist as $name => $group) {
593
										if ($group['ipprotocol'] != inet) {
594
											continue;
595
										}
596
										if ($group[0]['vip'] <> "") {
597
											$vipif = $group[0]['vip'];
598
										} else {
599
											$vipif = $group[0]['int'];
600
										}
601
										$interfaces[$name] = "GW Group {$name}";
602
									}
603
									$interfaces['lo0'] = "Localhost";
604
									$interfaces['any'] = "any";
605
									foreach ($interfaces as $iface => $ifacename):
606
										$selected = "";
607
										if ($iface == $pconfig['interface']) {
608
											$selected = "selected=\"selected\"";
609
										}
610
								?>
611
									<option value="<?=$iface;?>" <?=$selected;?>>
612
										<?=htmlspecialchars($ifacename);?>
613
									</option>
614
								<?php endforeach; ?>
615
							</select> <br />
616
						</td>
617
					</tr>
618
					<tr>
619
						<td width="22%" valign="top" class="vncell"><?=gettext("Local port");?></td>
620
						<td width="78%" class="vtable">
621
							<input name="local_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['local_port']);?>" />
622
							<br />
623
							<?=gettext("Set this option if you would like to bind to a specific port. Leave this blank or enter 0 for a random dynamic port."); ?>
624
						</td>
625
					</tr>
626
					<tr>
627
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server host or address");?></td>
628
						<td width="78%" class="vtable">
629
							<input name="server_addr" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['server_addr']);?>" />
630
						</td>
631
					</tr>
632
					<tr>
633
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server port");?></td>
634
						<td width="78%" class="vtable">
635
							<input name="server_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['server_port']);?>" />
636
						</td>
637
					</tr>
638
					<tr>
639
						<td width="22%" valign="top" class="vncell"><?=gettext("Proxy host or address");?></td>
640
						<td width="78%" class="vtable">
641
							<input name="proxy_addr" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['proxy_addr']);?>" />
642
						</td>
643
					</tr>
644
					<tr>
645
						<td width="22%" valign="top" class="vncell"><?=gettext("Proxy port");?></td>
646
						<td width="78%" class="vtable">
647
							<input name="proxy_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['proxy_port']);?>" />
648
						</td>
649
					</tr>
650
					<tr>
651
						<td width="22%" valign="top" class="vncell"><?=gettext("Proxy authentication extra options");?></td>
652
						<td width="78%" class="vtable">
653
							<table border="0" cellpadding="2" cellspacing="0" summary="proxy authentication">
654
								<tr>
655
									<td align="right" width="25%">
656
										<span class="vexpl">
657
											 &nbsp;<?=gettext("Authentication method"); ?> :&nbsp;
658
										</span>
659
									</td>
660
									<td>
661
										<select name="proxy_authtype" id="proxy_authtype" class="formfld select" onchange="useproxy_changed()">
662
											<option value="none" <?php if ($pconfig['proxy_authtype'] == "none") echo "selected=\"selected\""; ?>><?=gettext("none"); ?></option>
663
											<option value="basic" <?php if ($pconfig['proxy_authtype'] == "basic") echo "selected=\"selected\""; ?>><?=gettext("basic"); ?></option>
664
											<option value="ntlm" <?php if ($pconfig['proxy_authtype'] == "ntlm") echo "selected=\"selected\""; ?>><?=gettext("ntlm"); ?></option>
665
										</select>
666
									</td>
667
								</tr>
668
							</table>
669
							<br />
670
							 <table border="0" cellpadding="2" cellspacing="0" id="proxy_authtype_opts" style="display:none" summary="proxy authentication options">
671
								<tr>
672
									<td align="right" width="25%">
673
										<span class="vexpl">
674
											 &nbsp;<?=gettext("Username"); ?> :&nbsp;
675
										</span>
676
									</td>
677
									<td>
678
										<input name="proxy_user" id="proxy_user" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['proxy_user']);?>" />
679
									</td>
680
								</tr>
681
								<tr>
682
									<td align="right" width="25%">
683
										<span class="vexpl">
684
											 &nbsp;<?=gettext("Password"); ?> :&nbsp;
685
										</span>
686
									</td>
687
									<td>
688
										<input name="proxy_passwd" id="proxy_passwd" type="password" class="formfld pwd" size="20" value="<?=htmlspecialchars($pconfig['proxy_passwd']);?>" />
689
									</td>
690
								</tr>
691
							</table>
692
						</td>
693
					</tr>
694
					<tr>
695
						<td width="22%" valign="top" class="vncell"><?=gettext("Server host name resolution"); ?></td>
696
						<td width="78%" class="vtable">
697
							<table border="0" cellpadding="2" cellspacing="0" summary="server host name resolution">
698
								<tr>
699
									<td>
700
										<?php set_checked($pconfig['resolve_retry'], $chk); ?>
701
										<input name="resolve_retry" type="checkbox" value="yes" <?=$chk;?> />
702
									</td>
703
									<td>
704
										<span class="vexpl">
705
											<?=gettext("Infinitely resolve server"); ?>
706
										</span>
707
									</td>
708
								</tr>
709
							</table>
710
							<?=gettext("Continuously attempt to resolve the server host " .
711
							"name. Useful when communicating with a server " .
712
							"that is not permanently connected to the Internet"); ?>.
713
						</td>
714
					</tr>
715
					<tr>
716
						<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
717
						<td width="78%" class="vtable">
718
							<input name="description" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['description']);?>" />
719
							<br />
720
							<?=gettext("You may enter a description here for your reference (not parsed)"); ?>.
721
						</td>
722
					</tr>
723
					<tr>
724
						<td colspan="2" class="list" height="12"></td>
725
					</tr>
726
					<tr id='userpassheader'>
727
						<td colspan="2" valign="top" class="listtopic"><?=gettext("User Authentication Settings"); ?></td>
728
					</tr>
729
					<tr id='userpass'>
730
						<td width="22%" valign="top" class="vncell"><?=gettext("User name/pass"); ?></td>
731
						<td width="78%" class="vtable">
732
							<?=gettext("Leave empty when no user name and/or password are needed."); ?>
733
							<br/>
734
							<table border="0" cellpadding="2" cellspacing="0" summary="user name password">
735
								<tr>
736
									<td align="right" width="25%">
737
										<span class="vexpl">
738
											&nbsp;<?=gettext("Username"); ?> :&nbsp;
739
										</span>
740
									</td>
741
									<td>
742
										<input name="auth_user" id="auth_user" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['auth_user']);?>" />
743
									</td>
744
								</tr>
745
								<tr>
746
									<td align="right" width="25%">
747
										<span class="vexpl">
748
											&nbsp;<?=gettext("Password"); ?> :&nbsp;
749
										</span>
750
									</td>
751
									<td>
752
										<input name="auth_pass" id="auth_pass" type="password" class="formfld pwd" size="20" value="<?=htmlspecialchars($pconfig['auth_pass']);?>" />
753
									</td>
754
								</tr>
755
							</table>
756
						</td>
757
					</tr>
758
					<tr>
759
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Cryptographic Settings"); ?></td>
760
					</tr>
761
					<tr id="tls">
762
						<td width="22%" valign="top" class="vncellreq"><?=gettext("TLS Authentication"); ?></td>
763
						<td width="78%" class="vtable">
764
							<table border="0" cellpadding="2" cellspacing="0" summary="tls authentication">
765
								<tr>
766
									<td>
767
										<?php set_checked($pconfig['tlsauth_enable'], $chk); ?>
768
										<input name="tlsauth_enable" id="tlsauth_enable" type="checkbox" value="yes" <?=$chk;?> onclick="tlsauth_change()" />
769
									</td>
770
									<td>
771
										<span class="vexpl">
772
											<?=gettext("Enable authentication of TLS packets"); ?>.
773
										</span>
774
									</td>
775
								</tr>
776
							</table>
777
							<?php if (!$pconfig['tls']): ?>
778
							<table border="0" cellpadding="2" cellspacing="0" id="tlsauth_opts" summary="tls authentication options">
779
								<tr>
780
									<td>
781
										<?php set_checked($pconfig['autotls_enable'], $chk); ?>
782
										<input name="autotls_enable" id="autotls_enable" type="checkbox" value="yes" <?=$chk;?> onclick="autotls_change()" />
783
									</td>
784
									<td>
785
										<span class="vexpl">
786
											<?=gettext("Automatically generate a shared TLS authentication key"); ?>.
787
										</span>
788
									</td>
789
								</tr>
790
							</table>
791
							<?php endif; ?>
792
							<table border="0" cellpadding="2" cellspacing="0" id="autotls_opts" summary="tls authentication options">
793
								<tr>
794
									<td>
795
										<textarea name="tls" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['tls']);?></textarea>
796
										<br />
797
										<?=gettext("Paste your shared key here"); ?>.
798
									</td>
799
								</tr>
800
							</table>
801
						</td>
802
					</tr>
803
					<tr id="tls_ca">
804
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer Certificate Authority"); ?></td>
805
						<td width="78%" class="vtable">
806
							<?php if (count($a_ca)): ?>
807
							<select name='caref' class="formselect">
808
							<?php
809
								foreach ($a_ca as $ca):
810
									$selected = "";
811
									if ($pconfig['caref'] == $ca['refid']) {
812
										$selected = "selected=\"selected\"";
813
									}
814
							?>
815
								<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=htmlspecialchars($ca['descr']);?></option>
816
							<?php endforeach; ?>
817
							</select>
818
							<?php else: ?>
819
								<b>No Certificate Authorities defined.</b> <br />Create one under <a href="system_camanager.php">System &gt; Cert Manager</a>.
820
							<?php endif; ?>
821
							</td>
822
					</tr>
823
					<tr id="tls_cert">
824
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Client Certificate"); ?></td>
825
						<td width="78%" class="vtable">
826
							<select name='certref' class="formselect">
827
							<?php
828
							foreach ($a_cert as $cert):
829
								$selected = "";
830
								$caname = "";
831
								$inuse = "";
832
								$revoked = "";
833
								$ca = lookup_ca($cert['caref']);
834
								if ($ca) {
835
									$caname = " (CA: " . htmlspecialchars($ca['descr']) . ")";
836
								}
837
								if ($pconfig['certref'] == $cert['refid']) {
838
									$selected = "selected=\"selected\"";
839
								}
840
								if (cert_in_use($cert['refid'])) {
841
									$inuse = " *In Use";
842
								}
843
								if (is_cert_revoked($cert)) {
844
									$revoked = " *Revoked";
845
								}
846
							?>
847
								<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=htmlspecialchars($cert['descr']) . $caname . $inuse . $revoked;?></option>
848
							<?php endforeach; ?>
849
								<option value="" <?PHP if (empty($pconfig['certref'])) echo "selected=\"selected\""; ?>>None (Username and/or Password required)</option>
850
							</select>
851
						<?php if (!count($a_cert)): ?>
852
							<b>No Certificates defined.</b> <br />Create one under <a href="system_certmanager.php">System &gt; Cert Manager</a> if one is required for this connection.
853
						<?php endif; ?>
854
						</td>
855
					</tr>
856
					<tr id="psk">
857
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Shared Key"); ?></td>
858
						<td width="78%" class="vtable">
859
							<?php if (!$pconfig['shared_key']): ?>
860
							<table border="0" cellpadding="2" cellspacing="0" summary="shared key">
861
								<tr>
862
									<td>
863
										<?php set_checked($pconfig['autokey_enable'], $chk); ?>
864
										<input name="autokey_enable" type="checkbox" value="yes" <?=$chk;?> onclick="autokey_change()" />
865
									</td>
866
									<td>
867
										<span class="vexpl">
868
											<?=gettext("Automatically generate a shared key"); ?>.
869
										</span>
870
									</td>
871
								</tr>
872
							</table>
873
							<?php endif; ?>
874
							<table border="0" cellpadding="2" cellspacing="0" id="autokey_opts" summary="shared key options">
875
								<tr>
876
									<td>
877
										<textarea name="shared_key" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['shared_key']);?></textarea>
878
										<br />
879
										<?=gettext("Paste your shared key here"); ?>.
880
									</td>
881
								</tr>
882
							</table>
883
						</td>
884
					</tr>
885
					<tr>
886
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Encryption algorithm"); ?></td>
887
						<td width="78%" class="vtable">
888
							<select name="crypto" class="formselect">
889
								<?php
890
									$cipherlist = openvpn_get_cipherlist();
891
									foreach ($cipherlist as $name => $desc):
892
										$selected = "";
893
										if ($name == $pconfig['crypto']) {
894
											$selected = " selected=\"selected\"";
895
										}
896
								?>
897
								<option value="<?=$name;?>"<?=$selected?>>
898
									<?=htmlspecialchars($desc);?>
899
								</option>
900
								<?php endforeach; ?>
901
							</select>
902
						</td>
903
					</tr>
904
					<tr>
905
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Auth Digest Algorithm"); ?></td>
906
						<td width="78%" class="vtable">
907
							<select name="digest" class="formselect">
908
								<?php
909
									$digestlist = openvpn_get_digestlist();
910
									foreach ($digestlist as $name => $desc):
911
									$selected = "";
912
									if ($name == $pconfig['digest']) {
913
										$selected = " selected=\"selected\"";
914
									}
915
								?>
916
								<option value="<?=$name;?>"<?=$selected?>>
917
									<?=htmlspecialchars($desc);?>
918
								</option>
919
								<?php endforeach; ?>
920
							</select>
921
							<br /><?PHP echo gettext("NOTE: Leave this set to SHA1 unless the server is set to match. SHA1 is the default for OpenVPN."); ?>
922
						</td>
923
					</tr>
924
					<tr id="engine">
925
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Hardware Crypto"); ?></td>
926
						<td width="78%" class="vtable">
927
							<select name="engine" class="formselect">
928
								<?php
929
									$engines = openvpn_get_engines();
930
									foreach ($engines as $name => $desc):
931
									$selected = "";
932
									if ($name == $pconfig['engine']) {
933
										$selected = " selected=\"selected\"";
934
									}
935
								?>
936
								<option value="<?=$name;?>"<?=$selected?>>
937
									<?=htmlspecialchars($desc);?>
938
								</option>
939
								<?php endforeach; ?>
940
							</select>
941
						</td>
942
					</tr>
943
					<tr>
944
						<td colspan="2" class="list" height="12"></td>
945
					</tr>
946
					<tr>
947
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Tunnel Settings"); ?></td>
948
					</tr>
949
					<tr>
950
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Tunnel Network"); ?></td>
951
						<td width="78%" class="vtable">
952
							<input name="tunnel_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_network']);?>" />
953
							<br />
954
							<?=gettext("This is the virtual network used for private " .
955
							"communications between this client and the " .
956
							"server expressed using CIDR (eg. 10.0.8.0/24). " .
957
							"The first network address is assumed to be the " .
958
							"server address and the second network address " .
959
							"will be assigned to the client virtual " .
960
							"interface"); ?>.
961
						</td>
962
					</tr>
963
					<tr>
964
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Tunnel Network"); ?></td>
965
						<td width="78%" class="vtable">
966
							<input name="tunnel_networkv6" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_networkv6']);?>" />
967
							<br />
968
							<?=gettext("This is the IPv6 virtual network used for private " .
969
							"communications between this client and the " .
970
							"server expressed using CIDR (eg. fe80::/64). " .
971
							"The first network address is assumed to be the " .
972
							"server address and the second network address " .
973
							"will be assigned to the client virtual " .
974
							"interface"); ?>.
975
						</td>
976
					</tr>
977
					<tr>
978
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Remote Network/s"); ?></td>
979
						<td width="78%" class="vtable">
980
							<input name="remote_network" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['remote_network']);?>" />
981
							<br />
982
							<?=gettext("These are the IPv4 networks that will be routed through " .
983
							"the tunnel, so that a site-to-site VPN can be " .
984
							"established without manually changing the routing tables. " .
985
							"Expressed as a comma-separated list of one or more CIDR ranges. " .
986
							"If this is a site-to-site VPN, enter the " .
987
							"remote LAN/s here. You may leave this blank to " .
988
							"only communicate with other clients"); ?>.
989
						</td>
990
					</tr>
991
					<tr>
992
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Remote Network/s"); ?></td>
993
						<td width="78%" class="vtable">
994
							<input name="remote_networkv6" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['remote_networkv6']);?>" />
995
							<br />
996
							<?=gettext("These are the IPv6 networks that will be routed through " .
997
							"the tunnel, so that a site-to-site VPN can be " .
998
							"established without manually changing the routing tables. " .
999
							"Expressed as a comma-separated list of one or more IP/PREFIX. " .
1000
							"If this is a site-to-site VPN, enter the " .
1001
							"remote LAN/s here. You may leave this blank to " .
1002
							"only communicate with other clients"); ?>.
1003
						</td>
1004
					</tr>
1005
					<tr>
1006
						<td width="22%" valign="top" class="vncell"><?=gettext("Limit outgoing bandwidth");?></td>
1007
						<td width="78%" class="vtable">
1008
							<input name="use_shaper" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['use_shaper']);?>" />
1009
							<br />
1010
							<?=gettext("Maximum outgoing bandwidth for this tunnel. " .
1011
							"Leave empty for no limit. The input value has " .
1012
							"to be something between 100 bytes/sec and 100 " .
1013
							"Mbytes/sec (entered as bytes per second)"); ?>.
1014
						</td>
1015
					</tr>
1016
					<tr>
1017
						<td width="22%" valign="top" class="vncell"><?=gettext("Compression"); ?></td>
1018
						<td width="78%" class="vtable">
1019
							<select name="compression" class="formselect">
1020
								<?php
1021
									foreach ($openvpn_compression_modes as $cmode => $cmodedesc):
1022
										$selected = "";
1023
										if ($cmode == $pconfig['compression']) {
1024
											$selected = " selected=\"selected\"";
1025
										}
1026
								?>
1027
									<option value="<?= $cmode ?>" <?= $selected ?>><?= $cmodedesc ?></option>
1028
								<?php endforeach; ?>
1029
							</select>
1030
							<br />
1031
							<?=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."); ?>.
1032
						</td>
1033
					</tr>
1034
					<tr>
1035
						<td width="22%" valign="top" class="vncell"><?=gettext("Type-of-Service"); ?></td>
1036
						<td width="78%" class="vtable">
1037
							<table border="0" cellpadding="2" cellspacing="0" summary="type-of-service">
1038
								<tr>
1039
									<td>
1040
										<?php set_checked($pconfig['passtos'], $chk); ?>
1041
										<input name="passtos" type="checkbox" value="yes" <?=$chk;?> />
1042
									</td>
1043
									<td>
1044
										<span class="vexpl">
1045
											<?=gettext("Set the TOS IP header value of tunnel packets to match the encapsulated packet value"); ?>.
1046
										</span>
1047
									</td>
1048
								</tr>
1049
							</table>
1050
						</td>
1051
					</tr>
1052

    
1053
					<tr id="chkboxNoTunIPv6">
1054
						<td width="22%" valign="top" class="vncell"><?=gettext("Disable IPv6"); ?></td>
1055
						<td width="78%" class="vtable">
1056
							<table border="0" cellpadding="2" cellspacing="0" summary="disable-ipv6">
1057
								<tr>
1058
									<td>
1059
										<?php set_checked($pconfig['no_tun_ipv6'], $chk); ?>
1060
										<input name="no_tun_ipv6" type="checkbox" value="yes" <?=$chk;?> />
1061
									</td>
1062
									<td>
1063
										<span class="vexpl">
1064
											<?=gettext("Don't forward IPv6 traffic"); ?>.
1065
										</span>
1066
									</td>
1067
								</tr>
1068
							</table>
1069
						</td>
1070
					</tr>
1071

    
1072
					<tr id="chkboxRouteNoPull">
1073
						<td width="22%" valign="top" class="vncell"><?=gettext("Don't pull routes"); ?></td>
1074
						<td width="78%" class="vtable">
1075
							<table border="0" cellpadding="2" cellspacing="0" summary="dont-pull-routes">
1076
								<tr>
1077
									<td>
1078
										<?php set_checked($pconfig['route_no_pull'], $chk); ?>
1079
										<input name="route_no_pull" type="checkbox" value="yes" <?=$chk;?> />
1080
									</td>
1081
									<td>
1082
										<span class="vexpl">
1083
											<?=gettext("This option effectively bars the server from adding routes to the client's routing table, however note that this option still allows the server to set the TCP/IP properties of the client's TUN/TAP interface"); ?>.
1084
										</span>
1085
									</td>
1086
								</tr>
1087
							</table>
1088
						</td>
1089
					</tr>
1090

    
1091
					<tr id="chkboxRouteNoExec">
1092
						<td width="22%" valign="top" class="vncell"><?=gettext("Don't add/remove routes"); ?></td>
1093
						<td width="78%" class="vtable">
1094
							<table border="0" cellpadding="2" cellspacing="0" summary="dont-exec-routes">
1095
								<tr>
1096
									<td>
1097
										<?php set_checked($pconfig['route_no_exec'], $chk); ?>
1098
										<input name="route_no_exec" type="checkbox" value="yes" <?=$chk;?> />
1099
									</td>
1100
									<td>
1101
										<span class="vexpl">
1102
											<?=gettext("Don't add or remove routes automatically. Instead pass routes to "); ?> <strong>--route-up</strong> <?=gettext("script using environmental variables"); ?>.
1103
										</span>
1104
									</td>
1105
								</tr>
1106
							</table>
1107
						</td>
1108
					</tr>
1109
				</table>
1110

    
1111
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts" summary="advance configuration">
1112
					<tr>
1113
						<td colspan="2" class="list" height="12"></td>
1114
					</tr>
1115
					<tr>
1116
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
1117
					</tr>
1118
					<tr>
1119
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1120
						<td width="78%" class="vtable">
1121
							<table border="0" cellpadding="2" cellspacing="0" summary="advance configuration">
1122
								<tr>
1123
									<td>
1124
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=htmlspecialchars($pconfig['custom_options']);?></textarea><br />
1125
										<?=gettext("Enter any additional options you would like to add to the OpenVPN client configuration here, separated by a semicolon"); ?><br />
1126
										<?=gettext("EXAMPLE:"); ?> <strong>remote server.example.com 1194;</strong> or <strong>remote 1.2.3.4 1194;</strong>
1127
									</td>
1128
								</tr>
1129
							</table>
1130
						</td>
1131
					</tr>
1132

    
1133
					<tr id="comboboxVerbosityLevel">
1134
						<td width="22%" valign="top" class="vncell"><?=gettext("Verbosity level");?></td>
1135
						<td width="78%" class="vtable">
1136
							<select name="verbosity_level" class="formselect">
1137
							<?php
1138
								foreach ($openvpn_verbosity_level as $verb_value => $verb_desc):
1139
									$selected = "";
1140
									if ($pconfig['verbosity_level'] == $verb_value) {
1141
										$selected = "selected=\"selected\"";
1142
									}
1143
							?>
1144
								<option value="<?=$verb_value;?>" <?=$selected;?>><?=$verb_desc;?></option>
1145
							<?php endforeach; ?>
1146
							</select>
1147
							<br />
1148
							<?=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 />
1149
							<strong>none</strong> -- <?=gettext("No output except fatal errors"); ?>. <br />
1150
							<strong>default</strong>-<strong>4</strong> -- <?=gettext("Normal usage range"); ?>. <br />
1151
							<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 />
1152
							<strong>6</strong>-<strong>11</strong> -- <?=gettext("Debug info range"); ?>.
1153
						</td>
1154
					</tr>
1155

    
1156
				</table>
1157

    
1158
				<br />
1159
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="icons">
1160
					<tr>
1161
						<td width="22%" valign="top">&nbsp;</td>
1162
						<td width="78%">
1163
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
1164
							<input name="act" type="hidden" value="<?=$act;?>" />
1165
							<?php if (isset($id) && $a_client[$id]): ?>
1166
							<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
1167
							<?php endif; ?>
1168
						</td>
1169
					</tr>
1170
				</table>
1171
			</form>
1172

    
1173
			<?php else: ?>
1174

    
1175
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="list of openvpn clients">
1176
				<thead>
1177
				<tr>
1178
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
1179
					<td width="10%" class="listhdrr"><?=gettext("Protocol"); ?></td>
1180
					<td width="30%" class="listhdrr"><?=gettext("Server"); ?></td>
1181
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
1182
					<td width="10%" class="list"></td>
1183
				</tr>
1184
				</thead>
1185
				<tfoot>
1186
				<tr>
1187
					<td class="list" colspan="4"></td>
1188
					<td class="list">
1189
						<a href="vpn_openvpn_client.php?act=new"><img src="./themes/<?=$g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add client"); ?>" width="17" height="17" border="0" alt="add" />
1190
						</a>
1191
					</td>
1192
				</tr>
1193
				<tr>
1194
					<td colspan="4">
1195
						<p>
1196
							<?=gettext("Additional OpenVPN clients can be added here.");?>
1197
						</p>
1198
					</td>
1199
				</tr>
1200
				</tfoot>
1201
				<tbody>
1202
				<?php
1203
					$i = 0;
1204
					foreach ($a_client as $client):
1205
						$disabled = "NO";
1206
						if (isset($client['disable'])) {
1207
							$disabled = "YES";
1208
						}
1209
						$server = "{$client['server_addr']}:{$client['server_port']}";
1210
				?>
1211
				<tr ondblclick="document.location='vpn_openvpn_client.php?act=edit&amp;id=<?=$i;?>'">
1212
					<td class="listlr">
1213
						<?=$disabled;?>
1214
					</td>
1215
					<td class="listr">
1216
						<?=htmlspecialchars($client['protocol']);?>
1217
					</td>
1218
					<td class="listr">
1219
						<?=htmlspecialchars($server);?>
1220
					</td>
1221
					<td class="listbg">
1222
						<?=htmlspecialchars($client['description']);?>
1223
					</td>
1224
					<td valign="middle" class="list nowrap">
1225
						<a href="vpn_openvpn_client.php?act=edit&amp;id=<?=$i;?>">
1226
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit client"); ?>" width="17" height="17" border="0" alt="edit" />
1227
						</a>
1228
						&nbsp;
1229
						<a href="vpn_openvpn_client.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this client?"); ?>')">
1230
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete client"); ?>" width="17" height="17" border="0" alt="delete" />
1231
						</a>
1232
					</td>
1233
				</tr>
1234
				<?php
1235
					$i++;
1236
					endforeach;
1237
				?>
1238
				<tr style="display:none;"><td></td></tr>
1239
				</tbody>
1240
			</table>
1241

    
1242
			<?php endif; ?>
1243

    
1244
		</td>
1245
	</tr>
1246
</table>
1247
<script type="text/javascript">
1248
//<![CDATA[
1249
mode_change();
1250
autokey_change();
1251
tlsauth_change();
1252
useproxy_changed();
1253
//]]>
1254
</script>
1255
<?php include("fend.inc"); ?>
1256
</body>
1257
</html>
1258

    
1259
<?php
1260

    
1261
/* local utility functions */
1262

    
1263
function set_checked($var, & $chk) {
1264
	if ($var) {
1265
		$chk = "checked=\"checked\"";
1266
	} else {
1267
		$chk = "";
1268
	}
1269
}
1270

    
1271
?>
(243-243/252)