Project

General

Profile

Download (45.1 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
$a_client = &$config['openvpn']['openvpn-client'];
49

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

    
53
$a_ca =& $config['ca'];
54

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

    
58
$a_cert =& $config['cert'];
59

    
60
if (!is_array($config['crl']))
61
	$config['crl'] = array();
62

    
63
$a_crl =& $config['crl'];
64

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

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

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

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

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

    
92
if($_GET['act']=="new"){
93
	$pconfig['autokey_enable'] = "yes";
94
	$pconfig['tlsauth_enable'] = "yes";
95
	$pconfig['autotls_enable'] = "yes";
96
	$pconfig['interface'] = "wan";
97
	$pconfig['server_port'] = 1194;
98
	$pconfig['verbosity_level'] = 1; // Default verbosity is 1
99
	// OpenVPN Defaults to SHA1
100
	$pconfig['digest'] = "SHA1";
101
}
102

    
103
global $simplefields;
104
$simplefields = array('auth_user','auth_pass');
105

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

    
108
	if (isset($id) && $a_client[$id]) {
109
		foreach($simplefields as $stat)
110
			$pconfig[$stat] = $a_client[$id][$stat];
111

    
112
		$pconfig['disable'] = isset($a_client[$id]['disable']);
113
		$pconfig['mode'] = $a_client[$id]['mode'];
114
		$pconfig['protocol'] = $a_client[$id]['protocol'];
115
		$pconfig['interface'] = $a_client[$id]['interface'];
116
		if (!empty($a_client[$id]['ipaddr'])) {
117
			$pconfig['interface'] = $pconfig['interface'] . '|' . $a_client[$id]['ipaddr'];
118
		}
119
		$pconfig['local_port'] = $a_client[$id]['local_port'];
120
		$pconfig['server_addr'] = $a_client[$id]['server_addr'];
121
		$pconfig['server_port'] = $a_client[$id]['server_port'];
122
		$pconfig['resolve_retry'] = $a_client[$id]['resolve_retry'];
123
		$pconfig['proxy_addr'] = $a_client[$id]['proxy_addr'];
124
		$pconfig['proxy_port'] = $a_client[$id]['proxy_port'];
125
		$pconfig['proxy_user'] = $a_client[$id]['proxy_user'];
126
		$pconfig['proxy_passwd'] = $a_client[$id]['proxy_passwd'];
127
		$pconfig['proxy_authtype'] = $a_client[$id]['proxy_authtype'];
128
		$pconfig['description'] = $a_client[$id]['description'];
129
		$pconfig['custom_options'] = $a_client[$id]['custom_options'];
130
		$pconfig['ns_cert_type'] = $a_client[$id]['ns_cert_type'];
131
		$pconfig['dev_mode'] = $a_client[$id]['dev_mode'];
132

    
133
		if ($pconfig['mode'] != "p2p_shared_key") {
134
			$pconfig['caref'] = $a_client[$id]['caref'];
135
			$pconfig['certref'] = $a_client[$id]['certref'];
136
			if ($a_client[$id]['tls']) {
137
				$pconfig['tlsauth_enable'] = "yes";
138
				$pconfig['tls'] = base64_decode($a_client[$id]['tls']);
139
			}
140
		} else
141
			$pconfig['shared_key'] = base64_decode($a_client[$id]['shared_key']);
142
		$pconfig['crypto'] = $a_client[$id]['crypto'];
143
		// OpenVPN Defaults to SHA1 if unset
144
		$pconfig['digest'] = !empty($a_client[$id]['digest']) ? $a_client[$id]['digest'] : "SHA1";
145
		$pconfig['engine'] = $a_client[$id]['engine'];
146

    
147
		$pconfig['tunnel_network'] = $a_client[$id]['tunnel_network'];
148
		$pconfig['tunnel_networkv6'] = $a_client[$id]['tunnel_networkv6'];
149
		$pconfig['remote_network'] = $a_client[$id]['remote_network'];
150
		$pconfig['remote_networkv6'] = $a_client[$id]['remote_networkv6'];
151
		$pconfig['use_shaper'] = $a_client[$id]['use_shaper'];
152
		$pconfig['compression'] = $a_client[$id]['compression'];
153
		$pconfig['passtos'] = $a_client[$id]['passtos'];
154

    
155
		// just in case the modes switch
156
		$pconfig['autokey_enable'] = "yes";
157
		$pconfig['autotls_enable'] = "yes";
158
		
159
		$pconfig['no_tun_ipv6'] = $a_client[$id]['no_tun_ipv6'];
160
		$pconfig['route_no_pull'] = $a_client[$id]['route_no_pull'];
161
		$pconfig['route_no_exec'] = $a_client[$id]['route_no_exec'];
162
		if (isset($a_client[$id]['verbosity_level']))
163
			$pconfig['verbosity_level'] = $a_client[$id]['verbosity_level'];
164
		else
165
			$pconfig['verbosity_level'] = 1; // Default verbosity is 1
166
	}
167
}
168

    
169
if ($_POST) {
170

    
171
	unset($input_errors);
172
	$pconfig = $_POST;
173

    
174
	if (isset($id) && $a_client[$id])
175
		$vpnid = $a_client[$id]['vpnid'];
176
	else
177
		$vpnid = 0;
178

    
179
	list($iv_iface, $iv_ip) = explode ("|",$pconfig['interface']);
180
	if (is_ipaddrv4($iv_ip) && (stristr($pconfig['protocol'], "6") !== false)) {
181
		$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv6 protocol and an IPv4 IP address.");
182
	} elseif (is_ipaddrv6($iv_ip) && (stristr($pconfig['protocol'], "6") === false)) {
183
		$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv4 protocol and an IPv6 IP address.");
184
	} elseif ((stristr($pconfig['protocol'], "6") === false) && !get_interface_ip($iv_iface) && ($pconfig['interface'] != "any")) {
185
		$input_errors[] = gettext("An IPv4 protocol was selected, but the selected interface has no IPv4 address.");
186
	} elseif ((stristr($pconfig['protocol'], "6") !== false) && !get_interface_ipv6($iv_iface) && ($pconfig['interface'] != "any")) {
187
		$input_errors[] = gettext("An IPv6 protocol was selected, but the selected interface has no IPv6 address.");
188
	}
189

    
190
	if ($pconfig['mode'] != "p2p_shared_key")
191
		$tls_mode = true;
192
	else
193
		$tls_mode = false;
194

    
195
	/* input validation */
196
	if ($pconfig['local_port']) {
197

    
198
		if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
199
			$input_errors[] = $result;
200

    
201
		$portused = openvpn_port_used($pconfig['protocol'], $pconfig['interface'], $pconfig['local_port'], $vpnid);
202
		if (($portused != $vpnid) && ($portused != 0))
203
			$input_errors[] = gettext("The specified 'Local port' is in use. Please select another value");
204
	}
205

    
206
	if ($result = openvpn_validate_host($pconfig['server_addr'], 'Server host or address'))
207
		$input_errors[] = $result;
208

    
209
	if ($result = openvpn_validate_port($pconfig['server_port'], 'Server port'))
210
		$input_errors[] = $result;
211

    
212
	if ($pconfig['proxy_addr']) {
213

    
214
		if ($result = openvpn_validate_host($pconfig['proxy_addr'], 'Proxy host or address'))
215
			$input_errors[] = $result;
216

    
217
		if ($result = openvpn_validate_port($pconfig['proxy_port'], 'Proxy port'))
218
			$input_errors[] = $result;
219

    
220
		if ($pconfig['proxy_authtype'] != "none") {
221
			if (empty($pconfig['proxy_user']) || empty($pconfig['proxy_passwd']))
222
				$input_errors[] = gettext("User name and password are required for proxy with authentication.");
223
		}
224
	}
225

    
226
	if($pconfig['tunnel_network'])
227
		if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'IPv4 Tunnel Network', false, "ipv4"))
