vpn_openvpn_client.php 46.9 KB
Newer Older
Ad Schellevis's avatar
Ad Schellevis committed
1
<?php
2

Ad Schellevis's avatar
Ad Schellevis committed
3
/*
4
	Copyright (C) 2014-2015 Deciso B.V.
Ad Schellevis's avatar
Ad Schellevis committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
	Copyright (C) 2008 Shrew Soft Inc.
	All rights reserved.

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

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

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

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

30
require_once("guiconfig.inc");
Ad Schellevis's avatar
Ad Schellevis committed
31
require_once("openvpn.inc");
32
require_once("services.inc");
33
require_once("interfaces.inc");
Ad Schellevis's avatar
Ad Schellevis committed
34

35

Ad Schellevis's avatar
Ad Schellevis committed
36 37 38
$pgtitle = array(gettext("OpenVPN"), gettext("Client"));
$shortcut_section = "openvpn";

39
if (!isset($config['openvpn']['openvpn-client'])) {
40 41
    $config['openvpn']['openvpn-client'] = array();
}
Ad Schellevis's avatar
Ad Schellevis committed
42 43 44

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

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
$vpnid = 0;
$act = null;
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
		if (isset($_GET['id']) && is_numericint($_GET['id'])) {
		    $id = $_GET['id'];
		}
		if (isset($_GET['act'])) {
		    $act = $_GET['act'];
		}

		$pconfig = array();
		// set defaults
		$pconfig['autokey_enable'] = "yes"; // just in case the modes switch
		$pconfig['autotls_enable'] = "yes"; // just in case the modes switch
		$pconfig['tlsauth_enable'] = "yes";
		$pconfig['digest'] = "SHA1";
		$pconfig['verbosity_level'] = 1; // Default verbosity is 1

		// edit existing.
		if ($act=="edit" && isset($id) && $a_client[$id] ) {
				// 1 on 1 copy of config attributes
				$copy_fields = "auth_user,auth_pass,disable,mode,protocol,interface
				,local_port,server_addr,server_port,resolve_retry
				,proxy_addr,proxy_port,proxy_user,proxy_passwd,proxy_authtype,description
				,custom_options,ns_cert_type,dev_mode,caref,certref,crypto,digest,engine
				,tunnel_network,tunnel_networkv6,remote_network,remote_networkv6,use_shaper
				,compression,passtos,no_tun_ipv6,route_no_pull,route_no_exec,verbosity_level";

				foreach (explode(",",$copy_fields) as $fieldname) {
					$fieldname = trim($fieldname);
					if(isset($a_client[$id][$fieldname])) {
						$pconfig[$fieldname] = $a_client[$id][$fieldname];
					} elseif (!isset($pconfig[$fieldname])) {
						// initialize element
						$pconfig[$fieldname] = null;
					}
				}

				// load / convert
				if (!empty($a_client[$id]['ipaddr'])) {
85 86 87
            $pconfig['interface'] = $pconfig['interface'] . '|' . $a_client[$id]['ipaddr'];
        }

88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
        if (isset($a_client[$id]['tls'])) {
            $pconfig['tls'] = base64_decode($a_client[$id]['tls']);
        } else  {
						$pconfig['tls'] = null;
				}

				if (isset($a_client[$id]['shared_key'])) {
						$pconfig['shared_key'] = base64_decode($a_client[$id]['shared_key']);
				} else {
						$pconfig['shared_key'] = null ;
				}

				if (isset($id) && $a_client[$id]) {
				    $vpnid = $a_client[$id]['vpnid'];
				}
		} elseif ($act=="new") {
				// create new
		    $pconfig['interface'] = "wan";
		    $pconfig['server_port'] = 1194;
				$init_fields = "auth_user,auth_pass,disable,mode,protocol,interface
				,local_port,server_addr,server_port,resolve_retry
				,proxy_addr,proxy_port,proxy_user,proxy_passwd,proxy_authtype,description
				,custom_options,ns_cert_type,dev_mode,caref,certref,crypto,digest,engine
				,tunnel_network,tunnel_networkv6,remote_network,remote_networkv6,use_shaper
				,compression,passtos,no_tun_ipv6,route_no_pull,route_no_exec,verbosity_level";

				foreach (explode(",",$init_fields) as $fieldname) {
					$fieldname = trim($fieldname);
					if (!isset($pconfig[$fieldname])) {
						$pconfig[$fieldname] = null;
					}
				}
		}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
	if (isset($_POST['id']) && is_numericint($_POST['id'])) {
			$id = $_POST['id'];
	}
	if (isset($_POST['act'])) {
			$act = $_POST['act'];
	}
128

129
	if ($act == "del") {
130
			// remove client
131 132 133 134 135 136 137 138 139 140
			if (!isset($id) || !isset($a_client[$id])) {
					redirectHeader("vpn_openvpn_client.php");
					exit;
			}
			if (!empty($a_client[$id])) {
					openvpn_delete('client', $a_client[$id]);
			}
			unset($a_client[$id]);
			write_config();
	} else {
141
			// update client (after validation)
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
			$pconfig = $_POST;
			$input_errors = array();

	    if (isset($id) && $a_client[$id]) {
	        $vpnid = $a_client[$id]['vpnid'];
	    }
			if (isset($pconfig['mode']) && $pconfig['mode'] != "p2p_shared_key") {
	        $tls_mode = true;
	    } else {
	        $tls_mode = false;
	    }

			// generate new key
			if (!empty($pconfig['autokey_enable'])) {
	        $pconfig['shared_key'] = openvpn_create_key();
	    }

	    /* input validation */
			if (strpos($pconfig['interface'],'|') !== false) {
					list($iv_iface, $iv_ip) = explode("|", $pconfig['interface']);
			} else {
					$iv_iface = $pconfig['interface'];
					$iv_ip = null;
			}

	    if (is_ipaddrv4($iv_ip) && (stristr($pconfig['protocol'], "6") !== false)) {
	        $input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv6 protocol and an IPv4 IP address.");
	    } elseif (is_ipaddrv6($iv_ip) && (stristr($pconfig['protocol'], "6") === false)) {
	        $input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv4 protocol and an IPv6 IP address.");
	    } elseif ((stristr($pconfig['protocol'], "6") === false) && !get_interface_ip($iv_iface) && ($pconfig['interface'] != "any")) {
	        $input_errors[] = gettext("An IPv4 protocol was selected, but the selected interface has no IPv4 address.");
	    } elseif ((stristr($pconfig['protocol'], "6") !== false) && !get_interface_ipv6($iv_iface) && ($pconfig['interface'] != "any")) {
	        $input_errors[] = gettext("An IPv6 protocol was selected, but the selected interface has no IPv6 address.");
	    }
	    if (!empty($pconfig['local_port'])) {
					if (empty($pconfig['local_port']) || !is_numeric($pconfig['local_port']) || $pconfig['local_port'] < 0 || ($pconfig['local_port'] > 65535)) {
							$input_errors[] = "The field Local port must contain a valid port, ranging from 0 to 65535.";
					}
	        $portused = openvpn_port_used($pconfig['protocol'], $pconfig['interface'], $pconfig['local_port'], $vpnid);
	        if (($portused != $vpnid) && ($portused != 0)) {
	            $input_errors[] = gettext("The specified 'Local port' is in use. Please select another value");
	        }
	    }
			if (empty($pconfig['server_addr']) || (!is_domain($pconfig['server_addr']) && !is_ipaddr($pconfig['server_addr']))) {
					$input_errors[] = gettext("The field Server host or address must contain a valid IP address or domain name.") ;
			}

			if (empty($pconfig['server_port']) || !is_numeric($pconfig['server_port']) || $pconfig['server_port'] < 0 || ($pconfig['server_port'] > 65535)) {
					$input_errors[] = "The field Server port must contain a valid port, ranging from 0 to 65535.";
			}

	    if (!empty($pconfig['proxy_addr'])) {
					if (empty($pconfig['proxy_addr']) || (!is_domain($pconfig['proxy_addr']) && !is_ipaddr($pconfig['proxy_addr']))) {
							$input_errors[] = gettext("The field Proxy host or address must contain a valid IP address or domain name.") ;
					}
					if (empty($pconfig['proxy_port']) || !is_numeric($pconfig['proxy_port']) || $pconfig['proxy_port'] < 0 || ($pconfig['proxy_port'] > 65535)) {
							$input_errors[] = "The field Proxy port must contain a valid port, ranging from 0 to 65535.";
					}
	        if (isset($pconfig['proxy_authtype']) && $pconfig['proxy_authtype'] != "none") {
	            if (empty($pconfig['proxy_user']) || empty($pconfig['proxy_passwd'])) {
	                $input_errors[] = gettext("User name and password are required for proxy with authentication.");
	            }
	        }
	    }
	    if (!empty($pconfig['tunnel_network'])) {
	        if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'IPv4 Tunnel Network', false, "ipv4")) {
	            $input_errors[] = $result;
	        }
	    }
	    if (!empty($pconfig['tunnel_networkv6'])) {
	        if ($result = openvpn_validate_cidr($pconfig['tunnel_networkv6'], 'IPv6 Tunnel Network', false, "ipv6")) {
	            $input_errors[] = $result;
	        }
	    }
	    if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'IPv4 Remote Network', true, "ipv4")) {
	        $input_errors[] = $result;
	    }
	    if ($result = openvpn_validate_cidr($pconfig['remote_networkv6'], 'IPv6 Remote Network', true, "ipv6")) {
	        $input_errors[] = $result;
	    }
	    if (!empty($pconfig['use_shaper']) && (!is_numeric($pconfig['use_shaper']) || ($pconfig['use_shaper'] <= 0))) {
	        $input_errors[] = gettext("The bandwidth limit must be a positive numeric value.");
	    }
	    if (!$tls_mode && empty($pconfig['autokey_enable'])) {
	        if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
	            !strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----")) {
	            $input_errors[] = gettext("The field 'Shared Key' does not appear to be valid");
	        }
	    }
	    if ($tls_mode && !empty($pconfig['tlsauth_enable']) && empty($pconfig['autotls_enable'])) {
	        if (!strstr($pconfig['tls'], "-----BEGIN OpenVPN Static key V1-----") ||
	            !strstr($pconfig['tls'], "-----END OpenVPN Static key V1-----")) {
	            $input_errors[] = gettext("The field 'TLS Authentication Key' does not appear to be valid");
	        }
	    }

	    /* If we are not in shared key mode, then we need the CA/Cert. */
	    if (isset($pconfig['mode']) && $pconfig['mode'] != "p2p_shared_key") {
	        $reqdfields = explode(" ", "caref");
	        $reqdfieldsn = array(gettext("Certificate Authority"));
	    } elseif (empty($pconfig['autokey_enable'])) {
	        /* We only need the shared key filled in if we are in shared key mode and autokey is not selected. */
	        $reqdfields = array('shared_key');
	        $reqdfieldsn = array(gettext('Shared key'));
	    }

			do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);

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

	    if (count($input_errors) == 0) {
					// save data
	        $client = array();
					// 1 on 1 copy of config attributes
					$copy_fields = "auth_user,auth_pass,protocol,dev_mode,local_port
					,server_addr,server_port,resolve_retry,proxy_addr,proxy_port
					,proxy_authtype,proxy_user,proxy_passwd,description,mode,crypto,digest
					,engine,tunnel_network,tunnel_networkv6,remote_network,remote_networkv6
					,use_shaper,compression,passtos,no_tun_ipv6,route_no_pull,route_no_exec
					,verbosity_level,interface";

					foreach (explode(",",$copy_fields) as $fieldname) {
						$fieldname = trim($fieldname);
267
						if(!empty($pconfig[$fieldname])) {
268 269 270 271 272 273 274 275 276 277
							$client[$fieldname] = $pconfig[$fieldname];
						}
					}

					// attributes containing some kind of logic
	        if ($vpnid) {
	            $client['vpnid'] = $vpnid;
	        } else {
	            $client['vpnid'] = openvpn_vpnid_next();
	        }
278
	        if (isset($pconfig['disable']) && $pconfig['disable'] == "yes") {
279 280 281 282 283 284 285 286 287 288 289
	            $client['disable'] = true;
	        }

					if (strpos($pconfig['interface'], "|") !== false) {
							list($client['interface'], $client['ipaddr']) = explode("|", $pconfig['interface']);
					}
	        $client['custom_options'] = str_replace("\r\n", "\n", $pconfig['custom_options']);

	        if ($tls_mode) {
	            $client['caref'] = $pconfig['caref'];
	            $client['certref'] = $pconfig['certref'];
290 291
	            if (!empty($pconfig['tlsauth_enable'])) {
	                if (!empty($pconfig['autotls_enable'])) {
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
	                    $pconfig['tls'] = openvpn_create_key();
	                }
	                $client['tls'] = base64_encode($pconfig['tls']);
	            }
	        } else {
	            $client['shared_key'] = base64_encode($pconfig['shared_key']);
	        }

	        if (isset($id) && isset($a_client[$id])) {
	            $a_client[$id] = $client;
	        } else {
	            $a_client[] = $client;
	        }

	        openvpn_resync('client', $client);
	        write_config();

	        header("Location: vpn_openvpn_client.php");
	        exit;
	    }
		}
