Project

General

Profile

Download (39.2 KB) Statistics
| Branch: | Tag: | Revision:
1 d799787e Matthew Grooms
<?php 
2
/*
3
	vpn_openvpn_client.php
4
5
	Copyright (C) 2008 Shrew Soft Inc.
6
	All rights reserved. 
7
8
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10
	
11
	1. Redistributions of source code must retain the above copyright notice,
12
	   this list of conditions and the following disclaimer.
13
	
14
	2. Redistributions in binary form must reproduce the above copyright
15
	   notice, this list of conditions and the following disclaimer in the
16
	   documentation and/or other materials provided with the distribution.
17
	
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29
30
##|+PRIV
31
##|*IDENT=page-openvpn-client
32
##|*NAME=OpenVPN: Client page
33
##|*DESCR=Allow access to the 'OpenVPN: Client' page.
34
##|*MATCH=vpn_openvpn_client.php*
35
##|-PRIV
36
37
require("guiconfig.inc");
38 d84bd468 Ermal Lu?i
require_once("openvpn.inc");
39 d799787e Matthew Grooms
40 2fa7a468 Carlos Eduardo Ramos
$pgtitle = array(gettext("OpenVPN"), gettext("Client"));
41 b32dd0a6 jim-p
$shortcut_section = "openvpn";
42 d799787e Matthew Grooms
43
if (!is_array($config['openvpn']['openvpn-client']))
44
	$config['openvpn']['openvpn-client'] = array();
45
46
$a_client = &$config['openvpn']['openvpn-client'];
47
48 428e66b6 jim-p
if (!is_array($config['ca']))
49
	$config['ca'] = array();
50
51
$a_ca =& $config['ca'];
52
53
if (!is_array($config['cert']))
54
	$config['cert'] = array();
55
56
$a_cert =& $config['cert'];
57
58
if (!is_array($config['crl']))
59
	$config['crl'] = array();
60
61
$a_crl =& $config['crl'];
62
63 d799787e Matthew Grooms
$id = $_GET['id'];
64
if (isset($_POST['id']))
65
	$id = $_POST['id'];
66
67
$act = $_GET['act'];
68
if (isset($_POST['act']))
69
	$act = $_POST['act'];
70
71 6d9b1074 jim-p
if (isset($id) && $a_client[$id])
72
	$vpnid = $a_client[$id]['vpnid'];
73
else
74
	$vpnid = 0;
75
76 d799787e Matthew Grooms
if ($_GET['act'] == "del") {
77
78 767cf960 jim-p
	if (!isset($a_client[$id])) {
79 d799787e Matthew Grooms
		pfSenseHeader("vpn_openvpn_client.php");
80
		exit;
81
	}
82 767cf960 jim-p
	if (!empty($a_client[$id]))
83
		openvpn_delete('client', $a_client[$id]);
84 d799787e Matthew Grooms
	unset($a_client[$id]);
85
	write_config();
86
	$savemsg = gettext("Client successfully deleted")."<br/>";
87
}
88
89 f432e364 Matthew Grooms
if($_GET['act']=="new"){
90 3c11bd3c Matthew Grooms
	$pconfig['autokey_enable'] = "yes";
91
	$pconfig['tlsauth_enable'] = "yes";
92
	$pconfig['autotls_enable'] = "yes";
93 f432e364 Matthew Grooms
	$pconfig['interface'] = "wan";
94
	$pconfig['server_port'] = 1194;
95
}
96
97 d799787e Matthew Grooms
if($_GET['act']=="edit"){
98
99
	if (isset($id) && $a_client[$id]) {
100
101 8319ee63 jim-p
		$pconfig['disable'] = isset($a_client[$id]['disable']);
102 3c11bd3c Matthew Grooms
		$pconfig['mode'] = $a_client[$id]['mode'];
103 d799787e Matthew Grooms
		$pconfig['protocol'] = $a_client[$id]['protocol'];
104
		$pconfig['interface'] = $a_client[$id]['interface'];
105 67b0902f pierrepomes
		if (!empty($a_client[$id]['ipaddr'])) {
106
			$pconfig['interface'] = $pconfig['interface'] . '|' . $a_client[$id]['ipaddr'];
107
		}
108 d799787e Matthew Grooms
		$pconfig['local_port'] = $a_client[$id]['local_port'];
109
		$pconfig['server_addr'] = $a_client[$id]['server_addr'];
110
		$pconfig['server_port'] = $a_client[$id]['server_port'];
111
		$pconfig['resolve_retry'] = $a_client[$id]['resolve_retry'];
112
		$pconfig['proxy_addr'] = $a_client[$id]['proxy_addr'];
113
		$pconfig['proxy_port'] = $a_client[$id]['proxy_port'];
114 762a24a3 Ermal Lu?i
		$pconfig['proxy_user'] = $a_client[$id]['proxy_user'];
115
		$pconfig['proxy_passwd'] = $a_client[$id]['proxy_passwd'];
116
		$pconfig['proxy_authtype'] = $a_client[$id]['proxy_authtype'];
117 d799787e Matthew Grooms
		$pconfig['description'] = $a_client[$id]['description'];
118 c7323d81 sullrich
		$pconfig['custom_options'] = $a_client[$id]['custom_options'];
119 691fbf14 Ermal Lu?i
		$pconfig['ns_cert_type'] = $a_client[$id]['ns_cert_type'];
120 4936ff53 jim-p
		$pconfig['dev_mode'] = $a_client[$id]['dev_mode'];
121 691fbf14 Ermal Lu?i
	
122 3c11bd3c Matthew Grooms
		if ($pconfig['mode'] != "p2p_shared_key") {
123 d799787e Matthew Grooms
			$pconfig['caref'] = $a_client[$id]['caref'];
124
			$pconfig['certref'] = $a_client[$id]['certref'];
125 3c11bd3c Matthew Grooms
			if ($a_client[$id]['tls']) {
126
				$pconfig['tlsauth_enable'] = "yes";
127
				$pconfig['tls'] = base64_decode($a_client[$id]['tls']);
128
			}
129
		} else
130
			$pconfig['shared_key'] = base64_decode($a_client[$id]['shared_key']);
131 d799787e Matthew Grooms
		$pconfig['crypto'] = $a_client[$id]['crypto'];
132 f5c704b6 jim-p
		$pconfig['engine'] = $a_client[$id]['engine'];
133 d799787e Matthew Grooms
134
		$pconfig['tunnel_network'] = $a_client[$id]['tunnel_network'];
135 4856df9b jim-p
		$pconfig['tunnel_networkv6'] = $a_client[$id]['tunnel_networkv6'];
136 d799787e Matthew Grooms
		$pconfig['remote_network'] = $a_client[$id]['remote_network'];
137 4856df9b jim-p
		$pconfig['remote_networkv6'] = $a_client[$id]['remote_networkv6'];
138 b422360c jim-p
		$pconfig['use_shaper'] = $a_client[$id]['use_shaper'];
139 d799787e Matthew Grooms
		$pconfig['compression'] = $a_client[$id]['compression'];
140 1cb0b40a Matthew Grooms
		$pconfig['passtos'] = $a_client[$id]['passtos'];
141 3c11bd3c Matthew Grooms
142
		// just in case the modes switch
143
		$pconfig['autokey_enable'] = "yes";
144
		$pconfig['autotls_enable'] = "yes";
145 d799787e Matthew Grooms
	}
146
}
147
148
if ($_POST) {
149
150
	unset($input_errors);
151
	$pconfig = $_POST;
152
153 dc408939 Matthew Grooms
	if (isset($id) && $a_client[$id])
154
		$vpnid = $a_client[$id]['vpnid'];
155 f432e364 Matthew Grooms
	else
156
		$vpnid = 0;
157
158 198bb449 jim-p
	list($iv_iface, $iv_ip) = explode ("|",$pconfig['interface']);
159
	if (is_ipaddrv4($iv_ip) && (stristr($pconfig['protocol'], "6") !== false)) {
160
		$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv6 protocol and an IPv4 IP address.");
161
	} elseif (is_ipaddrv6($iv_ip) && (stristr($pconfig['protocol'], "6") === false)) {
162
		$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv4 protocol and an IPv6 IP address.");
163 489f484c jim-p
	} elseif ((stristr($pconfig['protocol'], "6") === false) && !get_interface_ip($iv_iface) && ($pconfig['interface'] != "any")) {
164 198bb449 jim-p
		$input_errors[] = gettext("An IPv4 protocol was selected, but the selected interface has no IPv4 address.");
165 489f484c jim-p
	} elseif ((stristr($pconfig['protocol'], "6") !== false) && !get_interface_ipv6($iv_iface) && ($pconfig['interface'] != "any")) {
166 198bb449 jim-p
		$input_errors[] = gettext("An IPv6 protocol was selected, but the selected interface has no IPv6 address.");
167
	}
168
169 98c0c87a jim-p
	if ($pconfig['mode'] != "p2p_shared_key")
170 3c11bd3c Matthew Grooms
		$tls_mode = true;
171
	else
172
		$tls_mode = false;
173
174 d799787e Matthew Grooms
	/* input validation */