228
			$input_errors[] = $result;
229

    
230
	if($pconfig['tunnel_networkv6'])
231
		if ($result = openvpn_validate_cidr($pconfig['tunnel_networkv6'], 'IPv6 Tunnel Network', false, "ipv6"))
232
			$input_errors[] = $result;
233

    
234
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'IPv4 Remote Network', true, "ipv4"))
235
		$input_errors[] = $result;
236

    
237
	if ($result = openvpn_validate_cidr($pconfig['remote_networkv6'], 'IPv6 Remote Network', true, "ipv6"))
238
		$input_errors[] = $result;
239

    
240
	if (!empty($pconfig['use_shaper']) && (!is_numeric($pconfig['use_shaper']) || ($pconfig['use_shaper'] <= 0)))
241
		$input_errors[] = gettext("The bandwidth limit must be a positive numeric value.");
242

    
243
	if ($pconfig['autokey_enable'])
244
		$pconfig['shared_key'] = openvpn_create_key();
245

    
246
	if (!$tls_mode && !$pconfig['autokey_enable'])
247
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
248
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
249
			$input_errors[] = gettext("The field 'Shared Key' does not appear to be valid");
250

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

    
256
	/* If we are not in shared key mode, then we need the CA/Cert. */
257
	if ($pconfig['mode'] != "p2p_shared_key") {
258
		$reqdfields = explode(" ", "caref");
259
		$reqdfieldsn = array(gettext("Certificate Authority"));
260
	} elseif (!$pconfig['autokey_enable']) {
261
		/* We only need the shared key filled in if we are in shared key mode and autokey is not selected. */
262
		$reqdfields = array('shared_key');
263
		$reqdfieldsn = array(gettext('Shared key'));
264
	}