Ad Schellevis's avatar
Ad Schellevis committed
313 314
}

315 316 317
// escape form output before processing
legacy_html_escape_form_data($pconfig);

Ad Schellevis's avatar
Ad Schellevis committed
318 319
include("head.inc");

320
$main_buttons = array(
321
    array('href'=>'vpn_openvpn_client.php?act=new', 'label'=>gettext("add client")),
322 323
);

Ad Schellevis's avatar
Ad Schellevis committed
324 325
?>

326
<body>
Ad Schellevis's avatar
Ad Schellevis committed
327 328 329
<?php include("fbegin.inc"); ?>
<script type="text/javascript">
//<![CDATA[
330
$( document ).ready(function() {
331
	// init form (old stuff)
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
	if (document.iform != undefined) {
		mode_change();
		autokey_change();
		tlsauth_change();
		useproxy_changed();
	}

	// link delete buttons
	$(".act_delete").click(function(){
		var id = $(this).attr("id").split('_').pop(-1);
		BootstrapDialog.show({
				type:BootstrapDialog.TYPE_INFO,
				title: "<?= gettext("OpenVPN");?>",
				message: "<?= gettext("Do you really want to delete this client?"); ?>",
				buttons: [{
								label: "<?= gettext("No");?>",
								action: function(dialogRef) {
										dialogRef.close();
								}}, {
									label: "<?= gettext("Yes");?>",
									action: function(dialogRef) {
										$.post(window.location, {act: 'del', id:id}, function(data) {
													location.reload();
										});
										dialogRef.close();
								}
						}]
		});
	});
});