175 f432e364 Matthew Grooms
	if ($pconfig['local_port']) {
176
177
		if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
178
			$input_errors[] = $result;
179
180 49b76122 Renato Botelho
		$portused = openvpn_port_used($pconfig['protocol'], $pconfig['interface'], $pconfig['local_port'], $vpnid);
181 5accf130 jim-p
		if (($portused != $vpnid) && ($portused != 0))
182 2fa7a468 Carlos Eduardo Ramos
			$input_errors[] = gettext("The specified 'Local port' is in use. Please select another value");
183 f432e364 Matthew Grooms
	}
184
185 d799787e Matthew Grooms
	if ($result = openvpn_validate_host($pconfig['server_addr'], 'Server host or address'))
186
		$input_errors[] = $result;
187
188
	if ($result = openvpn_validate_port($pconfig['server_port'], 'Server port'))
189
		$input_errors[] = $result;
190
191
	if ($pconfig['proxy_addr']) {
192
193
		if ($result = openvpn_validate_host($pconfig['proxy_addr'], 'Proxy host or address'))
194
			$input_errors[] = $result;
195
196
		if ($result = openvpn_validate_port($pconfig['proxy_port'], 'Proxy port'))
197
			$input_errors[] = $result;
198 762a24a3 Ermal Lu?i
199
		if ($pconfig['proxy_authtype'] != "none") {
200
			if (empty($pconfig['proxy_user']) || empty($pconfig['proxy_passwd']))
201 2fa7a468 Carlos Eduardo Ramos
				$input_errors[] = gettext("User name and password are required for proxy with authentication.");
202 762a24a3 Ermal Lu?i
		}
203 d799787e Matthew Grooms
	}
204
205 c13b87a0 sullrich
	if($pconfig['tunnel_network'])
206 a28d40cb jim-p
		if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'IPv4 Tunnel Network', false, "ipv4"))
207 c13b87a0 sullrich
			$input_errors[] = $result;
208 d799787e Matthew Grooms
209 a28d40cb jim-p
	if($pconfig['tunnel_networkv6'])
210
		if ($result = openvpn_validate_cidr($pconfig['tunnel_networkv6'], 'IPv6 Tunnel Network', false, "ipv6"))
211
			$input_errors[] = $result;
212
213
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'IPv4 Remote Network', true, "ipv4"))
214
		$input_errors[] = $result;
215
216
	if ($result = openvpn_validate_cidr($pconfig['remote_networkv6'], 'IPv6 Remote Network', true, "ipv6"))
217 d799787e Matthew Grooms
		$input_errors[] = $result;
218
219 b422360c jim-p
	if (!empty($pconfig['use_shaper']) && (!is_numeric($pconfig['use_shaper']) || ($pconfig['use_shaper'] <= 0)))
220
		$input_errors[] = gettext("The bandwidth limit must be a positive numeric value.");
221
222 89e6e210 jim-p
    if ($pconfig['autokey_enable'])
223
        $pconfig['shared_key'] = openvpn_create_key();
224
225 3c11bd3c Matthew Grooms
	if (!$tls_mode && !$pconfig['autokey_enable'])
226 d799787e Matthew Grooms
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
227
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
228 2fa7a468 Carlos Eduardo Ramos
			$input_errors[] = gettext("The field 'Shared Key' does not appear to be valid");
229 3c11bd3c Matthew Grooms
230
	if ($tls_mode && $pconfig['tlsauth_enable'] && !$pconfig['autotls_enable'])
231
		if (!strstr($pconfig['tls'], "-----BEGIN OpenVPN Static key V1-----") ||
232
			!strstr($pconfig['tls'], "-----END OpenVPN Static key V1-----"))