265

    
266
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
267

    
268
	if (($pconfig['mode'] != "p2p_shared_key") && empty($pconfig['certref']) && empty($pconfig['auth_user']) && empty($pconfig['auth_pass'])) {
269
		$input_errors[] = gettext("If no Client Certificate is selected, a username and password must be entered.");
270
	}
271

    
272
	if (!$input_errors) {
273

    
274
		$client = array();
275

    
276
		foreach($simplefields as $stat)
277
			update_if_changed($stat, $client[$stat], $_POST[$stat]);
278

    
279
		if ($vpnid)
280
			$client['vpnid'] = $vpnid;
281
		else
282
			$client['vpnid'] = openvpn_vpnid_next();
283

    
284
		if ($_POST['disable'] == "yes")
285
			$client['disable'] = true;
286
		$client['protocol'] = $pconfig['protocol'];
287
		$client['dev_mode'] = $pconfig['dev_mode'];
288
		list($client['interface'], $client['ipaddr']) = explode ("|",$pconfig['interface']);
289
		$client['local_port'] = $pconfig['local_port'];
290
		$client['server_addr'] = $pconfig['server_addr'];
291
		$client['server_port'] = $pconfig['server_port'];
292
		$client['resolve_retry'] = $pconfig['resolve_retry'];
293
		$client['proxy_addr'] = $pconfig['proxy_addr'];
294
		$client['proxy_port'] = $pconfig['proxy_port'];
295
		$client['proxy_authtype'] = $pconfig['proxy_authtype'];
296
		$client['proxy_user'] = $pconfig['proxy_user'];
297
		$client['proxy_passwd'] = $pconfig['proxy_passwd'];
298
		$client['description'] = $pconfig['description'];
299
		$client['mode'] = $pconfig['mode'];
300
		$client['custom_options'] = str_replace("\r\n", "\n", $pconfig['custom_options']);
301

    
302
		if ($tls_mode) {
303
			$client['caref'] = $pconfig['caref'];
304
			$client['certref'] = $pconfig['certref'];
305
			if ($pconfig['tlsauth_enable']) {
306
				if ($pconfig['autotls_enable'])
307
					$pconfig['tls'] = openvpn_create_key();
308
				$client['tls'] = base64_encode($pconfig['tls']);
309
			}
310
		} else {
311
			$client['shared_key'] = base64_encode($pconfig['shared_key']);
312
		}
313
		$client['crypto'] = $pconfig['crypto'];
314
		$client['digest'] = $pconfig['digest'];
315
		$client['engine'] = $pconfig['engine'];
316

    
317
		$client['tunnel_network'] = $pconfig['tunnel_network'];
318
		$client['tunnel_networkv6'] = $pconfig['tunnel_networkv6'];
319
		$client['remote_network'] = $pconfig['remote_network'];
320
		$client['remote_networkv6'] = $pconfig['remote_networkv6'];
321
		$client['use_shaper'] = $pconfig['use_shaper'];
322
		$client['compression'] = $pconfig['compression'];
323
		$client['passtos'] = $pconfig['passtos'];
324

    
325
		$client['no_tun_ipv6'] = $pconfig['no_tun_ipv6'];
326
		$client['route_no_pull'] = $pconfig['route_no_pull'];
327
		$client['route_no_exec'] = $pconfig['route_no_exec'];
328
		$client['verbosity_level'] = $pconfig['verbosity_level'];
329

    
330
		if (isset($id) && $a_client[$id])
331
			$a_client[$id] = $client;
332
		else
333
			$a_client[] = $client;
334

    
335
		openvpn_resync('client', $client);
336
		write_config();
337

    
338
		header("Location: vpn_openvpn_client.php");
339
		exit;
340
	}