Ad Schellevis's avatar
Ad Schellevis committed
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396

function mode_change() {
	index = document.iform.mode.selectedIndex;
	value = document.iform.mode.options[index].value;
	switch(value) {
		case "p2p_tls":
			document.getElementById("tls").style.display="";
			document.getElementById("tls_ca").style.display="";
			document.getElementById("tls_cert").style.display="";
			document.getElementById("psk").style.display="none";
			break;
		case "p2p_shared_key":
			document.getElementById("tls").style.display="none";
			document.getElementById("tls_ca").style.display="none";
			document.getElementById("tls_cert").style.display="none";
			document.getElementById("psk").style.display="";
			break;
	}
}

function dev_mode_change() {
	index = document.iform.dev_mode.selectedIndex;
	value = document.iform.dev_mode.options[index].value;
	switch(value) {
		case "tun":
			document.getElementById("chkboxNoTunIPv6").style.display="";
			break;
		case "tap":
			document.getElementById("chkboxNoTunIPv6").style.display="none";
			break;
	}
}

function autokey_change() {
397
	if (document.iform.autokey_enable != undefined && document.iform.autokey_enable.checked)
Ad Schellevis's avatar
Ad Schellevis committed
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
		document.getElementById("autokey_opts").style.display="none";
	else
		document.getElementById("autokey_opts").style.display="";
}

function useproxy_changed() {

	if (jQuery('#proxy_authtype').val() != 'none') {
		jQuery('#proxy_authtype_opts').show();
	} else {
		jQuery('#proxy_authtype_opts').hide();
	}
}

function tlsauth_change() {

414
<?php if (empty($pconfig['tls'])) :
415
?>
Ad Schellevis's avatar
Ad Schellevis committed
416 417 418 419
	if (document.iform.tlsauth_enable.checked)
		document.getElementById("tlsauth_opts").style.display="";
	else
		document.getElementById("tlsauth_opts").style.display="none";
420 421
<?php
endif; ?>
Ad Schellevis's avatar
Ad Schellevis committed
422 423 424 425 426 427

	autotls_change();
}

function autotls_change() {

428
<?php if (empty($pconfig['tls'])) :
429
?>
Ad Schellevis's avatar
Ad Schellevis committed
430
	autocheck = document.iform.autotls_enable.checked;
431 432 433
<?php
else :
?>
Ad Schellevis's avatar
Ad Schellevis committed
434
	autocheck = false;
435 436
<?php
endif; ?>
Ad Schellevis's avatar
Ad Schellevis committed
437 438 439 440 441 442 443 444 445

	if (document.iform.tlsauth_enable.checked && !autocheck)
		document.getElementById("autotls_opts").style.display="";
	else
		document.getElementById("autotls_opts").style.display="none";
}

//]]>
</script>
446
	<section class="page-content-main">
447
		<div class="container-fluid">
448
			<div class="row">
449

450
<?php
451
                if (isset($input_errors) && count($input_errors) > 0) {
452 453
                    print_input_errors($input_errors);
                }
454
                if (isset($savemsg)) {
455 456
                    print_info_box($savemsg);
                }
457
?>
458 459


460
			    <section class="col-xs-12">