233 2fa7a468 Carlos Eduardo Ramos
			$input_errors[] = gettext("The field 'TLS Authentication Key' does not appear to be valid");
234 d799787e Matthew Grooms
235 6180c3ae jim-p
	/* If we are not in shared key mode, then we need the CA/Cert. */
236
	if ($pconfig['mode'] != "p2p_shared_key") {
237 872d9195 Matthew Grooms
		$reqdfields = explode(" ", "caref certref");
238 2fa7a468 Carlos Eduardo Ramos
		$reqdfieldsn = array(gettext("Certificate Authority"),gettext("Certificate"));
239 6180c3ae jim-p
	} elseif (!$pconfig['autokey_enable']) {
240
		/* We only need the shared key filled in if we are in shared key mode and autokey is not selected. */
241
		$reqdfields = array('shared_key');
242 2fa7a468 Carlos Eduardo Ramos
		$reqdfieldsn = array(gettext('Shared key'));
243 d799787e Matthew Grooms
	}
244
245
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
246
	
247
	if (!$input_errors) {
248
249
		$client = array();
250
251 f432e364 Matthew Grooms
		if ($vpnid)
252
			$client['vpnid'] = $vpnid;
253 d799787e Matthew Grooms
		else
254
			$client['vpnid'] = openvpn_vpnid_next();
255
256 8319ee63 jim-p
		if ($_POST['disable'] == "yes")
257 b65f56f6 jim-p
			$client['disable'] = true;
258 d799787e Matthew Grooms
		$client['protocol'] = $pconfig['protocol'];
259 4936ff53 jim-p
		$client['dev_mode'] = $pconfig['dev_mode'];
260 67b0902f pierrepomes
		list($client['interface'], $client['ipaddr']) = explode ("|",$pconfig['interface']);
261 d799787e Matthew Grooms
		$client['local_port'] = $pconfig['local_port'];
262
		$client['server_addr'] = $pconfig['server_addr'];
263
		$client['server_port'] = $pconfig['server_port'];
264
		$client['resolve_retry'] = $pconfig['resolve_retry'];
265
		$client['proxy_addr'] = $pconfig['proxy_addr'];
266
		$client['proxy_port'] = $pconfig['proxy_port'];
267 762a24a3 Ermal Lu?i
		$client['proxy_authtype'] = $pconfig['proxy_authtype'];
268
		$client['proxy_user'] = $pconfig['proxy_user'];
269
		$client['proxy_passwd'] = $pconfig['proxy_passwd'];
270 d799787e Matthew Grooms
		$client['description'] = $pconfig['description'];
271 50a9d5b9 jim-p
		$client['mode'] = $pconfig['mode'];
272 e3bbd29a Ermal
		$client['custom_options'] = str_replace("\r\n", "\n", $pconfig['custom_options']);
273 d799787e Matthew Grooms
274 3c11bd3c Matthew Grooms
        if ($tls_mode) {
275
            $client['caref'] = $pconfig['caref'];
276
            $client['certref'] = $pconfig['certref'];
277
            if ($pconfig['tlsauth_enable']) {
278
                if ($pconfig['autotls_enable'])
279
                    $pconfig['tls'] = openvpn_create_key();
280
                $client['tls'] = base64_encode($pconfig['tls']);
281
            }
282
        } else {
283
            $client['shared_key'] = base64_encode($pconfig['shared_key']);
284
        }
285 d799787e Matthew Grooms
		$client['crypto'] = $pconfig['crypto'];
286 582c58ae jim-p
		$client['engine'] = $pconfig['engine'];
287 d799787e Matthew Grooms
288
		$client['tunnel_network'] = $pconfig['tunnel_network'];
289 4856df9b jim-p
		$client['tunnel_networkv6'] = $pconfig['tunnel_networkv6'];
290 d799787e Matthew Grooms
		$client['remote_network'] = $pconfig['remote_network'];
291 4856df9b jim-p
		$client['remote_networkv6'] = $pconfig['remote_networkv6'];
292 b422360c jim-p
		$client['use_shaper'] = $pconfig['use_shaper'];
293 d799787e Matthew Grooms
		$client['compression'] = $pconfig['compression'];
294 e067306d pierrepomes
		$client['passtos'] = $pconfig['passtos'];
295 d799787e Matthew Grooms
296
		if (isset($id) && $a_client[$id])
297
			$a_client[$id] = $client;
298
		else
299
			$a_client[] = $client;
300
301 dc408939 Matthew Grooms
		openvpn_resync('client', $client);
302 d799787e Matthew Grooms
		write_config();
303
		
304
		header("Location: vpn_openvpn_client.php");
305
		exit;
306
	}
307
}
308
309
include("head.inc");
310
311
?>
312
313
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
314
<?php include("fbegin.inc"); ?>
315
<script language="JavaScript">
316
<!--
317
318 3c11bd3c Matthew Grooms
function mode_change() {
319
	index = document.iform.mode.selectedIndex;
320
	value = document.iform.mode.options[index].value;
321 d799787e Matthew Grooms
	switch(value) {
322 3c11bd3c Matthew Grooms
		case "p2p_tls":
323
			document.getElementById("tls").style.display="";
324
			document.getElementById("tls_ca").style.display="";
325
			document.getElementById("tls_cert").style.display="";
326 d799787e Matthew Grooms
			document.getElementById("psk").style.display="none";
327
			break;
328 3c11bd3c Matthew Grooms
		case "p2p_shared_key":
329
			document.getElementById("tls").style.display="none";
330
			document.getElementById("tls_ca").style.display="none";
331
			document.getElementById("tls_cert").style.display="none";
332 d799787e Matthew Grooms
			document.getElementById("psk").style.display="";
333
			break;
334
	}
335
}
336
337 3c11bd3c Matthew Grooms
function autokey_change() {
338
	if (document.iform.autokey_enable.checked)
339
		document.getElementById("autokey_opts").style.display="none";
340
	else
341
		document.getElementById("autokey_opts").style.display="";
342
}
343
344 762a24a3 Ermal Lu?i
function useproxy_changed() {
345
346 ea1cea05 Vinicius Coque
	if (jQuery('#proxy_authtype').val() != 'none') {
347
                jQuery('#proxy_authtype_opts').show();
348 762a24a3 Ermal Lu?i
        } else {
349 ea1cea05 Vinicius Coque
                jQuery('#proxy_authtype_opts').hide();
350 762a24a3 Ermal Lu?i
        }
351
}
352
353 3c11bd3c Matthew Grooms
function tlsauth_change() {
354
355
<?php if (!$pconfig['tls']): ?>
356
	if (document.iform.tlsauth_enable.checked)
357
		document.getElementById("tlsauth_opts").style.display="";
358
	else
359
		document.getElementById("tlsauth_opts").style.display="none";
360
<?php endif; ?>
361
362
	autotls_change();
363
}
364
365
function autotls_change() {
366
367
<?php if (!$pconfig['tls']): ?>
368
	autocheck = document.iform.autotls_enable.checked;
369
<?php else: ?>
370
	autocheck = false;
371
<?php endif; ?>
372
373
	if (document.iform.tlsauth_enable.checked && !autocheck)
374
		document.getElementById("autotls_opts").style.display="";
375
	else
376
		document.getElementById("autotls_opts").style.display="none";
377
}
378
379 d799787e Matthew Grooms
//-->
380
</script>
381
<?php
382 428e66b6 jim-p
if (!$savemsg)
383
	$savemsg = "";