341
}
342

    
343
include("head.inc");
344

    
345
?>
346

    
347
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
348
<?php include("fbegin.inc"); ?>
349
<script type="text/javascript">
350
//<![CDATA[
351

    
352
function mode_change() {
353
	index = document.iform.mode.selectedIndex;
354
	value = document.iform.mode.options[index].value;
355
	switch(value) {
356
		case "p2p_tls":
357
			document.getElementById("tls").style.display="";
358
			document.getElementById("tls_ca").style.display="";
359
			document.getElementById("tls_cert").style.display="";
360
			document.getElementById("userpass").style.display="";
361
			document.getElementById("userpassheader").style.display="";
362
			document.getElementById("psk").style.display="none";
363
			break;
364
		case "p2p_shared_key":
365
			document.getElementById("tls").style.display="none";
366
			document.getElementById("tls_ca").style.display="none";
367
			document.getElementById("tls_cert").style.display="none";
368
			document.getElementById("userpass").style.display="none";
369
			document.getElementById("userpassheader").style.display="none";
370
			document.getElementById("psk").style.display="";
371
			break;
372
	}
373
}
374

    
375
function dev_mode_change() {
376
	index = document.iform.dev_mode.selectedIndex;
377
	value = document.iform.dev_mode.options[index].value;
378
	switch(value) {
379
		case "tun":
380
			document.getElementById("chkboxNoTunIPv6").style.display="";
381
			break;
382
		case "tap":
383
			document.getElementById("chkboxNoTunIPv6").style.display="none";
384
			break;
385
	}
386
}
387

    
388
function autokey_change() {
389
	if (document.iform.autokey_enable.checked)
390
		document.getElementById("autokey_opts").style.display="none";
391
	else
392
		document.getElementById("autokey_opts").style.display="";
393
}
394

    
395
function useproxy_changed() {
396

    
397
	if (jQuery('#proxy_authtype').val() != 'none') {
398
		jQuery('#proxy_authtype_opts').show();
399
	} else {
400
		jQuery('#proxy_authtype_opts').hide();
401
	}
402
}
403

    
404
function tlsauth_change() {
405

    
406
<?php if (!$pconfig['tls']): ?>
407
	if (document.iform.tlsauth_enable.checked)
408
		document.getElementById("tlsauth_opts").style.display="";
409
	else
410
		document.getElementById("tlsauth_opts").style.display="none";
411
<?php endif; ?>
412

    
413
	autotls_change();
414
}
415

    
416
function autotls_change() {
417

    
418
<?php if (!$pconfig['tls']): ?>
419
	autocheck = document.iform.autotls_enable.checked;
420
<?php else: ?>
421
	autocheck = false;
422
<?php endif; ?>
423

    
424
	if (document.iform.tlsauth_enable.checked && !autocheck)
425
		document.getElementById("autotls_opts").style.display="";
426
	else
427
		document.getElementById("autotls_opts").style.display="none";
428
}
429

    
430
//]]>
431
</script>
432
<?php
433
if (!$savemsg)
434
	$savemsg = "";
435

    
436
if ($input_errors)
437
	print_input_errors($input_errors);
438
if ($savemsg)
439
	print_info_box($savemsg);
440
?>
441
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn openvpn client">
442
	<tr>
443
		<td class="tabnavtbl">
444
			<?php
445
				$tab_array = array();
446
				$tab_array[] = array(gettext("Server"), false, "vpn_openvpn_server.php");
447
				$tab_array[] = array(gettext("Client"), true, "vpn_openvpn_client.php");
448
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
449
				$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
450
				add_package_tabs("openvpn-client-export", $tab_array);