461
<?php
462 463 464 465
                        $tab_array = array();
                        $tab_array[] = array(gettext("Server"), false, "vpn_openvpn_server.php");
                        $tab_array[] = array(gettext("Client"), true, "vpn_openvpn_client.php");
                        $tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
466 467
                        $tab_array[] = array(gettext("Client Export"), false, "vpn_openvpn_export.php");
                        $tab_array[] = array(gettext("Shared Key Export"), false, "vpn_openvpn_export_shared.php");
468
                        display_top_tabs($tab_array);
469
?>
470 471

					<div class="tab-content content-box col-xs-12">
472 473
							<?php if ($act=="new" || $act=="edit") :
?>
474 475
							<form action="vpn_openvpn_client.php" method="post" name="iform" id="iform">
							<div class="table-responsive">
476
							<table class="table table-striped">
477
								<tr>
478 479 480
									<td width="22%"><?=gettext("General information"); ?></td>
									<td width="78%" align="right">
										<small><?=gettext("full help"); ?> </small>
481
										<i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_page" type="button"></i></a>
482
									</td>
483
								</tr>
Ad Schellevis's avatar
Ad Schellevis committed
484
								<tr>
485 486
									<td><a id="help_for_disable" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a><?=gettext("Disabled"); ?></td>
									<td>
487 488 489 490
										<input name="disable" type="checkbox" value="yes" <?= !empty($pconfig['disable']) ? "checked=\"checked\"" : "";?> />
										<div class="hidden" for="help_for_disable">
											<small><?=gettext("Set this option to disable this client without removing it from the list"); ?>.</small>
										</div>
Ad Schellevis's avatar
Ad Schellevis committed
491 492
									</td>
								</tr>
493
								<tr>
494 495
									<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Server Mode");?></td>
									<td>
496 497 498 499 500
										<select name="mode" id="mode" class="form-control" onchange="mode_change()">
<?php
														$openvpn_client_modes = array(
															'p2p_tls' => gettext("Peer to Peer ( SSL/TLS )"),
															'p2p_shared_key' => gettext("Peer to Peer ( Shared Key )") );
501 502 503 504 505
                            foreach ($openvpn_client_modes as $name => $desc) :
                                $selected = "";
                                if ($pconfig['mode'] == $name) {
                                    $selected = "selected=\"selected\"";
                                }
506 507 508
?>
                            <option value="<?=$name;?>" <?=$selected;?>><?=$desc;?></option>
<?php
509
                            endforeach; ?>
510 511 512 513
										</select>
									</td>
								</tr>
								<tr>
514 515
									<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Protocol");?></td>
									<td>
516 517 518
										<select name='protocol' class="form-control">
<?php
                            foreach (array("UDP", "UDP6", "TCP", "TCP6") as $prot) :
519 520 521 522
                                $selected = "";
                                if ($pconfig['protocol'] == $prot) {
                                    $selected = "selected=\"selected\"";
                                }
523 524
?>
                            <option value="<?=$prot;?>" <?=$selected;?>><?=$prot;?></option>
525
<?php
526
                            endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
527 528 529 530
							</select>
							</td>
					</tr>
					<tr>
531 532
						<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Device mode");?></td>
							<td>
533
							<select name='dev_mode' class="form-control" onchange="dev_mode_change()">
Ad Schellevis's avatar
Ad Schellevis committed
534
							<?php
535
                            foreach (array("tun", "tap") as $mode) :
536 537 538 539
                                $selected = "";
                                if ($pconfig['dev_mode'] == $mode) {
                                    $selected = "selected=\"selected\"";
                                }
540 541 542
?>
                            <option value="<?=$mode;?>" <?=$selected;?>><?=$mode;?></option>
<?php
543
                            endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
544 545 546 547
							</select>
							</td>
					</tr>
					<tr>
548 549
						<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Interface"); ?></td>
						<td>
550
							<select name="interface" class="form-control">