384
385
if ($input_errors)
386
	print_input_errors($input_errors);
387
if ($savemsg)
388
	print_info_box($savemsg);
389 d799787e Matthew Grooms
?>
390
<table width="100%" border="0" cellpadding="0" cellspacing="0">
391
 	<tr>
392
		<td class="tabnavtbl">
393
			<ul id="tabnav">
394
			<?php 
395
				$tab_array = array();
396
				$tab_array[] = array(gettext("Server"), false, "vpn_openvpn_server.php");
397
				$tab_array[] = array(gettext("Client"), true, "vpn_openvpn_client.php");
398
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
399 5540aee6 Ermal Lu?i
				$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
400 b63f2e8b Matthew Grooms
				add_package_tabs("OpenVPN", $tab_array);
401 d799787e Matthew Grooms
				display_top_tabs($tab_array);
402
			?>
403
			</ul>
404
		</td>
405
	</tr>    
406
	<tr>
407
		<td class="tabcont">
408
409
			<?php if($act=="new" || $act=="edit"): ?>
410
411
			<form action="vpn_openvpn_client.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
412
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
413 47c00c09 Scott Ullrich
					<tr>
414 2fa7a468 Carlos Eduardo Ramos
						<td colspan="2" valign="top" class="listtopic"><?=gettext("General information"); ?></td>
415 47c00c09 Scott Ullrich
					</tr>
416 d799787e Matthew Grooms
					<tr>
417 2fa7a468 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td>
418 d799787e Matthew Grooms
						<td width="78%" class="vtable">
419
							<table border="0" cellpadding="0" cellspacing="0">
420
								<tr>
421
									<td>
422
										<?php set_checked($pconfig['disable'],$chk); ?>
423
										<input name="disable" type="checkbox" value="yes" <?=$chk;?>/>
424
									</td>
425
									<td>
426
										&nbsp;
427
										<span class="vexpl">
428 2fa7a468 Carlos Eduardo Ramos
											<strong><?=gettext("Disable this client"); ?></strong><br>
429 d799787e Matthew Grooms
										</span>
430
									</td>
431
								</tr>
432
							</table>
433 2fa7a468 Carlos Eduardo Ramos
							<?=gettext("Set this option to disable this client without removing it from the list"); ?>.
434 d799787e Matthew Grooms
						</td>
435
					</tr>
436 3c11bd3c Matthew Grooms
					<tr>
437
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server Mode");?></td>
438
						<td width="78%" class="vtable">
439
							<select name='mode' id='mode' class="formselect" onchange='mode_change()'>
440
							<?php
441
								foreach ($openvpn_client_modes as $name => $desc):
442
									$selected = "";
443
									if ($pconfig['mode'] == $name)
444
										$selected = "selected";
445
							?>
446
								<option value="<?=$name;?>" <?=$selected;?>><?=$desc;?></option>
447
							<?php endforeach; ?>
448
							</select>
449
						</td>
450
					</tr>
451 d799787e Matthew Grooms
					<tr>
452
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
453
							<td width="78%" class="vtable">
454
							<select name='protocol' class="formselect">
455
							<?php
456
								foreach ($openvpn_prots as $prot):
457
									$selected = "";
458
									if ($pconfig['protocol'] == $prot)
459
										$selected = "selected";
460
							?>
461
								<option value="<?=$prot;?>" <?=$selected;?>><?=$prot;?></option>
462
							<?php endforeach; ?>
463
							</select>
464
							</td>
465
					</tr>
466 691fbf14 Ermal Lu?i
                                        <tr>
467
                                                <td width="22%" valign="top" class="vncellreq"><?=gettext("Device mode");?></td>
468
                                                        <td width="78%" class="vtable">
469 4936ff53 jim-p
                                                        <select name='dev_mode' class="formselect">
470 691fbf14 Ermal Lu?i
                                                        <?php
471
                                                                foreach ($openvpn_dev_mode as $mode):
472
                                                                        $selected = "";
473 4936ff53 jim-p
                                                                        if ($pconfig['dev_mode'] == $mode)
474 691fbf14 Ermal Lu?i
                                                                                $selected = "selected";
475
                                                        ?>
476
                                                                <option value="<?=$mode;?>" <?=$selected;?>><?=$mode;?></option>
477
                                                        <?php endforeach; ?>
478
                                                        </select>
479
                                                        </td>
480
                                        </tr>
481 d799787e Matthew Grooms
					<tr>
482 2fa7a468 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
483 d799787e Matthew Grooms
						<td width="78%" class="vtable">
484
							<select name="interface" class="formselect">
485
								<?php
486
									$interfaces = get_configured_interface_with_descr();
487 3d06e8f0 pierrepomes
									$carplist = get_configured_carp_interface_list();
488
									foreach ($carplist as $cif => $carpip)