451
				display_top_tabs($tab_array);
452
			?>
453
		</td>
454
	</tr>
455
	<tr>
456
		<td class="tabcont">
457

    
458
			<?php if($act=="new" || $act=="edit"): ?>
459

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

    
992
					<tr id="chkboxNoTunIPv6">
993
						<td width="22%" valign="top" class="vncell"><?=gettext("Disable IPv6"); ?></td>
994
						<td width="78%" class="vtable">
995
							<table border="0" cellpadding="2" cellspacing="0" summary="disable-ipv6">
996
								<tr>
997
									<td>
998
										<?php set_checked($pconfig['no_tun_ipv6'],$chk); ?>
999
										<input name="no_tun_ipv6" type="checkbox" value="yes" <?=$chk;?> />
1000
									</td>
1001
									<td>
1002
										<span class="vexpl">
1003
											<?=gettext("Don't forward IPv6 traffic"); ?>.
1004
										</span>
1005
									</td>
1006
								</tr>
1007
							</table>
1008
						</td>
1009
					</tr>
1010

    
1011
					<tr id="chkboxRouteNoPull">
1012
						<td width="22%" valign="top" class="vncell"><?=gettext("Don't pull routes"); ?></td>
1013
						<td width="78%" class="vtable">
1014
							<table border="0" cellpadding="2" cellspacing="0" summary="dont-pull-routes">
1015
								<tr>
1016
									<td>
1017
										<?php set_checked($pconfig['route_no_pull'],$chk); ?>
1018
										<input name="route_no_pull" type="checkbox" value="yes" <?=$chk;?> />
1019
									</td>
1020
									<td>
1021
										<span class="vexpl">
1022
											<?=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"); ?>.
1023
										</span>
1024
									</td>
1025
								</tr>
1026
							</table>
1027
						</td>
1028
					</tr>
1029

    
1030
					<tr id="chkboxRouteNoExec">
1031
						<td width="22%" valign="top" class="vncell"><?=gettext("Don't add/remove routes"); ?></td>
1032
						<td width="78%" class="vtable">
1033
							<table border="0" cellpadding="2" cellspacing="0" summary="dont-exec-routes">
1034
								<tr>
1035
									<td>
1036
										<?php set_checked($pconfig['route_no_exec'],$chk); ?>
1037
										<input name="route_no_exec" type="checkbox" value="yes" <?=$chk;?> />
1038
									</td>
1039
									<td>
1040
										<span class="vexpl">
1041
											<?=gettext("Don't add or remove routes automatically. Instead pass routes to "); ?> <strong>--route-up</strong> <?=gettext("script using environmental variables"); ?>.
1042
										</span>
1043
									</td>
1044
								</tr>
1045
							</table>
1046
						</td>
1047
					</tr>
1048
				</table>
1049

    
1050
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts" summary="advance configuration">
1051
					<tr>
1052
						<td colspan="2" class="list" height="12"></td>
1053
					</tr>
1054
					<tr>
1055
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
1056
					</tr>
1057
					<tr>
1058
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1059
						<td width="78%" class="vtable">
1060
							<table border="0" cellpadding="2" cellspacing="0" summary="advance configuration">
1061
								<tr>
1062
									<td>
1063
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=htmlspecialchars($pconfig['custom_options']);?></textarea><br />
1064
										<?=gettext("Enter any additional options you would like to add to the OpenVPN client configuration here, separated by a semicolon"); ?><br />
1065
										<?=gettext("EXAMPLE:"); ?> <strong>remote server.example.com 1194;</strong> or <strong>remote 1.2.3.4 1194;</strong>
1066
									</td>
1067
								</tr>
1068
							</table>
1069
						</td>
1070
					</tr>
1071

    
1072
					<tr id="comboboxVerbosityLevel">
1073
							<td width="22%" valign="top" class="vncell"><?=gettext("Verbosity level");?></td>
1074
							<td width="78%" class="vtable">
1075
							<select name="verbosity_level" class="formselect">
1076
							<?php
1077
								foreach ($openvpn_verbosity_level as $verb_value => $verb_desc):
1078
									$selected = "";
1079
									if ($pconfig['verbosity_level'] == $verb_value)
1080
										$selected = "selected=\"selected\"";
1081
							?>