551
<?php
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580
                                    $interfaces = get_configured_interface_with_descr();
                                    $carplist = get_configured_carp_interface_list();
                                foreach ($carplist as $cif => $carpip) {
                                    $interfaces[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")";
                                }
                                    $aliaslist = get_configured_ip_aliases_list();
                                foreach ($aliaslist as $aliasip => $aliasif) {
                                    $interfaces[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
                                }
                                    $grouplist = return_gateway_groups_array();
                                foreach ($grouplist as $name => $group) {
                                    if ($group['ipprotocol'] != inet) {
                                        continue;
                                    }
                                    if ($group[0]['vip'] <> "") {
                                        $vipif = $group[0]['vip'];
                                    } else {
                                        $vipif = $group[0]['int'];
                                    }
                                    $interfaces[$name] = "GW Group {$name}";
                                }
                                    $interfaces['lo0'] = "Localhost";
                                    $interfaces['any'] = "any";
                                foreach ($interfaces as $iface => $ifacename) :
                                    $selected = "";
                                    if ($iface == $pconfig['interface']) {
                                        $selected = "selected=\"selected\"";
                                    }
                                ?>
581 582
                                <option value="<?=$iface;?>" <?=$selected;?>><?=htmlspecialchars($ifacename);?></option>
<?php
583
                                endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
584 585 586 587
							</select> <br />
						</td>
					</tr>
					<tr>
588
						<td><a id="help_for_local_port" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Local port");?></td>
589 590 591 592 593
						<td>
							<input name="local_port" type="text" class="form-control unknown" size="5" value="<?=$pconfig['local_port'];?>" />
							<div class="hidden" for="help_for_local_port">
								<em><small><?=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."); ?></small></em>
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
594 595 596
						</td>
					</tr>
					<tr>
597 598 599
						<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Server host or address");?></td>
						<td>
							<input name="server_addr" type="text" class="form-control unknown" size="30" value="<?=$pconfig['server_addr'];?>" />
Ad Schellevis's avatar
Ad Schellevis committed
600 601 602
						</td>
					</tr>
					<tr>
603 604 605
						<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Server port");?></td>
						<td>
							<input name="server_port" type="text" class="form-control unknown" size="5" value="<?=$pconfig['server_port'];?>" />
Ad Schellevis's avatar
Ad Schellevis committed
606 607 608
						</td>
					</tr>
					<tr>
609
						<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Proxy host or address");?></td>
610 611
						<td>
							<input name="proxy_addr" type="text" class="form-control unknown" size="30" value="<?=$pconfig['proxy_addr'];?>" />
Ad Schellevis's avatar
Ad Schellevis committed
612 613 614
						</td>
					</tr>
					<tr>
615
						<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Proxy port");?></td>
616 617
						<td>
							<input name="proxy_port" type="text" class="form-control unknown" size="5" value="<?=$pconfig['proxy_port'];?>" />
Ad Schellevis's avatar
Ad Schellevis committed
618 619 620
						</td>
					</tr>
					<tr>
621
						<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Proxy authentication extra options");?></td>
622 623 624 625 626 627 628 629 630
						<td>
							<?=gettext("Authentication method"); ?>
							<select name="proxy_authtype" id="proxy_authtype" class="form-control select" onchange="useproxy_changed()">
								<option value="none"  <?=$pconfig['proxy_authtype'] == "none" ? "selected=\"selected\"" : "" ?> > <?=gettext("none"); ?></option>
								<option value="basic" <?=$pconfig['proxy_authtype'] == "basic" ? "selected=\"selected\"" : "" ?> > <?=gettext("basic"); ?></option>
								<option value="basic" <?=$pconfig['proxy_authtype'] == "ntlm" ? "selected=\"selected\"" : "" ?> > <?=gettext("ntlm"); ?></option>
							</select>
							<div style="display:none" id="proxy_authtype_opts">
								<div><?=gettext("Username"); ?> <br/></div
631
								<div><input name="proxy_user" id="proxy_user" class="form-control unknown" type="text" size="20" value="<?=$pconfig['proxy_user'];?>" /></div>
632 633 634
								<div><?=gettext("Password"); ?> </div>
								<div><input name="proxy_passwd" id="proxy_passwd" type="password" class="form-control pwd" size="20" value="<?=$pconfig['proxy_passwd'];?>" /></div>
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
635 636 637
						</td>
					</tr>
					<tr>
638
						<td><a id="help_for_resolve_retry" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Server host name resolution"); ?></td>
639 640 641 642 643 644
						<td>
							<input name="resolve_retry" type="checkbox" value="yes" <?= !empty($pconfig['resolve_retry']) ? "checked=\"checked\"" : "";?>  />
							<div class="hidden" for="help_for_resolve_retry">
								<div><?=gettext("Infinitely resolve server"); ?></div>
								<div><small><?=gettext("Continuously attempt to resolve the server host name. Useful when communicating with a server that is not permanently connected to the Internet"); ?></small></div>
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
645 646 647
						</td>
					</tr>
					<tr>
648
						<td><a id="help_for_description" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Description"); ?></td>
649 650 651 652 653
						<td>
							<input name="description" type="text" class="form-control unknown" size="30" value="<?=$pconfig['description'];?>" />
							<div class="hidden" for="help_for_description">
								<small><?=gettext("You may enter a description here for your reference (not parsed)"); ?>.</small>
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
654 655 656 657 658 659
						</td>
					</tr>
					<tr>
						<td colspan="2" class="list" height="12"></td>
					</tr>
					<tr>
660
						<td colspan="2"><?=gettext("User Authentication Settings"); ?></td>
Ad Schellevis's avatar
Ad Schellevis committed
661 662
					</tr>
					<tr>
663
						<td><a id="help_for_auth_user_pass" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("User name/pass"); ?></td>
664 665
						<td>
							<div><?=gettext("Username"); ?></div>
666
							<div><input name="auth_user" id="auth_user" class="form-control unknown" type="text" size="20" value="<?=htmlspecialchars($pconfig['auth_user']);?>" /></div>
667 668 669 670 671
							<div><?=gettext("Password"); ?></div>
							<div><input name="auth_pass" id="auth_pass" type="password" class="form-control pwd" size="20" value="<?=htmlspecialchars($pconfig['auth_pass']);?>" /></div>
							<div class="hidden" for="help_for_auth_user_pass">
								<?=gettext("Leave empty when no user name and password are needed."); ?>
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
672 673 674 675
							<br/>
						</td>
					</tr>
					<tr>
676
						<td colspan="2"><?=gettext("Cryptographic Settings"); ?></td>
Ad Schellevis's avatar
Ad Schellevis committed
677 678
					</tr>
					<tr id="tls">
679 680 681 682 683 684
						<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("TLS Authentication"); ?></td>
						<td>
							<input name="tlsauth_enable" id="tlsauth_enable" type="checkbox" value="yes"  <?= !empty($pconfig['tlsauth_enable']) ? "checked=\"checked\"" : "";?> onclick="tlsauth_change()" />
							<?=gettext("Enable authentication of TLS packets"); ?>.

							<?php if (empty($pconfig['tls'])) :
685
?>
686 687 688 689
							<div id="tlsauth_opts">
								<input name="autotls_enable" id="autotls_enable" type="checkbox" value="yes"<?= !empty($pconfig['autotls_enable']) ? "checked=\"checked\"" : "";?> onclick="autotls_change()" />
								<?=gettext("Automatically generate a shared TLS authentication key"); ?>.
							</div>
690 691
							<?php
endif; ?>
692 693
							<div id="autotls_opts">
									<textarea name="tls" cols="65" rows="7" class="formpre"><?=isset($pconfig['tls'])?$pconfig['tls']:"";?></textarea>
694
										<p class="text-muted"><em><small><?=gettext("Paste your shared key here"); ?>.</small></em></p>
695
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
696 697 698
						</td>
					</tr>
					<tr id="tls_ca">
699 700 701
						<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Peer Certificate Authority"); ?></td>
							<td>
<?php if (isset($config['ca'])) :
702
?>
703
							<select name='caref' class="form-control">
704 705
<?php
                            foreach ($config['ca'] as $ca) :
706
                                $selected = "";
707
                                if (isset($pconfig['caref']) && $pconfig['caref'] == $ca['refid']) {
708 709 710
                                    $selected = "selected=\"selected\"";
                                }
                            ?>
711 712
                            <option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['descr'];?></option>
<?php
713
                            endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
714
							</select>
715 716 717
							<?php
else :
?>
718
								<b><?=gettext("No Certificate Authorities defined.");?></b> <br /><?=gettext("Create one under");?> <a href="system_camanager.php"><?=gettext("System: Certificates");?></a>.
719 720
							<?php
endif; ?>
Ad Schellevis's avatar
Ad Schellevis committed
721 722 723
							</td>
					</tr>
					<tr id="tls_cert">
724 725
						<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Client Certificate"); ?></td>
						<td>
726
							<select name='certref' class="form-control">
Ad Schellevis's avatar
Ad Schellevis committed
727
							<?php
728
                            foreach (isset($config['cert']) ? $config['cert'] : array() as $cert) :
729 730 731 732
                                $selected = "";
                                $caname = "";
                                $inuse = "";
                                $revoked = "";
733 734 735 736 737 738 739
																if (isset($cert['caref'])) {
																	$ca = lookup_ca($cert['caref']);
	                                if (!empty($ca)) {
	                                    $caname = " (CA: {$ca['descr']})";
	                                }
																}
                                if (isset($pconfig['certref']) && $pconfig['certref'] == $cert['refid']) {
740 741
                                    $selected = "selected=\"selected\"";
                                }
742
                                if (isset($cert['refid']) && cert_in_use($cert['refid'])) {
743 744 745 746 747 748
                                    $inuse = " *In Use";
                                }
                                if (is_cert_revoked($cert)) {
                                    $revoked = " *Revoked";
                                }
                            ?>
749
								<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['descr'] . $caname . $inuse . $revoked;?></option>
750 751
							<?php
                            endforeach; ?>
752
								<option value="" <?=empty($pconfig['certref'])?  "selected=\"selected\"" : "";?>> <?=gettext("None");?> <?=gettext("(Username and Password required)");?></option>
Ad Schellevis's avatar
Ad Schellevis committed
753
							</select>
754
							<?php if (!isset($config['cert']) || count($config['cert']) == 0) :
755
?>
756 757
								<b><?=gettext("No Certificates defined.");?></b> <br /><?=gettext("Create one under");?> <a href="system_certmanager.php"><?=gettext("System: Certificates");?></a> <?=gettext("if one is required for this connection.");?>
<?php
758
endif; ?>
Ad Schellevis's avatar
Ad Schellevis committed
759 760 761
						</td>
					</tr>
					<tr id="psk">
762 763 764
						<td><?=gettext("Shared Key"); ?></td>
						<td>
							<?php if (empty($pconfig['shared_key'])) :
765
?>
766 767 768
							<input name="autokey_enable" id="autokey_enable" type="checkbox" value="yes" <?= !empty($pconfig['autokey_enable']) ? "checked=\"checked\"" : "";?> onclick="autokey_change()" />
							<?=gettext("Automatically generate a shared key"); ?>.

769 770
							<?php
endif; ?>
771 772 773 774
							<div id="autokey_opts">
								<textarea name="shared_key" cols="65" rows="7" class="formpre"><?=isset($pconfig['shared_key']) ? $pconfig['shared_key'] : "";?></textarea>
								<em><small><?=gettext("Paste your shared key here"); ?>.</small></em>
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
775 776 777
						</td>
					</tr>
					<tr>
778 779
						<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Encryption algorithm"); ?></td>
						<td>
780
							<select name="crypto" class="form-control">
Ad Schellevis's avatar
Ad Schellevis committed
781
								<?php
782 783 784 785 786 787 788
                                    $cipherlist = openvpn_get_cipherlist();
                                foreach ($cipherlist as $name => $desc) :
                                    $selected = "";
                                    if ($name == $pconfig['crypto']) {
                                        $selected = " selected=\"selected\"";
                                    }
                                ?>
789
								<option value="<?=$name;?>"<?=$selected?>><?=htmlspecialchars($desc);?></option>
790 791
								<?php
                                endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
792 793 794 795
							</select>
						</td>
					</tr>
					<tr>
796 797
						<td><a id="help_for_digest" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Auth Digest Algorithm"); ?></td>
						<td>
798
							<select name="digest" class="form-control">
Ad Schellevis's avatar
Ad Schellevis committed
799
								<?php
800
                                $digestlist = openvpn_get_digestlist();
801 802 803 804 805 806
                                foreach ($digestlist as $name => $desc) :
                                    $selected = "";
                                    if ($name == $pconfig['digest']) {
                                        $selected = " selected=\"selected\"";
                                    }
                                ?>
807
								<option value="<?=$name;?>"<?=$selected?>><?=htmlspecialchars($desc);?></option>
808 809
								<?php
                                endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
810
							</select>
811 812 813
							<div class="hidden" for="help_for_digest">
								<?=gettext("NOTE: Leave this set to SHA1 unless the server is set to match. SHA1 is the default for OpenVPN."); ?>
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
814 815 816
						</td>
					</tr>
					<tr id="engine">
817 818
						<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Hardware Crypto"); ?></td>
						<td>
819
							<select name="engine" class="form-control">
Ad Schellevis's avatar
Ad Schellevis committed
820
								<?php
821
                                $engines = openvpn_get_engines();
822 823 824 825 826 827
                                foreach ($engines as $name => $desc) :
                                    $selected = "";
                                    if ($name == $pconfig['engine']) {
                                        $selected = " selected=\"selected\"";
                                    }
                                ?>
828
								<option value="<?=$name;?>"<?=$selected?>><?=htmlspecialchars($desc);?></option>
829 830
								<?php
                                endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
831 832 833 834 835 836 837
							</select>
						</td>
					</tr>
					<tr>
						<td colspan="2" class="list" height="12"></td>
					</tr>
					<tr>
838
						<td colspan="2"><?=gettext("Tunnel Settings"); ?></td>
Ad Schellevis's avatar
Ad Schellevis committed
839 840
					</tr>
					<tr>
841
						<td><a id="help_for_tunnel_network" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("IPv4 Tunnel Network"); ?></td>
842 843 844 845 846 847 848 849 850 851 852
						<td>
							<input name="tunnel_network" type="text" class="form-control unknown" size="20" value="<?=$pconfig['tunnel_network'];?>" />
							<div class="hidden" for="help_for_tunnel_network">
								<?=gettext("This is the virtual network used for private " .
								"communications between this client and the " .
								"server expressed using CIDR (eg. 10.0.8.0/24). " .
								"The first network address is assumed to be the " .
								"server address and the second network address " .
								"will be assigned to the client virtual " .
								"interface"); ?>.
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
853 854 855
						</td>
					</tr>
					<tr>
856
						<td><a id="help_for_tunnel_networkv6" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("IPv6 Tunnel Network"); ?></td>
857 858 859 860 861 862 863 864 865 866 867
						<td>
							<input name="tunnel_networkv6" type="text" class="form-control unknown" size="20" value="<?=$pconfig['tunnel_networkv6'];?>" />
							<div class="hidden" for="help_for_tunnel_networkv6">
								<?=gettext("This is the IPv6 virtual network used for private " .
								"communications between this client and the " .
								"server expressed using CIDR (eg. fe80::/64). " .
								"The first network address is assumed to be the " .
								"server address and the second network address " .
								"will be assigned to the client virtual " .
								"interface"); ?>.
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
868 869 870
						</td>
					</tr>
					<tr>
871
						<td><a id="help_for_remote_network" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("IPv4 Remote Network/s"); ?></td>
872 873 874 875
						<td>
							<input name="remote_network" type="text" class="form-control unknown" size="40" value="<?=$pconfig['remote_network'];?>" />
							<div class="hidden" for="help_for_remote_network">
								<?=gettext("These are the IPv4 networks that will be routed through " .
876 877 878 879 880
                            "the tunnel, so that a site-to-site VPN can be " .
                            "established without manually changing the routing tables. " .
                            "Expressed as a comma-separated list of one or more CIDR ranges. " .
                            "If this is a site-to-site VPN, enter the " .
                            "remote LAN/s here. You may leave this blank to " .
881 882
                            "only communicate with other clients"); ?>.
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
883 884 885
						</td>
					</tr>
					<tr>
886
						<td><a id="help_for_remote_networkv6" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("IPv6 Remote Network/s"); ?></td>
887 888 889 890
						<td>
							<input name="remote_networkv6" type="text" class="form-control unknown" size="40" value="<?=$pconfig['remote_networkv6'];?>" />
							<div class="hidden" for="help_for_remote_networkv6">
								<?=gettext("These are the IPv6 networks that will be routed through " .
891 892 893 894 895
                            "the tunnel, so that a site-to-site VPN can be " .
                            "established without manually changing the routing tables. " .
                            "Expressed as a comma-separated list of one or more IP/PREFIX. " .
                            "If this is a site-to-site VPN, enter the " .
                            "remote LAN/s here. You may leave this blank to " .
896 897
                            "only communicate with other clients"); ?>.
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
898 899 900
						</td>
					</tr>
					<tr>
901
						<td><a id="help_for_use_shaper" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Limit outgoing bandwidth");?></td>
902 903 904 905
						<td>
							<input name="use_shaper" type="text" class="form-control unknown" size="5" value="<?=$pconfig['use_shaper'];?>" />
							<div class="hidden" for="help_for_use_shaper">
								<?=gettext("Maximum outgoing bandwidth for this tunnel. " .
906 907
                            "Leave empty for no limit. The input value has " .
                            "to be something between 100 bytes/sec and 100 " .
908 909
                            "Mbytes/sec (entered as bytes per second)"); ?>.
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
910 911 912
						</td>
					</tr>
					<tr>
913
						<td><a id="help_for_compression" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Compression"); ?></td>
914
						<td>
915
							<select name="compression" class="form-control">
Ad Schellevis's avatar
Ad Schellevis committed
916
								<?php
917 918 919 920 921 922
                                foreach ($openvpn_compression_modes as $cmode => $cmodedesc) :
                                    $selected = "";
                                    if ($cmode == $pconfig['compression']) {
                                        $selected = " selected=\"selected\"";
                                    }
                                ?>
Ad Schellevis's avatar
Ad Schellevis committed
923
								<option value="<?= $cmode ?>" <?= $selected ?>><?= $cmodedesc ?></option>
924 925
								<?php
                                endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
926
							</select>
927 928 929
							<div class="hidden" for="help_for_compression">
								<?=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."); ?>.
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
930 931 932
						</td>
					</tr>
					<tr>
933
						<td><a id="help_for_passtos" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Type-of-Service"); ?></td>
934 935 936 937 938
						<td>
							<input name="passtos" type="checkbox" value="yes" <?=!empty($pconfig['passtos']) ? "checked=\"checked\"" : "" ;?>  />
							<div class="hidden" for="help_for_passtos">
								<?=gettext("Set the TOS IP header value of tunnel packets to match the encapsulated packet value"); ?>.
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
939 940 941
						</td>
					</tr>
					<tr id="chkboxNoTunIPv6">
942
						<td><a id="help_for_no_tun_ipv6" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Disable IPv6"); ?></td>
943 944 945 946 947
						<td>
							<input name="no_tun_ipv6" type="checkbox" value="yes" <?=!empty($pconfig['no_tun_ipv6']) ? "checked=\"checked\"" : "" ;?> />
							<div class="hidden" for="help_for_no_tun_ipv6">
								<?=gettext("Don't forward IPv6 traffic"); ?>.
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
948 949 950
						</td>
					</tr>
					<tr id="chkboxRouteNoPull">
951
						<td><a id="help_for_route_no_pull" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Don't pull routes"); ?></td>
952 953 954 955 956 957
						<td>
							<input name="route_no_pull" type="checkbox" value="yes" <?=!empty($pconfig['route_no_pull']) ? "checked=\"checked\"" : "" ;?> />
							<div class="hidden" for="help_for_route_no_pull">
								<?=gettext("Don't add or remove routes automatically. Instead pass routes to ");?>
								<strong>--route-up</strong> <?=gettext("script using environmental variables"); ?>.
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
958 959 960
						</td>
					</tr>
					<tr id="chkboxRouteNoExec">
961
						<td><a id="help_for_route_no_exec" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Don't add/remove routes"); ?></td>
962 963 964 965 966
						<td>
							<input name="route_no_exec" type="checkbox" value="yes" <?=!empty($pconfig['route_no_exec']) ? "checked=\"checked\"" : "" ;?> />
							<div class="hidden" for="help_for_route_no_exec">
								<?=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"); ?>.
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
967 968 969 970 971 972
						</td>
					</tr>
					<tr>
						<td colspan="2" class="list" height="12"></td>
					</tr>
					<tr>
973
						<td colspan="2"><?=gettext("Advanced configuration"); ?></td>
Ad Schellevis's avatar
Ad Schellevis committed
974 975
					</tr>
					<tr>
976
						<td><a id="help_for_custom_options" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Advanced"); ?></td>
977 978 979 980 981 982
						<td>
							<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=$pconfig['custom_options'];?></textarea><br />
							<div class="hidden" for="help_for_custom_options">
								<?=gettext("Enter any additional options you would like to add to the OpenVPN client configuration here, separated by a semicolon"); ?><br />
								<?=gettext("EXAMPLE:"); ?> <strong>remote server.mysite.com 1194;</strong> or <strong>remote 1.2.3.4 1194;</strong>
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
983 984 985
						</td>
					</tr>
					<tr id="comboboxVerbosityLevel">
986
							<td><a id="help_for_verbosity_level" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Verbosity level");?></td>
987
							<td>
988
							<select name="verbosity_level" class="form-control">
Ad Schellevis's avatar
Ad Schellevis committed
989
							<?php
990 991 992 993 994 995 996 997 998 999 1000
                            foreach ($openvpn_verbosity_level as $verb_value => $verb_desc) :
                                $selected = "";
                                if ($pconfig['verbosity_level'] == $verb_value) {
                                    $selected = "selected=\"selected\"";
                                }
                            ?>
                            <option value="<?=$verb_value;
?>" <?=$selected;
?>><?=$verb_desc;?></option>
							<?php
                            endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
1001
							</select>
1002 1003 1004 1005 1006 1007 1008
							<div class="hidden" for="help_for_verbosity_level">
								<?=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 />
								<strong>none</strong> -- <?=gettext("No output except fatal errors"); ?>. <br />
								<strong>default</strong>-<strong>4</strong> -- <?=gettext("Normal usage range"); ?>. <br />
								<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 />
								<strong>6</strong>-<strong>11</strong> -- <?=gettext("Debug info range"); ?>.
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
1009 1010 1011 1012 1013 1014 1015 1016
							</td>
					</tr>

				</table>

				<br />
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="icons">
					<tr>
1017
						<td>&nbsp;</td>
Ad Schellevis's avatar
Ad Schellevis committed
1018
						<td width="78%">
1019
							<input name="save" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
Ad Schellevis's avatar
Ad Schellevis committed
1020
							<input name="act" type="hidden" value="<?=$act;?>" />
1021 1022
							<?php if (isset($id) && $a_client[$id]) :
?>
Ad Schellevis's avatar
Ad Schellevis committed
1023
							<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
1024 1025
							<?php
endif; ?>
Ad Schellevis's avatar
Ad Schellevis committed
1026 1027 1028
						</td>
					</tr>
				</table>
1029 1030
							 </div>
							</form>
Ad Schellevis's avatar
Ad Schellevis committed
1031

1032 1033 1034
			<?php
else :
?>
Ad Schellevis's avatar
Ad Schellevis committed
1035

1036
			<table class="table table-striped">
Ad Schellevis's avatar
Ad Schellevis committed
1037 1038 1039 1040 1041 1042 1043 1044 1045
				<thead>
				<tr>
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
					<td width="10%" class="listhdrr"><?=gettext("Protocol"); ?></td>
					<td width="30%" class="listhdrr"><?=gettext("Server"); ?></td>
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
					<td width="10%" class="list"></td>
				</tr>
				</thead>
1046

Ad Schellevis's avatar
Ad Schellevis committed
1047 1048
				<tbody>
				<?php
1049 1050 1051 1052 1053 1054 1055 1056
                    $i = 0;
                foreach ($a_client as $client) :
                    $disabled = "NO";
                    if (isset($client['disable'])) {
                        $disabled = "YES";
                    }
                    $server = "{$client['server_addr']}:{$client['server_port']}";
                ?>
Ad Schellevis's avatar
Ad Schellevis committed
1057
				<tr ondblclick="document.location='vpn_openvpn_client.php?act=edit&amp;id=<?=$i;?>'">
1058
                <td>
1059 1060
                    <?=$disabled;?>
                </td>
1061
                <td>
1062 1063
                    <?=htmlspecialchars($client['protocol']);?>
                </td>
1064
                <td>
1065 1066
                    <?=htmlspecialchars($server);?>
                </td>
1067
                <td>
1068 1069
                    <?=htmlspecialchars($client['description']);?>
                </td>
1070
                <td>
1071 1072
                    <a href="vpn_openvpn_client.php?act=edit&amp;id=<?=$i;?>" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
										<a id="del_<?=$i;?>" title="<?=gettext("delete client"); ?>" class="act_delete btn btn-default btn-xs"><span class="glyphicon glyphicon-remove"></span></a>
1073
                </td>
Ad Schellevis's avatar
Ad Schellevis committed
1074 1075
				</tr>
				<?php
1076 1077 1078
                $i++;
                endforeach;
                ?>
Ad Schellevis's avatar
Ad Schellevis committed
1079 1080 1081
				</tbody>
			</table>

1082 1083
			<?php
endif; ?>
1084

1085 1086 1087 1088 1089 1090
					</div>
			    </section>
			</div>
		</div>
	</section>
<?php include("foot.inc"); ?>