489 dd62256f Pierre POMES
										$interfaces[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")";
490 67b0902f pierrepomes
									$aliaslist = get_configured_ip_aliases_list();
491
									foreach ($aliaslist as $aliasip => $aliasif)
492 dd62256f Pierre POMES
										$interfaces[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
493 174ba22b smos
									$grouplist = return_gateway_groups_array();
494
									foreach ($grouplist as $name => $group) {
495
										if($group['ipprotocol'] != inet)
496
											continue;
497
										if($group[0]['vip'] <> "")
498
											$vipif = $group[0]['vip'];
499
										else
500
											$vipif = $group[0]['int'];
501
										$interfaces[$name] = "GW Group {$name}";
502
									}
503 5c94aa12 jim-p
									$interfaces['lo0'] = "Localhost";
504 67b0902f pierrepomes
									$interfaces['any'] = "any";
505 3d06e8f0 pierrepomes
									foreach ($interfaces as $iface => $ifacename):
506 1d3bcd2a Matthew Grooms
										$selected = "";
507
										if ($iface == $pconfig['interface'])
508
											$selected = "selected";
509 d799787e Matthew Grooms
								?>
510 1d3bcd2a Matthew Grooms
									<option value="<?=$iface;?>" <?=$selected;?>>
511
										<?=htmlspecialchars($ifacename);?>
512
									</option>
513 d799787e Matthew Grooms
								<?php endforeach; ?>
514
							</select> <br>
515
						</td>
516
					</tr>
517 1d3bcd2a Matthew Grooms
					<tr>
518
						<td width="22%" valign="top" class="vncell"><?=gettext("Local port");?></td>
519
						<td width="78%" class="vtable">
520
							<input name="local_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['local_port']);?>"/>
521 d799787e Matthew Grooms
							<br/>
522 5708241f jim-p
							<?=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."); ?>
523 1d3bcd2a Matthew Grooms
						</td>
524
					</tr>
525 d799787e Matthew Grooms
					<tr>
526
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server host or address");?></td>
527
						<td width="78%" class="vtable">
528
							<input name="server_addr" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['server_addr']);?>"/>
529
						</td>
530
					</tr>
531
					<tr>
532
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server port");?></td>
533
						<td width="78%" class="vtable">
534
							<input name="server_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['server_port']);?>"/>
535
						</td>
536
					</tr>
537
					<tr>
538
						<td width="22%" valign="top" class="vncell"><?=gettext("Proxy host or address");?></td>
539
						<td width="78%" class="vtable">
540
							<input name="proxy_addr" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['proxy_addr']);?>"/>
541
						</td>
542
					</tr>
543
					<tr>
544
						<td width="22%" valign="top" class="vncell"><?=gettext("Proxy port");?></td>
545
						<td width="78%" class="vtable">
546
							<input name="proxy_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['proxy_port']);?>"/>
547
						</td>
548
					</tr>
549 762a24a3 Ermal Lu?i
					<tr>
550
						<td width="22%" valign="top" class="vncell"><?=gettext("Proxy authentication extra options");?></td>
551
						<td width="78%" class="vtable">
552
							<table border="0" cellpadding="2" cellspacing="0">
553
								<tr>
554
                                                                        <td align="right" width="25%">
555
                                                                                <span class="vexpl">
556 2fa7a468 Carlos Eduardo Ramos
                                                                                         &nbsp;<?=gettext("Authentication method"); ?> :&nbsp;
557 762a24a3 Ermal Lu?i
                                                                                </span>
558
                                                                        </td>
559
                                                                        <td>
560
										<select name="proxy_authtype" id="proxy_authtype" class="formfld select" onChange="useproxy_changed()">
561 2fa7a468 Carlos Eduardo Ramos
											<option value="none" <?php if ($pconfig['proxy_authtype'] == "none") echo "selected"; ?>><?=gettext("none"); ?></option>
562
											<option value="basic" <?php if ($pconfig['proxy_authtype'] == "basic") echo "selected"; ?>><?=gettext("basic"); ?></option>
563
											<option value="ntlm" <?php if ($pconfig['proxy_authtype'] == "ntlm") echo "selected"; ?>><?=gettext("ntlm"); ?></option>
564 762a24a3 Ermal Lu?i
										</select>
565
									</td>
566
								</tr>
567
							</table>
568
							<br />
569
							 <table border="0" cellpadding="2" cellspacing="0" id="proxy_authtype_opts" style="display:none">
570
                                                                <tr>
571
                                                                        <td align="right" width="25%">
572
                                                                                <span class="vexpl">
573 2fa7a468 Carlos Eduardo Ramos
                                                                                         &nbsp;<?=gettext("Username"); ?> :&nbsp;
574 762a24a3 Ermal Lu?i
                                                                                </span>
575
                                                                        </td>
576
                                                                        <td>
577
                                                                                <input name="proxy_user" id="proxy_user" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['proxy_user']);?>" />
578
                                                                        </td>
579
                                                                </tr>
580
                                                                <tr>
581
                                                                        <td align="right" width="25%">
582
                                                                                <span class="vexpl">
583 2fa7a468 Carlos Eduardo Ramos
                                                                                         &nbsp;<?=gettext("Password"); ?> :&nbsp;
584 762a24a3 Ermal Lu?i
                                                                                </span>
585
                                                                        </td>
586
                                                                        <td>
587
                                                                                <input name="proxy_passwd" id="proxy_passwd" type="password" class="formfld pwd" size="20" value="<?=htmlspecialchars($pconfig['proxy_passwd']);?>" />
588
                                                                        </td>
589
                                                                </tr>
590
                                                        </table>
591
						</td>
592
					</tr>
593 d799787e Matthew Grooms
					<tr>
594 2fa7a468 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("Server host name resolution"); ?></td>
595 d799787e Matthew Grooms
						<td width="78%" class="vtable">
596
							<table border="0" cellpadding="2" cellspacing="0">
597
								<tr>
598
									<td>
599
										<?php set_checked($pconfig['resolve_retry'],$chk); ?>
600 db2872a2 Ermal Lu?i
										<input name="resolve_retry" type="checkbox" value="yes" <?=$chk;?>>
601 d799787e Matthew Grooms
									</td>
602
									<td>
603
										<span class="vexpl">
604 2fa7a468 Carlos Eduardo Ramos
											<?=gettext("Infinitely resolve server"); ?>
605 d799787e Matthew Grooms
										</span>
606
									</td>
607
								</tr>
608
							</table>
609 2fa7a468 Carlos Eduardo Ramos
							<?=gettext("Continuously attempt to resolve the server host " .
610
							"name. Useful when communicating with a server " .
611
							"that is not permanently connected to the Internet"); ?>.
612 d799787e Matthew Grooms
						</td>
613
					</tr>
614
					<tr> 
615 2fa7a468 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
616 d799787e Matthew Grooms
						<td width="78%" class="vtable"> 
617
							<input name="description" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['description']);?>">
618
							<br>