1082
								<option value="<?=$verb_value;?>" <?=$selected;?>><?=$verb_desc;?></option>
1083
							<?php endforeach; ?>
1084
							</select>
1085
							<br />
1086
							<?=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 />
1087
							<strong>none</strong> -- <?=gettext("No output except fatal errors"); ?>. <br />
1088
							<strong>default</strong>-<strong>4</strong> -- <?=gettext("Normal usage range"); ?>. <br />
1089
							<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 />
1090
							<strong>6</strong>-<strong>11</strong> -- <?=gettext("Debug info range"); ?>.
1091
							</td>
1092
					</tr>
1093

    
1094
				</table>
1095

    
1096
				<br />
1097
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="icons">
1098
					<tr>
1099
						<td width="22%" valign="top">&nbsp;</td>
1100
						<td width="78%">
1101
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
1102
							<input name="act" type="hidden" value="<?=$act;?>" />
1103
							<?php if (isset($id) && $a_client[$id]): ?>
1104
							<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
1105
							<?php endif; ?>
1106
						</td>
1107
					</tr>
1108
				</table>
1109
			</form>
1110

    
1111
			<?php else: ?>
1112

    
1113
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="list of openvpn clients">
1114
				<thead>
1115
				<tr>
1116
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
1117
					<td width="10%" class="listhdrr"><?=gettext("Protocol"); ?></td>
1118
					<td width="30%" class="listhdrr"><?=gettext("Server"); ?></td>
1119
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
1120
					<td width="10%" class="list"></td>
1121
				</tr>
1122
				</thead>
1123
				<tfoot>
1124
				<tr>
1125
					<td class="list" colspan="4"></td>
1126
					<td class="list">
1127
						<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" />
1128
						</a>
1129
					</td>
1130
				</tr>
1131
				<tr>
1132
					<td colspan="4">
1133
						<p>
1134
							<?=gettext("Additional OpenVPN clients can be added here.");?>
1135
						</p>
1136
					</td>
1137
				</tr>
1138
				</tfoot>
1139
				<tbody>
1140
				<?php
1141
					$i = 0;
1142
					foreach($a_client as $client):
1143
						$disabled = "NO";
1144
						if (isset($client['disable']))
1145
							$disabled = "YES";
1146
						$server = "{$client['server_addr']}:{$client['server_port']}";
1147
				?>
1148
				<tr ondblclick="document.location='vpn_openvpn_client.php?act=edit&amp;id=<?=$i;?>'">
1149
					<td class="listlr">
1150
						<?=$disabled;?>
1151
					</td>
1152
					<td class="listr">
1153
						<?=htmlspecialchars($client['protocol']);?>
1154
					</td>
1155
					<td class="listr">
1156
						<?=htmlspecialchars($server);?>
1157
					</td>
1158
					<td class="listbg">
1159
						<?=htmlspecialchars($client['description']);?>
1160
					</td>
1161
					<td valign="middle" class="list nowrap">
1162
						<a href="vpn_openvpn_client.php?act=edit&amp;id=<?=$i;?>">
1163
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit client"); ?>" width="17" height="17" border="0" alt="edit" />
1164
						</a>
1165
						&nbsp;
1166
						<a href="vpn_openvpn_client.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this client?"); ?>')">
1167
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete client"); ?>" width="17" height="17" border="0" alt="delete" />
1168
						</a>
1169
					</td>
1170
				</tr>
1171
				<?php
1172
					$i++;
1173
					endforeach;
1174
				?>
1175
				<tr style="display:none;"><td></td></tr>
1176
				</tbody>
1177
			</table>
1178

    
1179
			<?php endif; ?>
1180

    
1181
		</td>
1182
	</tr>
1183
</table>
1184
<script type="text/javascript">
1185
//<![CDATA[
1186
mode_change();
1187
autokey_change();
1188
tlsauth_change();
1189
useproxy_changed();
1190
//]]>
1191
</script>
1192
<?php include("fend.inc"); ?>
1193
</body>
1194
</html>
1195

    
1196
<?php
1197

    
1198
/* local utility functions */
1199

    
1200
function set_checked($var,& $chk) {
1201
	if($var)
1202
		$chk = "checked=\"checked\"";
1203
	else
1204
		$chk = "";
1205
}
1206

    
1207
?>
(247-247/256)