619 2fa7a468 Carlos Eduardo Ramos
							<?=gettext("You may enter a description here for your reference (not parsed)"); ?>.
620 d799787e Matthew Grooms
						</td>
621
					</tr>
622
					<tr>
623
						<td colspan="2" class="list" height="12"></td>
624
					</tr>
625
					<tr>
626 2fa7a468 Carlos Eduardo Ramos
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Cryptographic Settings"); ?></td>
627 d799787e Matthew Grooms
					</tr>
628 3c11bd3c Matthew Grooms
					<tr id="tls">
629 2fa7a468 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("TLS Authentication"); ?></td>
630 3c11bd3c Matthew Grooms
						<td width="78%" class="vtable">
631
							<table border="0" cellpadding="2" cellspacing="0">
632
								<tr>
633
									<td>
634
										<?php set_checked($pconfig['tlsauth_enable'],$chk); ?>
635
										<input name="tlsauth_enable" id="tlsauth_enable" type="checkbox" value="yes" <?=$chk;?> onClick="tlsauth_change()">
636
									</td>
637
									<td>
638
										<span class="vexpl">
639 2fa7a468 Carlos Eduardo Ramos
											<?=gettext("Enable authentication of TLS packets"); ?>.
640 3c11bd3c Matthew Grooms
										</span>
641
									</td>
642
								</tr>
643
							</table>
644
							<?php if (!$pconfig['tls']): ?>
645
							<table border="0" cellpadding="2" cellspacing="0" id='tlsauth_opts'>
646
								<tr>
647
									<td>
648
										<?php set_checked($pconfig['autotls_enable'],$chk); ?>
649
										<input name="autotls_enable" id="autotls_enable" type="checkbox" value="yes" <?=$chk;?> onClick="autotls_change()">
650
									</td>
651
									<td>
652
										<span class="vexpl">
653 2fa7a468 Carlos Eduardo Ramos
											<?=gettext("Automatically generate a shared TLS authentication key"); ?>.
654 3c11bd3c Matthew Grooms
										</span>
655
									</td>
656
								</tr>
657
							</table>
658
							<?php endif; ?>
659
							<table border="0" cellpadding="2" cellspacing="0" id='autotls_opts'>
660
								<tr>
661
									<td>
662
										<textarea name="tls" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['tls']);?></textarea>
663
										<br/>
664 2fa7a468 Carlos Eduardo Ramos
										<?=gettext("Paste your shared key here"); ?>.
665 3c11bd3c Matthew Grooms
									</td>
666
								</tr>
667
							</table>
668
						</td>
669 d799787e Matthew Grooms
					</tr>
670 3c11bd3c Matthew Grooms
					<tr id="tls_ca">
671 2fa7a468 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer Certificate Authority"); ?></td>
672 d799787e Matthew Grooms
							<td width="78%" class="vtable">
673 19cdeb3e jim-p
							<?php if (count($a_ca)): ?>
674 d799787e Matthew Grooms
							<select name='caref' class="formselect">
675
							<?php
676 428e66b6 jim-p
								foreach ($a_ca as $ca):
677 d799787e Matthew Grooms
									$selected = "";
678
									if ($pconfig['caref'] == $ca['refid'])
679
										$selected = "selected";
680
							?>
681 f2a86ca9 jim-p
								<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['descr'];?></option>
682 d799787e Matthew Grooms
							<?php endforeach; ?>
683
							</select>
684 19cdeb3e jim-p
							<?php else: ?>
685
								<b>No Certificate Authorities defined.</b> <br/>Create one under <a href="system_camanager.php">System &gt; Cert Manager</a>.
686
							<?php endif; ?>
687 d799787e Matthew Grooms
							</td>
688
					</tr>
689 3c11bd3c Matthew Grooms
					<tr id="tls_cert">
690 2fa7a468 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Client Certificate"); ?></td>
691 d799787e Matthew Grooms
							<td width="78%" class="vtable">
692 19cdeb3e jim-p
							<?php if (count($a_cert)): ?>
693 d799787e Matthew Grooms
							<select name='certref' class="formselect">
694
							<?php
695 428e66b6 jim-p
							foreach ($a_cert as $cert):
696 9e303f2f jim-p
								$selected = "";
697
								$caname = "";
698
								$inuse = "";
699
								$revoked = "";
700
								$ca = lookup_ca($cert['caref']);
701
								if ($ca)
702
									$caname = " (CA: {$ca['descr']})";
703
								if ($pconfig['certref'] == $cert['refid'])
704
									$selected = "selected";
705
								if (cert_in_use($cert['refid']))
706
									$inuse = " *In Use";
707
								if (is_cert_revoked($cert))
708
									$revoked = " *Revoked";
709 d799787e Matthew Grooms
							?>
710 6a0b3ea4 jim-p
								<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['descr'] . $caname . $inuse . $revoked;?></option>
711 d799787e Matthew Grooms
							<?php endforeach; ?>
712
							</select>
713 19cdeb3e jim-p
							<?php else: ?>
714
								<b>No Certificates defined.</b> <br/>Create one under <a href="system_certmanager.php">System &gt; Cert Manager</a>.
715
							<?php endif; ?>
716 d799787e Matthew Grooms
						</td>
717
					</tr>
718
					<tr id="psk">
719 2fa7a468 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Shared Key"); ?></td>
720 3c11bd3c Matthew Grooms
						<td width="78%" class="vtable">
721
							<?php if (!$pconfig['shared_key']): ?>
722
							<table border="0" cellpadding="2" cellspacing="0">
723
								<tr>
724
									<td>
725
										<?php set_checked($pconfig['autokey_enable'],$chk); ?>
726
										<input name="autokey_enable" type="checkbox" value="yes" <?=$chk;?> onClick="autokey_change()">
727
									</td>
728
									<td>
729
										<span class="vexpl">
730 2fa7a468 Carlos Eduardo Ramos
											<?=gettext("Automatically generate a shared key"); ?>.
731 3c11bd3c Matthew Grooms
										</span>
732
									</td>
733
								</tr>
734
							</table>
735
							<?php endif; ?>
736
							<table border="0" cellpadding="2" cellspacing="0" id='autokey_opts'>
737
								<tr>
738
									<td>
739
										<textarea name="shared_key" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['shared_key']);?></textarea>
740
										<br/>
741 2fa7a468 Carlos Eduardo Ramos
										<?=gettext("Paste your shared key here"); ?>.
742 3c11bd3c Matthew Grooms
									</td>
743
								</tr>
744
							</table>
745 d799787e Matthew Grooms
						</td>
746
					</tr>
747
					<tr>
748 2fa7a468 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Encryption algorithm"); ?></td>
749 d799787e Matthew Grooms
						<td width="78%" class="vtable">
750
							<select name="crypto" class="formselect">
751
								<?php
752
									$cipherlist = openvpn_get_cipherlist();
753
									foreach ($cipherlist as $name => $desc):
754
									$selected = '';
755
									if ($name == $pconfig['crypto'])
756
										$selected = ' selected';
757
								?>
758
								<option value="<?=$name;?>"<?=$selected?>>
759
									<?=htmlspecialchars($desc);?>
760
								</option>
761
								<?php endforeach; ?>
762
							</select>
763
						</td>
764
					</tr>
765 582c58ae jim-p
					<tr id="engine">
766
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Hardware Crypto"); ?></td>
767
						<td width="78%" class="vtable">
768
							<select name="engine" class="formselect">
769
								<?php
770
									$engines = openvpn_get_engines();
771
									foreach ($engines as $name => $desc):
772
									$selected = '';
773
									if ($name == $pconfig['engine'])
774
										$selected = ' selected';
775
								?>
776
								<option value="<?=$name;?>"<?=$selected?>>
777
									<?=htmlspecialchars($desc);?>
778
								</option>
779
								<?php endforeach; ?>
780
							</select>
781
						</td>
782
					</tr>
783 d799787e Matthew Grooms
					<tr>
784
						<td colspan="2" class="list" height="12"></td>
785
					</tr>
786
					<tr>
787 2fa7a468 Carlos Eduardo Ramos
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Tunnel Settings"); ?></td>
788 d799787e Matthew Grooms
					</tr>
789
					<tr>
790 4856df9b jim-p
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Tunnel Network"); ?></td>
791 d799787e Matthew Grooms
						<td width="78%" class="vtable">
792
							<input name="tunnel_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_network']);?>">
793
							<br>
794 2fa7a468 Carlos Eduardo Ramos
							<?=gettext("This is the virtual network used for private " .
795
							"communications between this client and the " .
796
							"server expressed using CIDR (eg. 10.0.8.0/24). " .
797
							"The first network address is assumed to be the " .
798
							"server address and the second network address " .
799
							"will be assigned to the client virtual " .
800
							"interface"); ?>.
801 d799787e Matthew Grooms
						</td>
802
					</tr>
803
					<tr>
804 4856df9b jim-p
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Tunnel Network"); ?></td>
805
						<td width="78%" class="vtable">
806
							<input name="tunnel_networkv6" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_networkv6']);?>">
807
							<br>
808
							<?=gettext("This is the IPv6 virtual network used for private " .
809
							"communications between this client and the " .
810
							"server expressed using CIDR (eg. fe80::/64). " .
811
							"The first network address is assumed to be the " .
812
							"server address and the second network address " .
813
							"will be assigned to the client virtual " .
814
							"interface"); ?>.
815
						</td>
816
					</tr>
817
					<tr>
818 3835613a Phil Davis
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Remote Network/s"); ?></td>
819 d799787e Matthew Grooms
						<td width="78%" class="vtable">
820 3835613a Phil Davis
							<input name="remote_network" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['remote_network']);?>">
821 d799787e Matthew Grooms
							<br>
822 3835613a Phil Davis
							<?=gettext("These are the IPv4 networks that will be routed through " .
823 2fa7a468 Carlos Eduardo Ramos
							"the tunnel, so that a site-to-site VPN can be " .
824 3835613a Phil Davis
							"established without manually changing the routing tables. " .
825
							"Expressed as a comma-separated list of one or more CIDR ranges. " .
826
							"If this is a site-to-site VPN, enter the " .
827
							"remote LAN/s here. You may leave this blank to " .
828 2fa7a468 Carlos Eduardo Ramos
							"only communicate with other clients"); ?>.
829 d799787e Matthew Grooms
						</td>
830
					</tr>
831 4856df9b jim-p
					<tr>
832 3835613a Phil Davis
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Remote Network/s"); ?></td>
833 4856df9b jim-p
						<td width="78%" class="vtable">
834 3835613a Phil Davis
							<input name="remote_networkv6" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['remote_networkv6']);?>">
835 4856df9b jim-p
							<br>
836 3835613a Phil Davis
							<?=gettext("These are the IPv6 networks that will be routed through " .
837 4856df9b jim-p
							"the tunnel, so that a site-to-site VPN can be " .
838 3835613a Phil Davis
							"established without manually changing the routing tables. " .
839
							"Expressed as a comma-separated list of one or more IP/PREFIX. " .
840
							"If this is a site-to-site VPN, enter the " .
841
							"remote LAN/s here. You may leave this blank to " .
842 4856df9b jim-p
							"only communicate with other clients"); ?>.
843
						</td>
844
					</tr>
845 d799787e Matthew Grooms
					<tr>
846
						<td width="22%" valign="top" class="vncell"><?=gettext("Limit outgoing bandwidth");?></td>
847
						<td width="78%" class="vtable">
848
							<input name="use_shaper" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['use_shaper']);?>"/>
849
							<br/>
850 2fa7a468 Carlos Eduardo Ramos
							<?=gettext("Maximum outgoing bandwidth for this tunnel. " .
851
							"Leave empty for no limit. The input value has " .
852
							"to be something between 100 bytes/sec and 100 " .
853
							"Mbytes/sec (entered as bytes per second)"); ?>.
854 d799787e Matthew Grooms
						</td>
855
					</tr>
856
					<tr>
857 2fa7a468 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("Compression"); ?></td>
858 d799787e Matthew Grooms
						<td width="78%" class="vtable">
859
							<table border="0" cellpadding="2" cellspacing="0">
860
								<tr>
861
									<td>
862
										<?php set_checked($pconfig['compression'],$chk); ?>
863
										<input name="compression" type="checkbox" value="yes" <?=$chk;?>>
864
									</td>
865
									<td>
866
										<span class="vexpl">
867 2fa7a468 Carlos Eduardo Ramos
											<?=gettext("Compress tunnel packets using the LZO algorithm"); ?>.
868 d799787e Matthew Grooms
										</span>
869
									</td>
870
								</tr>
871
							</table>
872
						</td>
873
					</tr>
874
					<tr>
875 2fa7a468 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("Type-of-Service"); ?></td>
876 d799787e Matthew Grooms
						<td width="78%" class="vtable">
877
							<table border="0" cellpadding="2" cellspacing="0">
878
								<tr>
879
									<td>
880 1cb0b40a Matthew Grooms
										<?php set_checked($pconfig['passtos'],$chk); ?>
881
										<input name="passtos" type="checkbox" value="yes" <?=$chk;?>>
882 d799787e Matthew Grooms
									</td>
883
									<td>
884
										<span class="vexpl">
885 2fa7a468 Carlos Eduardo Ramos
											<?=gettext("Set the TOS IP header value of tunnel packets to match the encapsulated packet value"); ?>.
886 d799787e Matthew Grooms
										</span>
887
									</td>
888
								</tr>
889
							</table>
890
						</td>
891
					</tr>
892 4856df9b jim-p
				</table>
893
894
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
895 c7323d81 sullrich
					<tr>
896
						<td colspan="2" class="list" height="12"></td>
897
					</tr>
898
					<tr>
899 2fa7a468 Carlos Eduardo Ramos
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
900 c7323d81 sullrich
					</tr>
901
					<tr>
902 2fa7a468 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
903 c7323d81 sullrich
						<td width="78%" class="vtable">
904
							<table border="0" cellpadding="2" cellspacing="0">
905
								<tr>
906
									<td>
907 dd5bf424 Scott Ullrich
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=htmlspecialchars($pconfig['custom_options']);?></textarea><br/>
908 2fa7a468 Carlos Eduardo Ramos
										<?=gettext("Enter any additional options you would like to add to the OpenVPN client configuration here, separated by a semicolon"); ?><br/>
909 3835613a Phil Davis
										<?=gettext("EXAMPLE:"); ?> <strong>remote server.mysite.com 1194;</strong> or <strong>remote 1.2.3.4 1194;</strong>
910 c7323d81 sullrich
									</td>
911
								</tr>
912
							</table>
913
						</td>
914 4856df9b jim-p
					</tr>
915
				</table>
916
917
				<br/>
918
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
919 d799787e Matthew Grooms
					<tr>
920
						<td width="22%" valign="top">&nbsp;</td>
921
						<td width="78%"> 
922 2fa7a468 Carlos Eduardo Ramos
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>"> 
923 d799787e Matthew Grooms
							<input name="act" type="hidden" value="<?=$act;?>">
924
							<?php if (isset($id) && $a_client[$id]): ?>
925
							<input name="id" type="hidden" value="<?=$id;?>">
926
							<?php endif; ?>
927
						</td>
928
					</tr>
929
				</table>
930
			</form>
931
932
			<?php else: ?>
933
934 79633b6c Evgeny Yurchenko
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
935 7773b868 jim-p
				<thead>
936 d799787e Matthew Grooms
				<tr>
937 2fa7a468 Carlos Eduardo Ramos
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
938
					<td width="10%" class="listhdrr"><?=gettext("Protocol"); ?></td>
939
					<td width="30%" class="listhdrr"><?=gettext("Server"); ?></td>
940
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
941 d799787e Matthew Grooms
					<td width="10%" class="list"></td>
942
				</tr>
943 7773b868 jim-p
				</thead>
944
				<tbody>
945 d799787e Matthew Grooms
				<?php
946
					$i = 0;
947
					foreach($a_client as $client):
948
						$disabled = "NO";
949 8319ee63 jim-p
						if (isset($client['disable']))
950 d799787e Matthew Grooms
							$disabled = "YES";
951
						$server = "{$client['server_addr']}:{$client['server_port']}";
952
				?>
953 c67bbe04 Chris Buechler
				<tr ondblclick="document.location='vpn_openvpn_client.php?act=edit&id=<?=$i;?>'">
954 d799787e Matthew Grooms
					<td class="listlr">
955
						<?=$disabled;?>
956
					</td>
957
					<td class="listr">
958
						<?=htmlspecialchars($client['protocol']);?>
959
					</td>
960
					<td class="listr">
961
						<?=htmlspecialchars($server);?>
962
					</td>
963 296a3cb6 Scott Ullrich
					<td class="listbg">
964 d799787e Matthew Grooms
						<?=htmlspecialchars($client['description']);?>
965
					</td>
966
					<td valign="middle" nowrap class="list">
967
						<a href="vpn_openvpn_client.php?act=edit&id=<?=$i;?>">
968 2fa7a468 Carlos Eduardo Ramos
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit client"); ?>" width="17" height="17" border="0">
969 d799787e Matthew Grooms
						</a>
970
						&nbsp;
971 2fa7a468 Carlos Eduardo Ramos
						<a href="vpn_openvpn_client.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this client?"); ?>')">
972
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete client"); ?>" width="17" height="17" border="0">
973 d799787e Matthew Grooms
						</a>
974
					</td>
975
				</tr>
976
				<?php
977
					$i++;
978
					endforeach;
979
				?>
980 7773b868 jim-p
				</tbody>
981
				<tfoot>
982 d799787e Matthew Grooms
				<tr>
983
					<td class="list" colspan="4"></td>
984
					<td class="list">
985 2fa7a468 Carlos Eduardo Ramos
						<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">
986 d799787e Matthew Grooms
						</a>
987
					</td>
988
				</tr>
989
				<tr>
990
					<td colspan="4">
991
						<p>
992
							<?=gettext("Additional OpenVPN clients can be added here.");?>
993
						</p>
994
					</td>
995
				</tr>
996 7773b868 jim-p
				</tfoot>
997 d799787e Matthew Grooms
			</table>
998
999 ee9933b6 Renato Botelho
			<?php endif; ?>
1000 d799787e Matthew Grooms
1001
		</td>
1002
	</tr>
1003
</table>
1004
<script language="JavaScript">
1005
<!--
1006 3c11bd3c Matthew Grooms
mode_change();
1007
autokey_change();
1008
tlsauth_change();
1009 762a24a3 Ermal Lu?i
useproxy_changed();
1010 d799787e Matthew Grooms
//-->
1011
</script>
1012
</body>
1013
<?php include("fend.inc"); ?>
1014
1015
<?php
1016
1017
/* local utility functions */
1018
1019
function set_checked($var,& $chk) {
1020
    if($var)
1021
        $chk = 'checked';
1022
    else
1023
        $chk = '';
1024
}
1025
1026 174ba22b smos
?>