Commit 49229ef2 authored by Ad Schellevis's avatar Ad Schellevis

(legacy) cleanup/refactor vpn_ipsec_phase1.php

parent ffb1dfd2
...@@ -55,15 +55,6 @@ $p2_ealgos = array( ...@@ -55,15 +55,6 @@ $p2_ealgos = array(
'cast128' => array( 'name' => 'CAST128' ), 'cast128' => array( 'name' => 'CAST128' ),
'des' => array( 'name' => 'DES' )); 'des' => array( 'name' => 'DES' ));
$p1_halgos = array(
'md5' => 'MD5',
'sha1' => 'SHA1',
'sha256' => 'SHA256',
'sha384' => 'SHA384',
'sha512' => 'SHA512',
'aesxcbc' => 'AES-XCBC'
);
$p2_halgos = array( $p2_halgos = array(
'hmac_md5' => 'MD5', 'hmac_md5' => 'MD5',
'hmac_sha1' => 'SHA1', 'hmac_sha1' => 'SHA1',
......
...@@ -28,51 +28,12 @@ ...@@ -28,51 +28,12 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
require_once("guiconfig.inc"); require_once("guiconfig.inc");
require_once("vpn.inc"); require_once("vpn.inc");
require_once("services.inc"); require_once("services.inc");
require_once("pfsense-utils.inc"); require_once("pfsense-utils.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
$my_identifier_list = array(
'myaddress' => array( 'desc' => gettext('My IP address'), 'mobile' => true ),
'address' => array( 'desc' => gettext('IP address'), 'mobile' => true ),
'fqdn' => array( 'desc' => gettext('Distinguished name'), 'mobile' => true ),
'user_fqdn' => array( 'desc' => gettext('User distinguished name'), 'mobile' => true ),
'asn1dn' => array( 'desc' => gettext('ASN.1 distinguished Name'), 'mobile' => true ),
'keyid tag' => array( 'desc' => gettext('KeyID tag'), 'mobile' => true ),
'dyn_dns' => array( 'desc' => gettext('Dynamic DNS'), 'mobile' => true ));
$peer_identifier_list = array(
'peeraddress' => array( 'desc' => gettext('Peer IP address'), 'mobile' => false ),
'address' => array( 'desc' => gettext('IP address'), 'mobile' => false ),
'fqdn' => array( 'desc' => gettext('Distinguished name'), 'mobile' => true ),
'user_fqdn' => array( 'desc' => gettext('User distinguished name'), 'mobile' => true ),
'asn1dn' => array( 'desc' => gettext('ASN.1 distinguished Name'), 'mobile' => true ),
'keyid tag' => array( 'desc' =>gettext('KeyID tag'), 'mobile' => true ));
$p1_dhgroups = array(
1 => '1 (768 bit)',
2 => '2 (1024 bit)',
5 => '5 (1536 bit)',
14 => '14 (2048 bit)',
15 => '15 (3072 bit)',
16 => '16 (4096 bit)',
17 => '17 (6144 bit)',
18 => '18 (8192 bit)',
22 => '22 (1024(sub 160) bit)',
23 => '23 (2048(sub 224) bit)',
24 => '24 (2048(sub 256) bit)'
);
$p1_authentication_methods = array(
'hybrid_rsa_server' => array( 'name' => 'Hybrid RSA + Xauth', 'mobile' => true ),
'xauth_rsa_server' => array( 'name' => 'Mutual RSA + Xauth', 'mobile' => true ),
'xauth_psk_server' => array( 'name' => 'Mutual PSK + Xauth', 'mobile' => true ),
'eap-tls' => array( 'name' => 'EAP-TLS', 'mobile' => true),
'rsasig' => array( 'name' => 'Mutual RSA', 'mobile' => false ),
'pre_shared_key' => array( 'name' => 'Mutual PSK', 'mobile' => false ) );
/* /*
* ikeid management functions * ikeid management functions
...@@ -98,7 +59,6 @@ function ipsec_ikeid_next() { ...@@ -98,7 +59,6 @@ function ipsec_ikeid_next() {
} }
if (!is_array($config['ipsec'])) { if (!is_array($config['ipsec'])) {
$config['ipsec'] = array(); $config['ipsec'] = array();
} }
...@@ -114,85 +74,56 @@ if (!is_array($config['ipsec']['phase2'])) { ...@@ -114,85 +74,56 @@ if (!is_array($config['ipsec']['phase2'])) {
$a_phase1 = &$config['ipsec']['phase1']; $a_phase1 = &$config['ipsec']['phase1'];
$a_phase2 = &$config['ipsec']['phase2']; $a_phase2 = &$config['ipsec']['phase2'];
if (is_numericint($_GET['p1index'])) {
$p1index = $_GET['p1index'];
}
if (isset($_POST['p1index']) && is_numericint($_POST['p1index'])) {
$p1index = $_POST['p1index'];
}
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// fetch data
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
$p1index = $_GET['dup']; $p1index = $_GET['dup'];
} } elseif (isset($_GET['p1index']) && is_numericint($_GET['p1index'])) {
$p1index = $_GET['p1index'];
}
$pconfig = array();
if (isset($p1index) && $a_phase1[$p1index]) { // generice defaults
// don't copy the ikeid on dup $pconfig['interface'] = "wan";
$pconfig['iketype'] = "ikev1";
$phase1_fields = "mode,protocol,myid_type,myid_data,peerid_type,peerid_data
,encryption-algorithm,halgo,dhgroup,lifetime,authentication_method,descr,nat_traversal
,interface,iketype,dpd_delay,dpd_maxfail,remote-gateway,pre-shared-key,certref
,caref,reauth_enable,rekey_enable";
if (isset($p1index) && isset($a_phase1[$p1index])) {
// 1-on-1 copy
foreach (explode(",", $phase1_fields) as $fieldname) {
$fieldname = trim($fieldname);
if(isset($a_phase1[$p1index][$fieldname])) {
$pconfig[$fieldname] = $a_phase1[$p1index][$fieldname];
} elseif (!isset($pconfig[$fieldname])) {
// initialize element
$pconfig[$fieldname] = null;
}
}
// attributes with some kind of logic behind them...
if (!isset($_GET['dup']) || !is_numericint($_GET['dup'])) { if (!isset($_GET['dup']) || !is_numericint($_GET['dup'])) {
// don't copy the ikeid on dup
$pconfig['ikeid'] = $a_phase1[$p1index]['ikeid']; $pconfig['ikeid'] = $a_phase1[$p1index]['ikeid'];
} }
$old_ph1ent = $a_phase1[$p1index];
$pconfig['disabled'] = isset($a_phase1[$p1index]['disabled']); $pconfig['disabled'] = isset($a_phase1[$p1index]['disabled']);
if ($a_phase1[$p1index]['interface']) { $pconfig['remotebits'] = null;
$pconfig['interface'] = $a_phase1[$p1index]['interface']; $pconfig['remotenet'] = null ;
} else { if (isset($a_phase1[$p1index]['remote-subnet']) && strpos($a_phase1[$p1index]['remote-subnet'],'/') !== false) {
$pconfig['interface'] = "wan";
}
list($pconfig['remotenet'],$pconfig['remotebits']) = explode("/", $a_phase1[$p1index]['remote-subnet']); list($pconfig['remotenet'],$pconfig['remotebits']) = explode("/", $a_phase1[$p1index]['remote-subnet']);
} elseif (isset($a_phase1[$p1index]['remote-subnet'])) {
$pconfig['remotenet'] = $a_phase1[$p1index]['remote-subnet'];
}
if (isset($a_phase1[$p1index]['mobile'])) { if (isset($a_phase1[$p1index]['mobile'])) {
$pconfig['mobile'] = 'true'; $pconfig['mobile'] = true;
} else {
$pconfig['remotegw'] = $a_phase1[$p1index]['remote-gateway'];
} }
if (empty($a_phase1[$p1index]['iketype'])) {
$pconfig['iketype'] = "ikev1";
} else {
$pconfig['iketype'] = $a_phase1[$p1index]['iketype'];
}
$pconfig['mode'] = $a_phase1[$p1index]['mode'];
$pconfig['protocol'] = $a_phase1[$p1index]['protocol'];
$pconfig['myid_type'] = $a_phase1[$p1index]['myid_type'];
$pconfig['myid_data'] = $a_phase1[$p1index]['myid_data'];
$pconfig['peerid_type'] = $a_phase1[$p1index]['peerid_type'];
$pconfig['peerid_data'] = $a_phase1[$p1index]['peerid_data'];
$pconfig['ealgo'] = $a_phase1[$p1index]['encryption-algorithm'];
$pconfig['halgo'] = $a_phase1[$p1index]['hash-algorithm'];
$pconfig['dhgroup'] = $a_phase1[$p1index]['dhgroup'];
$pconfig['lifetime'] = $a_phase1[$p1index]['lifetime'];
$pconfig['authentication_method'] = $a_phase1[$p1index]['authentication_method'];
if (($pconfig['authentication_method'] == "pre_shared_key") ||
($pconfig['authentication_method'] == "xauth_psk_server")) {
$pconfig['pskey'] = $a_phase1[$p1index]['pre-shared-key'];
} else { } else {
$pconfig['certref'] = $a_phase1[$p1index]['certref']; /* defaults new */
$pconfig['caref'] = $a_phase1[$p1index]['caref']; if (isset($config['interfaces']['lan'])) {
}
$pconfig['descr'] = $a_phase1[$p1index]['descr'];
$pconfig['nat_traversal'] = $a_phase1[$p1index]['nat_traversal'];
if (!isset($a_phase1[$p1index]['reauth_enable'])) {
$pconfig['reauth_enable'] = true;
}
if (!isset($a_phase1[$p1index]['rekey_enable'])) {
$pconfig['rekey_enable'] = true;
}
if ($a_phase1[$p1index]['dpd_delay'] && $a_phase1[$p1index]['dpd_maxfail']) {
$pconfig['dpd_enable'] = true;
$pconfig['dpd_delay'] = $a_phase1[$p1index]['dpd_delay'];
$pconfig['dpd_maxfail'] = $a_phase1[$p1index]['dpd_maxfail'];
}
} else {
/* defaults */
$pconfig['interface'] = "wan";
if ($config['interfaces']['lan']) {
$pconfig['localnet'] = "lan"; $pconfig['localnet'] = "lan";
} }
$pconfig['mode'] = "aggressive"; $pconfig['mode'] = "aggressive";
...@@ -200,36 +131,58 @@ if (isset($p1index) && $a_phase1[$p1index]) { ...@@ -200,36 +131,58 @@ if (isset($p1index) && $a_phase1[$p1index]) {
$pconfig['myid_type'] = "myaddress"; $pconfig['myid_type'] = "myaddress";
$pconfig['peerid_type'] = "peeraddress"; $pconfig['peerid_type'] = "peeraddress";
$pconfig['authentication_method'] = "pre_shared_key"; $pconfig['authentication_method'] = "pre_shared_key";
$pconfig['ealgo'] = array( name => "3des" ); $pconfig['encryption-algorithm'] = array("name" => "3des") ;
$pconfig['halgo'] = "sha1"; $pconfig['halgo'] = "sha1";
$pconfig['dhgroup'] = "2"; $pconfig['dhgroup'] = "2";
$pconfig['lifetime'] = "28800"; $pconfig['lifetime'] = "28800";
$pconfig['nat_traversal'] = "on"; $pconfig['nat_traversal'] = "on";
$pconfig['dpd_enable'] = true;
$pconfig['iketype'] = "ikev1"; $pconfig['iketype'] = "ikev1";
/* mobile client */ /* mobile client */
if ($_GET['mobile']) { if (isset($_GET['mobile'])) {
$pconfig['mobile']=true; $pconfig['mobile']=true;
} }
} // init empty
foreach (explode(",", $phase1_fields) as $fieldname) {
$fieldname = trim($fieldname);
if (!isset($pconfig[$fieldname])) {
$pconfig[$fieldname] = null;
}
}
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) { }
unset($p1index);
}
if ($_POST) { } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
unset($input_errors); if (isset($_POST['p1index']) && is_numericint($_POST['p1index'])) {
$p1index = $_POST['p1index'];
}
$input_errors = array();
$pconfig = $_POST; $pconfig = $_POST;
$old_ph1ent = $a_phase1[$p1index];
/* input validation */ // Preperations to kill some settings which aren't left empty by the field.
// Unset ca and cert if not required to avoid storing in config
$method = $pconfig['authentication_method']; if ($pconfig['authentication_method'] == "pre_shared_key" || $pconfig['authentication_method'] == "xauth_psk_server") {
// Unset ca and cert if not required to avaoid storing in config
if ($method == "pre_shared_key" || $method == "xauth_psk_server") {
unset($pconfig['caref']); unset($pconfig['caref']);
unset($pconfig['certref']); unset($pconfig['certref']);
} }
// unset dpd on post
if (!isset($pconfig['dpd_enable'])) {
unset($pconfig['dpd_delay']);
unset($pconfig['dpd_maxfail']);
}
/* My identity */
if ($pconfig['myid_type'] == "myaddress") {
$pconfig['myid_data'] = "";
}
/* Peer identity */
if ($pconfig['myid_type'] == "peeraddress") {
$pconfig['peerid_data'] = "";
}
/* input validation */
$method = $pconfig['authentication_method'];
// Only require PSK here for normal PSK tunnels (not mobile) or xauth. // Only require PSK here for normal PSK tunnels (not mobile) or xauth.
// For RSA methods, require the CA/Cert. // For RSA methods, require the CA/Cert.
...@@ -246,7 +199,7 @@ if ($_POST) { ...@@ -246,7 +199,7 @@ if ($_POST) {
break; break;
} }
case "xauth_psk_server": case "xauth_psk_server":
$reqdfields = explode(" ", "pskey"); $reqdfields = explode(" ", "pre-shared-key");
$reqdfieldsn = array(gettext("Pre-Shared Key")); $reqdfieldsn = array(gettext("Pre-Shared Key"));
break; break;
case "hybrid_rsa_server": case "hybrid_rsa_server":
...@@ -256,40 +209,39 @@ if ($_POST) { ...@@ -256,40 +209,39 @@ if ($_POST) {
$reqdfieldsn = array(gettext("Certificate Authority"),gettext("Certificate")); $reqdfieldsn = array(gettext("Certificate Authority"),gettext("Certificate"));
break; break;
} }
if (!$pconfig['mobile']) { if (empty($pconfig['mobile'])) {
$reqdfields[] = "remotegw"; $reqdfields[] = "remote-gateway";
$reqdfieldsn[] = gettext("Remote gateway"); $reqdfieldsn[] = gettext("Remote gateway");
} }
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors); do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
if (($pconfig['lifetime'] && !is_numeric($pconfig['lifetime']))) { if ((!empty($pconfig['lifetime']) && !is_numeric($pconfig['lifetime']))) {
$input_errors[] = gettext("The P1 lifetime must be an integer."); $input_errors[] = gettext("The P1 lifetime must be an integer.");
} }
if ($pconfig['remotegw']) { if (!empty($pconfig['remote-gateway'])) {
if (!is_ipaddr($pconfig['remotegw']) && !is_domain($pconfig['remotegw'])) { if (!is_ipaddr($pconfig['remote-gateway']) && !is_domain($pconfig['remote-gateway'])) {
$input_errors[] = gettext("A valid remote gateway address or host name must be specified."); $input_errors[] = gettext("A valid remote gateway address or host name must be specified.");
} elseif (is_ipaddrv4($pconfig['remotegw']) && ($pconfig['protocol'] != "inet")) } elseif (is_ipaddrv4($pconfig['remote-gateway']) && ($pconfig['protocol'] != "inet"))
$input_errors[] = gettext("A valid remote gateway IPv4 address must be specified or you need to change protocol to IPv6"); $input_errors[] = gettext("A valid remote gateway IPv4 address must be specified or you need to change protocol to IPv6");
elseif (is_ipaddrv6($pconfig['remotegw']) && ($pconfig['protocol'] != "inet6")) elseif (is_ipaddrv6($pconfig['remote-gateway']) && ($pconfig['protocol'] != "inet6"))
$input_errors[] = gettext("A valid remote gateway IPv6 address must be specified or you need to change protocol to IPv4"); $input_errors[] = gettext("A valid remote gateway IPv6 address must be specified or you need to change protocol to IPv4");
} }
if (($pconfig['remotegw'] && is_ipaddr($pconfig['remotegw']) && !isset($pconfig['disabled']) )) { if ((!empty($pconfig['remote-gateway']) && is_ipaddr($pconfig['remote-gateway']) && !isset($pconfig['disabled']) )) {
$t = 0; $t = 0;
foreach ($a_phase1 as $ph1tmp) { foreach ($a_phase1 as $ph1tmp) {
if ($p1index <> $t) { if ($p1index <> $t) {
$tremotegw = $pconfig['remotegw']; if (isset($ph1tmp['remote-gateway']) && $ph1tmp['remote-gateway'] == $pconfig['remote-gateway'] && !isset($ph1tmp['disabled'])) {
if (($ph1tmp['remote-gateway'] == $tremotegw) && !isset($ph1tmp['disabled'])) { $input_errors[] = sprintf(gettext('The remote gateway "%1$s" is already used by phase1 "%2$s".'), $pconfig['remote-gateway'], $ph1tmp['descr']);
$input_errors[] = sprintf(gettext('The remote gateway "%1$s" is already used by phase1 "%2$s".'), $tremotegw, $ph1tmp['descr']);
} }
} }
$t++; $t++;
} }
} }
if (is_array($a_phase2) && (count($a_phase2))) { if (isset($a_phase2) && (count($a_phase2))) {
foreach ($a_phase2 as $phase2) { foreach ($a_phase2 as $phase2) {
if ($phase2['ikeid'] == $pconfig['ikeid']) { if ($phase2['ikeid'] == $pconfig['ikeid']) {
if (($pconfig['protocol'] == "inet") && ($phase2['mode'] == "tunnel6")) { if (($pconfig['protocol'] == "inet") && ($phase2['mode'] == "tunnel6")) {
...@@ -304,12 +256,6 @@ if ($_POST) { ...@@ -304,12 +256,6 @@ if ($_POST) {
} }
} }
/* My identity */
if ($pconfig['myid_type'] == "myaddress") {
$pconfig['myid_data'] = "";
}
if ($pconfig['myid_type'] == "address" and $pconfig['myid_data'] == "") { if ($pconfig['myid_type'] == "address" and $pconfig['myid_data'] == "") {
$input_errors[] = gettext("Please enter an address for 'My Identifier'"); $input_errors[] = gettext("Please enter an address for 'My Identifier'");
} }
...@@ -357,44 +303,31 @@ if ($_POST) { ...@@ -357,44 +303,31 @@ if ($_POST) {
} }
} }
/* Peer identity */
if ($pconfig['myid_type'] == "peeraddress") {
$pconfig['peerid_data'] = "";
}
// Only enforce peer ID if we are not dealing with a pure-psk mobile config. // Only enforce peer ID if we are not dealing with a pure-psk mobile config.
if (!(($pconfig['authentication_method'] == "pre_shared_key") && ($pconfig['mobile']))) { if (!(($pconfig['authentication_method'] == "pre_shared_key") && !empty($pconfig['mobile']))) {
if ($pconfig['peerid_type'] == "address" and $pconfig['peerid_data'] == "") { if ($pconfig['peerid_type'] == "address" and $pconfig['peerid_data'] == "") {
$input_errors[] = gettext("Please enter an address for 'Peer Identifier'"); $input_errors[] = gettext("Please enter an address for 'Peer Identifier'");
} }
if ($pconfig['peerid_type'] == "keyid tag" and $pconfig['peerid_data'] == "") { if ($pconfig['peerid_type'] == "keyid tag" and $pconfig['peerid_data'] == "") {
$input_errors[] = gettext("Please enter a keyid tag for 'Peer Identifier'"); $input_errors[] = gettext("Please enter a keyid tag for 'Peer Identifier'");
} }
if ($pconfig['peerid_type'] == "fqdn" and $pconfig['peerid_data'] == "") { if ($pconfig['peerid_type'] == "fqdn" and $pconfig['peerid_data'] == "") {
$input_errors[] = gettext("Please enter a fully qualified domain name for 'Peer Identifier'"); $input_errors[] = gettext("Please enter a fully qualified domain name for 'Peer Identifier'");
} }
if ($pconfig['peerid_type'] == "user_fqdn" and $pconfig['peerid_data'] == "") { if ($pconfig['peerid_type'] == "user_fqdn" and $pconfig['peerid_data'] == "") {
$input_errors[] = gettext("Please enter a user and fully qualified domain name for 'Peer Identifier'"); $input_errors[] = gettext("Please enter a user and fully qualified domain name for 'Peer Identifier'");
} }
if ((($pconfig['peerid_type'] == "address") && !is_ipaddr($pconfig['peerid_data']))) { if ((($pconfig['peerid_type'] == "address") && !is_ipaddr($pconfig['peerid_data']))) {
$input_errors[] = gettext("A valid IP address for 'Peer identifier' must be specified."); $input_errors[] = gettext("A valid IP address for 'Peer identifier' must be specified.");
} }
if ((($pconfig['peerid_type'] == "fqdn") && !is_domain($pconfig['peerid_data']))) { if ((($pconfig['peerid_type'] == "fqdn") && !is_domain($pconfig['peerid_data']))) {
$input_errors[] = gettext("A valid domain name for 'Peer identifier' must be specified."); $input_errors[] = gettext("A valid domain name for 'Peer identifier' must be specified.");
} }
if ($pconfig['peerid_type'] == "fqdn") { if ($pconfig['peerid_type'] == "fqdn") {
if (is_domain($pconfig['peerid_data']) == false) { if (is_domain($pconfig['peerid_data']) == false) {
$input_errors[] = gettext("A valid FQDN for 'Peer identifier' must be specified."); $input_errors[] = gettext("A valid FQDN for 'Peer identifier' must be specified.");
} }
} }
if ($pconfig['peerid_type'] == "user_fqdn") { if ($pconfig['peerid_type'] == "user_fqdn") {
$user_fqdn = explode("@", $pconfig['peerid_data']); $user_fqdn = explode("@", $pconfig['peerid_data']);
if (is_domain($user_fqdn[1]) == false) { if (is_domain($user_fqdn[1]) == false) {
...@@ -403,11 +336,10 @@ if ($_POST) { ...@@ -403,11 +336,10 @@ if ($_POST) {
} }
} }
if ($pconfig['dpd_enable']) { if (!empty($pconfig['dpd_enable'])) {
if (!is_numeric($pconfig['dpd_delay'])) { if (!is_numeric($pconfig['dpd_delay'])) {
$input_errors[] = gettext("A numeric value must be specified for DPD delay."); $input_errors[] = gettext("A numeric value must be specified for DPD delay.");
} }
if (!is_numeric($pconfig['dpd_maxfail'])) { if (!is_numeric($pconfig['dpd_maxfail'])) {
$input_errors[] = gettext("A numeric value must be specified for DPD retries."); $input_errors[] = gettext("A numeric value must be specified for DPD retries.");
} }
...@@ -418,51 +350,34 @@ if ($_POST) { ...@@ -418,51 +350,34 @@ if ($_POST) {
} }
/* build our encryption algorithms array */ /* build our encryption algorithms array */
$pconfig['ealgo'] = array(); if (!isset($pconfig['encryption-algorithm']) || !is_array($pconfig['encryption-algorithm'])) {
$pconfig['ealgo']['name'] = $_POST['ealgo']; $pconfig['encryption-algorithm'] = array();
}
$pconfig['encryption-algorithm']['name'] = $_POST['encryption-algorithm'];
if ($pconfig['ealgo_keylen']) { if ($pconfig['ealgo_keylen']) {
$pconfig['ealgo']['keylen'] = $_POST['ealgo_keylen']; $pconfig['ealgo']['keylen'] = $_POST['ealgo_keylen'];
} }
if (!$input_errors) { if (count($input_errors) == 0) {
$ph1ent['ikeid'] = $pconfig['ikeid']; $copy_fields = "ikeid,iketype,interface,mode,protocol,myid_type,myid_data
$ph1ent['iketype'] = $pconfig['iketype']; ,peerid_type,peerid_data,encryption-algorithm,hash-algorithm,dhgroup
$ph1ent['disabled'] = $pconfig['disabled'] ? true : false; ,lifetime,pre-shared-key,certref,caref,authentication_method,descr
$ph1ent['interface'] = $pconfig['interface']; ,nat_traversal";
/* if the remote gateway changed and the interface is not WAN then remove route */
/* the vpn_ipsec_configure() handles adding the route */ foreach (explode(",",$copy_fields) as $fieldname) {
if ($pconfig['interface'] <> "wan") { $fieldname = trim($fieldname);
if ($old_ph1ent['remote-gateway'] <> $pconfig['remotegw']) { if(isset($pconfig[$fieldname])) {
mwexec("/sbin/route delete -host {$old_ph1ent['remote-gateway']}"); $ph1ent[$fieldname] = $pconfig[$fieldname];
} }
} }
if ($pconfig['mobile']) { $ph1ent['disabled'] = !empty($pconfig['disabled']) ? true : false;
$ph1ent['private-key'] =isset($pconfig['privatekey']) ? base64_encode($pconfig['privatekey']) : null;
if (!empty($pconfig['mobile'])) {
$ph1ent['mobile'] = true; $ph1ent['mobile'] = true;
} else { } else {
$ph1ent['remote-gateway'] = $pconfig['remotegw']; $ph1ent['remote-gateway'] = $pconfig['remote-gateway'];
} }
$ph1ent['mode'] = $pconfig['mode'];
$ph1ent['protocol'] = $pconfig['protocol'];
$ph1ent['myid_type'] = $pconfig['myid_type'];
$ph1ent['myid_data'] = $pconfig['myid_data'];
$ph1ent['peerid_type'] = $pconfig['peerid_type'];
$ph1ent['peerid_data'] = $pconfig['peerid_data'];
$ph1ent['encryption-algorithm'] = $pconfig['ealgo'];
$ph1ent['hash-algorithm'] = $pconfig['halgo'];
$ph1ent['dhgroup'] = $pconfig['dhgroup'];
$ph1ent['lifetime'] = $pconfig['lifetime'];
$ph1ent['pre-shared-key'] = $pconfig['pskey'];
$ph1ent['private-key'] = base64_encode($pconfig['privatekey']);
$ph1ent['certref'] = $pconfig['certref'];
$ph1ent['caref'] = $pconfig['caref'];
$ph1ent['authentication_method'] = $pconfig['authentication_method'];
$ph1ent['descr'] = $pconfig['descr'];
$ph1ent['nat_traversal'] = $pconfig['nat_traversal'];
if (isset($pconfig['reauth_enable'])) { if (isset($pconfig['reauth_enable'])) {
$ph1ent['reauth_enable'] = true; $ph1ent['reauth_enable'] = true;
} }
...@@ -486,6 +401,14 @@ if ($_POST) { ...@@ -486,6 +401,14 @@ if ($_POST) {
$a_phase1[] = $ph1ent; $a_phase1[] = $ph1ent;
} }
/* if the remote gateway changed and the interface is not WAN then remove route */
/* the vpn_ipsec_configure() handles adding the route */
if ($pconfig['interface'] <> "wan") {
if ($old_ph1ent['remote-gateway'] <> $pconfig['remote-gateway']) {
mwexec("/sbin/route delete -host {$old_ph1ent['remote-gateway']}");
}
}
write_config(); write_config();
mark_subsystem_dirty('ipsec'); mark_subsystem_dirty('ipsec');
...@@ -494,13 +417,14 @@ if ($_POST) { ...@@ -494,13 +417,14 @@ if ($_POST) {
} }
} }
if ($pconfig['mobile']) { if (!empty($pconfig['mobile'])) {
$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Edit Phase 1"), gettext("Mobile Client")); $pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Edit Phase 1"), gettext("Mobile Client"));
} else { } else {
$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Edit Phase 1")); $pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Edit Phase 1"));
} }
$shortcut_section = "ipsec"; $shortcut_section = "ipsec";
legacy_html_escape_form_data($pconfig);
include("head.inc"); include("head.inc");
...@@ -511,22 +435,43 @@ include("head.inc"); ...@@ -511,22 +435,43 @@ include("head.inc");
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
<?php
/* determine if we should init the key length */
$keyset = '';
if (isset($pconfig['ealgo']['keylen'])) {
if (is_numeric($pconfig['ealgo']['keylen'])) {
$keyset = $pconfig['ealgo']['keylen'];
}
}
?>
$( document ).ready(function() {
// old js code..
myidsel_change();
peeridsel_change();
methodsel_change();
ealgosel_change(<?=$keyset;?>);
dpdchkbox_change();
});
function myidsel_change() { function myidsel_change() {
index = document.iform.myid_type.selectedIndex; if ($("#myid_type").val() == 'myaddress') {
value = document.iform.myid_type.options[index].value; $("#myid_data").removeClass('show');
if (value == 'myaddress') $("#myid_data").addClass('hidden');
document.getElementById('myid_data').style.visibility = 'hidden'; } else {
else $("#myid_data").removeClass('hidden');
document.getElementById('myid_data').style.visibility = 'visible'; $("#myid_data").addClass('show');
}
} }
function peeridsel_change() { function peeridsel_change() {
index = document.iform.peerid_type.selectedIndex; if ($("#peerid_type").val() == 'peeraddress') {
value = document.iform.peerid_type.options[index].value; $("#peerid_data").removeClass('show');
if (value == 'peeraddress') $("#peerid_data").addClass('hidden');
document.getElementById('peerid_data').style.visibility = 'hidden'; } else {
else $("#peerid_data").removeClass('hidden');
document.getElementById('peerid_data').style.visibility = 'visible'; $("#peerid_data").addClass('show');
}
} }
function methodsel_change() { function methodsel_change() {
...@@ -559,7 +504,7 @@ function methodsel_change() { ...@@ -559,7 +504,7 @@ function methodsel_change() {
document.getElementById('opt_cert').disabled = false; document.getElementById('opt_cert').disabled = false;
document.getElementById('opt_ca').disabled = false; document.getElementById('opt_ca').disabled = false;
break; break;
<?php if ($pconfig['mobile']) { <?php if (!empty($pconfig['mobile'])) {
?> ?>
case 'pre_shared_key': case 'pre_shared_key':
document.getElementById('opt_psk').style.display = 'none'; document.getElementById('opt_psk').style.display = 'none';
...@@ -588,7 +533,7 @@ function ealgosel_change(bits) { ...@@ -588,7 +533,7 @@ function ealgosel_change(bits) {
<?php <?php
$i = 0; $i = 0;
foreach ($p1_ealgos as $algo => $algodata) { foreach ($p1_ealgos as $algo => $algodata) {
if (is_array($algodata['keysel'])) { if (isset($algodata['keysel']) && is_array($algodata['keysel'])) {
echo " case {$i}:\n"; echo " case {$i}:\n";
echo " document.iform.ealgo_keylen.style.visibility = 'visible';\n"; echo " document.iform.ealgo_keylen.style.visibility = 'visible';\n";
echo " document.iform.ealgo_keylen.options.length = 0;\n"; echo " document.iform.ealgo_keylen.options.length = 0;\n";
...@@ -633,97 +578,92 @@ function dpdchkbox_change() { ...@@ -633,97 +578,92 @@ function dpdchkbox_change() {
//]]> //]]>
</script> </script>
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<?php <?php
if (isset($input_errors) && count($input_errors) > 0) { if (isset($input_errors) && count($input_errors) > 0) {
print_input_errors($input_errors); print_input_errors($input_errors);
} }
?> ?>
<section class="col-xs-12"> <section class="col-xs-12">
<?php
<?php
$tab_array = array(); $tab_array = array();
$tab_array[0] = array(gettext("Tunnels"), true, "vpn_ipsec.php"); $tab_array[0] = array(gettext("Tunnels"), true, "vpn_ipsec.php");
$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php"); $tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
$tab_array[2] = array(gettext("Pre-Shared Keys"), false, "vpn_ipsec_keys.php"); $tab_array[2] = array(gettext("Pre-Shared Keys"), false, "vpn_ipsec_keys.php");
$tab_array[3] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php"); $tab_array[3] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php");
display_top_tabs($tab_array); display_top_tabs($tab_array);
?> ?>
<div class="tab-content content-box col-xs-12"> <div class="tab-content content-box col-xs-12">
<form action="vpn_ipsec_phase1.php" method="post" name="iform" id="iform"> <form action="vpn_ipsec_phase1.php" method="post" name="iform" id="iform">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped table-sort"> <table class="table table-striped">
<thead>
<tr> <tr>
<th colspan="2" class="listtopic"><?=gettext("General information"); ?></th> <td width="22%"><b><?=gettext("General information"); ?></b></td>
<td width="78%" align="right">
<small><?=gettext("full help"); ?> </small>
<i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_opnvpn_server" type="button"></i></a>
</td>
</tr> </tr>
</thead>
<tbody>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td> <td width="22%" valign="top"><a id="help_for_disabled" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Disabled"); ?></td>
<td width="78%" class="vtable"> <td>
<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) { <input name="disabled" type="checkbox" id="disabled" value="yes" <?=!empty($pconfig['disabled'])?"checked=\"checked\"":"";?> />
echo "checked=\"checked\""; <div class="hidden" for="help_for_disabled">
} ?> />
<strong><?=gettext("Disable this phase1 entry"); ?></strong><br /> <strong><?=gettext("Disable this phase1 entry"); ?></strong><br />
<span class="vexpl">
<?=gettext("Set this option to disable this phase1 without " . <?=gettext("Set this option to disable this phase1 without " .
"removing it from the list"); ?>. "removing it from the list"); ?>.
</span> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Key Exchange version"); ?></td> <td><a id="help_for_iketype" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Key Exchange version"); ?></td>
<td width="78%" class="vtable"> <td>
<select name="iketype" class="formselect"> <select name="iketype" class="formselect">
<?php <?php
$keyexchange = array("ikev1" => "V1", "ikev2" => "V2"); $keyexchange = array("ikev1" => "V1", "ikev2" => "V2");
foreach ($keyexchange as $kidx => $name) : foreach ($keyexchange as $kidx => $name) :
?> ?>
<option value="<?=$kidx;?>" <?php if ($kidx == $pconfig['iketype']) { <option value="<?=$kidx;?>" <?= $kidx == $pconfig['iketype'] ? "selected=\"selected\"" : "";?> >
echo "selected=\"selected\""; <?=$name;?>
} ?>>
<?=htmlspecialchars($name);?>
</option> </option>
<?php <?php endforeach;
endforeach; ?> ?>
</select> <br /> <span class="vexpl"><?=gettext("Select the KeyExchange Protocol version to be used. Usually known as IKEv1 or IKEv2."); ?>.</span> </select>
<div class="hidden" for="help_for_iketype">
<?=gettext("Select the KeyExchange Protocol version to be used. Usually known as IKEv1 or IKEv2."); ?>.
</div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Internet Protocol"); ?></td> <td><a id="help_for_protocol" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Internet Protocol"); ?></td>
<td width="78%" class="vtable"> <td>
<select name="protocol" class="formselect"> <select name="protocol" class="formselect">
<?php <?php
$protocols = array("inet" => "IPv4", "inet6" => "IPv6"); $protocols = array("inet" => "IPv4", "inet6" => "IPv6");
foreach ($protocols as $protocol => $name) : foreach ($protocols as $protocol => $name) :
?> ?>
<option value="<?=$protocol;?>" <?php if ($protocol == $pconfig['protocol']) { <option value="<?=$protocol;?>" <?=$protocol == $pconfig['protocol'] ? "selected=\"selected\"" : "";?> >
echo "selected=\"selected\""; <?=$name?>
} ?>>
<?=htmlspecialchars($name);?>
</option> </option>
<?php <?php endforeach;
endforeach; ?> ?>
</select> <br /> <span class="vexpl"><?=gettext("Select the Internet Protocol family from this dropdown"); ?>.</span> </select>
<div class="hidden" for="help_for_protocol">
<?=gettext("Select the Internet Protocol family from this dropdown"); ?>.
</div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td> <td ><a id="help_for_interface" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Interface"); ?></td>
<td width="78%" class="vtable"> <td>
<select name="interface" class="formselect"> <select name="interface" class="formselect">
<?php <?php
$interfaces = get_configured_interface_with_descr(); $interfaces = get_configured_interface_with_descr();
$carplist = get_configured_carp_interface_list(); $carplist = get_configured_carp_interface_list();
foreach ($carplist as $cif => $carpip) { foreach ($carplist as $cif => $carpip) {
$interfaces[$cif] = $carpip." (".get_vip_descr($carpip).")"; $interfaces[$cif] = $carpip." (".get_vip_descr($carpip).")";
...@@ -746,187 +686,187 @@ function dpdchkbox_change() { ...@@ -746,187 +686,187 @@ function dpdchkbox_change() {
foreach ($interfaces as $iface => $ifacename) : foreach ($interfaces as $iface => $ifacename) :
?> ?>
<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) { <option value="<?=$iface;?>" <?= $iface == $pconfig['interface'] ? "selected=\"selected\"" : "" ?> >
echo "selected=\"selected\"";
} ?>>
<?=htmlspecialchars($ifacename);?> <?=htmlspecialchars($ifacename);?>
</option> </option>
<?php <?php endforeach;
endforeach; ?> ?>
</select> </select>
<br /> <div class="hidden" for="help_for_interface">
<span class="vexpl"><?=gettext("Select the interface for the local endpoint of this phase1 entry"); ?>.</span> <?=gettext("Select the interface for the local endpoint of this phase1 entry"); ?>.
</div>
</td> </td>
</tr> </tr>
<?php if (empty($pconfig['mobile'])) :
<?php if (!$pconfig['mobile']) :
?> ?>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote gateway"); ?></td> <td ><a id="help_for_remotegw" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Remote gateway"); ?></td>
<td width="78%" class="vtable"> <td>
<input name="remotegw" type="text" class="formfld unknown" id="remotegw" size="28" value="<?=htmlspecialchars($pconfig['remotegw']);?>" /> <input name="remote-gateway" type="text" class="formfld unknown" id="remotegw" size="28" value="<?=$pconfig['remote-gateway'];?>" />
<br /> <div class="hidden" for="help_for_remotegw">
<?=gettext("Enter the public IP address or host name of the remote gateway"); ?> <?=gettext("Enter the public IP address or host name of the remote gateway"); ?>
</div>
</td> </td>
</tr> </tr>
<?php endif;
<?php ?>
endif; ?>
<tr> <tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td> <td><a id="help_for_remotegw" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Description"); ?></td>
<td width="78%" class="vtable"> <td>
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" /> <input name="descr" type="text" id="descr" size="40" value="<?=$pconfig['descr'];?>" />
<br /> <div class="hidden" for="help_for_remotegw">
<span class="vexpl">
<?=gettext("You may enter a description here " . <?=gettext("You may enter a description here " .
"for your reference (not parsed)"); ?>. "for your reference (not parsed)"); ?>.
</span> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2" class="list" height="12"></td> <td colspan="2">&nbsp;</td>
</tr> </tr>
</tbody>
</table>
<table class="table table-striped table-sort">
<thead>
<tr> <tr>
<th colspan="2" class="listtopic"><?=gettext("Phase 1 proposal (Authentication)"); ?></th> <td colspan="2"><b><?=gettext("Phase 1 proposal (Authentication)"); ?></b></td>
</tr> </tr>
</thead>
<tbody>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication method"); ?></td> <td><a id="help_for_authmethod" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Authentication method"); ?></td>
<td width="78%" class="vtable"> <td>
<select name="authentication_method" class="formselect" onchange="methodsel_change()"> <select name="authentication_method" class="formselect" onchange="methodsel_change()">
<?php <?php
$p1_authentication_methods = array(
'hybrid_rsa_server' => array( 'name' => 'Hybrid RSA + Xauth', 'mobile' => true ),
'xauth_rsa_server' => array( 'name' => 'Mutual RSA + Xauth', 'mobile' => true ),
'xauth_psk_server' => array( 'name' => 'Mutual PSK + Xauth', 'mobile' => true ),
'eap-tls' => array( 'name' => 'EAP-TLS', 'mobile' => true),
'rsasig' => array( 'name' => 'Mutual RSA', 'mobile' => false ),
'pre_shared_key' => array( 'name' => 'Mutual PSK', 'mobile' => false ) );
foreach ($p1_authentication_methods as $method_type => $method_params) : foreach ($p1_authentication_methods as $method_type => $method_params) :
if (!$pconfig['mobile'] && $method_params['mobile']) { if (empty($pconfig['mobile']) && $method_params['mobile']) {
continue; continue;
} }
?> ?>
<option value="<?=$method_type;?>" <?php if ($method_type == $pconfig['authentication_method']) { <option value="<?=$method_type;?>" <?= $method_type == $pconfig['authentication_method'] ? "selected=\"selected\"" : "";?> >
echo "selected=\"selected\""; <?=$method_params['name'];?>
} ?>>
<?=htmlspecialchars($method_params['name']);?>
</option> </option>
<?php <?php endforeach;
endforeach; ?> ?>
</select> </select>
<br /> <div class="hidden" for="help_for_authmethod">
<span class="vexpl">
<?=gettext("Must match the setting chosen on the remote side"); ?>. <?=gettext("Must match the setting chosen on the remote side"); ?>.
</span> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Negotiation mode"); ?></td> <td><a id="help_for_mode" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Negotiation mode"); ?></td>
<td width="78%" class="vtable"> <td>
<select name="mode" class="formselect"> <select name="mode" class="formselect">
<?php <?php
$modes = array("main" => "Main", "aggressive" => "Aggressive"); $modes = array("main" => "Main", "aggressive" => "Aggressive");
foreach ($modes as $mode => $mdescr) : foreach ($modes as $mode => $mdescr) :
?> ?>
<option value="<?=$mode;?>" <?php if ($mode == $pconfig['mode']) { <option value="<?=$mode;?>" <?= $mode == $pconfig['mode'] ? "selected=\"selected\"" : "" ;?> >
echo "selected=\"selected\""; <?=$mdescr;?>
} ?>>
<?=htmlspecialchars($mdescr);?>
</option> </option>
<?php <?php endforeach;
endforeach; ?> ?>
</select> <br /> <span class="vexpl"><?=gettext("Aggressive is more flexible, but less secure"); ?>.</span> </select>
<div class="hidden" for="help_for_mode">
<?=gettext("Aggressive is more flexible, but less secure"); ?>.
</div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("My identifier"); ?></td> <td ><i class="fa fa-info-circle text-muted"></i> <?=gettext("My identifier"); ?></td>
<td width="78%" class="vtable"> <td>
<select name="myid_type" class="formselect" onchange="myidsel_change()"> <select name="myid_type" id="myid_type" class="formselect" onchange="myidsel_change()">
<?php foreach ($my_identifier_list as $id_type => $id_params) : <?php
$my_identifier_list = array(
'myaddress' => array( 'desc' => gettext('My IP address'), 'mobile' => true ),
'address' => array( 'desc' => gettext('IP address'), 'mobile' => true ),
'fqdn' => array( 'desc' => gettext('Distinguished name'), 'mobile' => true ),
'user_fqdn' => array( 'desc' => gettext('User distinguished name'), 'mobile' => true ),
'asn1dn' => array( 'desc' => gettext('ASN.1 distinguished Name'), 'mobile' => true ),
'keyid tag' => array( 'desc' => gettext('KeyID tag'), 'mobile' => true ),
'dyn_dns' => array( 'desc' => gettext('Dynamic DNS'), 'mobile' => true ));
foreach ($my_identifier_list as $id_type => $id_params) :
?> ?>
<option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['myid_type']) { <option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['myid_type']) {
echo "selected=\"selected\""; echo "selected=\"selected\"";
} ?>> } ?>>
<?=htmlspecialchars($id_params['desc']);?> <?=$id_params['desc'];?>
</option> </option>
<?php <?php
endforeach; ?> endforeach; ?>
</select> </select>
<input name="myid_data" type="text" class="formfld unknown" id="myid_data" size="30" value="<?=htmlspecialchars($pconfig['myid_data']);?>" /> <div id="myid_data">
<input name="myid_data" type="text" size="30" value="<?=$pconfig['myid_data'];?>" />
</div>
</td> </td>
</tr> </tr>
<tr id="opt_peerid"> <tr id="opt_peerid">
<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer identifier"); ?></td> <td ><i class="fa fa-info-circle text-muted"></i> <?=gettext("Peer identifier"); ?></td>
<td width="78%" class="vtable"> <td>
<select name="peerid_type" class="formselect" onchange="peeridsel_change()"> <select name="peerid_type" id="peerid_type" class="formselect" onchange="peeridsel_change()">
<?php <?php
$peer_identifier_list = array(
'peeraddress' => array( 'desc' => gettext('Peer IP address'), 'mobile' => false ),
'address' => array( 'desc' => gettext('IP address'), 'mobile' => false ),
'fqdn' => array( 'desc' => gettext('Distinguished name'), 'mobile' => true ),
'user_fqdn' => array( 'desc' => gettext('User distinguished name'), 'mobile' => true ),
'asn1dn' => array( 'desc' => gettext('ASN.1 distinguished Name'), 'mobile' => true ),
'keyid tag' => array( 'desc' =>gettext('KeyID tag'), 'mobile' => true ));
foreach ($peer_identifier_list as $id_type => $id_params) : foreach ($peer_identifier_list as $id_type => $id_params) :
if ($pconfig['mobile'] && !$id_params['mobile']) { if (!empty($pconfig['mobile']) && !$id_params['mobile']) {
continue; continue;
} }
?> ?>
<option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['peerid_type']) { <option value="<?=$id_type;?>" <?= $id_type == $pconfig['peerid_type'] ? "selected=\"selected\"" : "";?> >
echo "selected=\"selected\""; <?=$id_params['desc'];?>
} ?>>
<?=htmlspecialchars($id_params['desc']);?>
</option> </option>
<?php <?php endforeach;
endforeach; ?> ?>
</select> </select>
<input name="peerid_data" type="text" class="formfld unknown" id="peerid_data" size="30" value="<?=htmlspecialchars($pconfig['peerid_data']);?>" /> <input name="peerid_data" type="text" id="peerid_data" size="30" value="<?=$pconfig['peerid_data'];?>" />
<?php if ($pconfig['mobile']) { <?php if (!empty($pconfig['mobile'])) {
?> ?>
<br /><br /><?=gettext("NOTE: This is known as the \"group\" setting on some VPN client implementations"); ?>. <small><?=gettext("NOTE: This is known as the \"group\" setting on some VPN client implementations"); ?>.</small>
<?php <?php
} ?> } ?>
</td> </td>
</tr> </tr>
<tr id="opt_psk"> <tr id="opt_psk">
<td width="22%" valign="top" class="vncellreq"><?=gettext("Pre-Shared Key"); ?></td> <td ><a id="help_for_psk" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Pre-Shared Key"); ?></td>
<td width="78%" class="vtable"> <td>
<input name="pre-shared-key" type="text" class="formfld unknown" id="pskey" size="40"
<input name="pskey" type="text" class="formfld unknown" id="pskey" size="40" value="<?=htmlspecialchars($pconfig['pskey']);?>" /> value="<?= $pconfig['authentication_method'] == "pre_shared_key" || $pconfig['authentication_method'] == "xauth_psk_server" ? $pconfig['pre-shared-key'] : "";?>" />
<span class="vexpl"> <div class="hidden" for="help_for_psk">
<br />
<?=gettext("Input your Pre-Shared Key string"); ?>. <?=gettext("Input your Pre-Shared Key string"); ?>.
</span> </div>
</td> </td>
</tr> </tr>
<tr id="opt_cert"> <tr id="opt_cert">
<td width="22%" valign="top" class="vncellreq"><?=gettext("My Certificate"); ?></td> <td ><a id="help_for_certref" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("My Certificate"); ?></td>
<td width="78%" class="vtable"> <td>
<select name="certref" class="formselect"> <select name="certref" class="formselect">
<?php <?php
if (isset($config['cert'])) : if (isset($config['cert'])) :
foreach ($config['cert'] as $cert) : foreach ($config['cert'] as $cert) :
$selected = ""; ?>
if ($pconfig['certref'] == $cert['refid']) { <option value="<?=$cert['refid'];?>" <?= isset($pconfig['certref']) && $pconfig['certref'] == $cert['refid'] ? "selected=\"selected\"" : ""?>>
$selected = "selected=\"selected\""; <?=$cert['descr'];?>
} </option>
?> <?php endforeach;
<option value="<?=$cert['refid']; endif;
?>" <?=$selected; ?>
?>><?=$cert['descr'];?></option>
<?php
endforeach;
endif; ?>
</select> </select>
<br /> <div class="hidden" for="help_for_certref">
<span class="vexpl">
<?=gettext("Select a certificate previously configured in the Certificate Manager"); ?>. <?=gettext("Select a certificate previously configured in the Certificate Manager"); ?>.
</span> </div>
</td> </td>
</tr> </tr>
<tr id="opt_ca"> <tr id="opt_ca">
<td width="22%" valign="top" class="vncellreq"><?=gettext("My Certificate Authority"); ?></td> <td><a id="help_for_caref" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("My Certificate Authority"); ?></td>
<td width="78%" class="vtable"> <td>
<select name="caref" class="formselect"> <select name="caref" class="formselect">
<?php <?php
$config__ca = isset($config['ca']) ? $config['ca'] : array(); $config__ca = isset($config['ca']) ? $config['ca'] : array();
...@@ -936,191 +876,182 @@ endforeach; ?> ...@@ -936,191 +876,182 @@ endforeach; ?>
$selected = "selected=\"selected\""; $selected = "selected=\"selected\"";
} }
?> ?>
<option value="<?=$ca['refid']; <option value="<?=$ca['refid'];?>" <?= isset($pconfig['caref']) && $pconfig['caref'] == $ca['refid'] ? "selected=\"selected\"":"";?>>
?>" <?=$selected; <?=htmlspecialchars($ca['descr']);?>
?>><?=$ca['descr'];?></option> </option>
<?php <?php endforeach;
endforeach; ?> ?>
</select> </select>
<br /> <div class="hidden" for="help_for_caref">
<span class="vexpl">
<?=gettext("Select a certificate authority previously configured in the Certificate Manager"); ?>. <?=gettext("Select a certificate authority previously configured in the Certificate Manager"); ?>.
</span> </div>
</td> </td>
</tr> </tr>
</tbody>
</table>
<table class="table table-striped table-sort">
<thead>
<tr> <tr>
<th colspan="2" class="listtopic"><?=gettext("Phase 1 proposal (Algorithms)"); ?></th> <td colspan="2"><b><?=gettext("Phase 1 proposal (Algorithms)"); ?></b></td>
</tr> </tr>
</thead>
<tbody>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Encryption algorithm"); ?></td> <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Encryption algorithm"); ?></td>
<td width="78%" class="vtable"> <td>
<select name="ealgo" class="formselect" onchange="ealgosel_change()"> <select name="encryption-algorithm" id="ealgo" class="formselect" onchange="ealgosel_change()">
<?php <?php
foreach ($p1_ealgos as $algo => $algodata) : foreach ($p1_ealgos as $algo => $algodata) :
$selected = "";
if ($algo == $pconfig['ealgo']['name']) {
$selected = " selected=\"selected\"";
}
?> ?>
<option value="<?=$algo;?>"<?=$selected?>> <option value="<?=$algo;?>" <?= $algo == $pconfig['encryption-algorithm']['name'] ? "selected=\"selected\"" : "" ;?>>
<?=htmlspecialchars($algodata['name']);?> <?=$algodata['name'];?>
</option> </option>
<?php <?php
endforeach; ?> endforeach;
?>
</select> </select>
<select name="ealgo_keylen" width="30" class="formselect"> <select name="ealgo_keylen" width="30" class="formselect">
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Hash algorithm"); ?></td> <td><a id="help_for_halgo" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Hash algorithm"); ?></td>
<td width="78%" class="vtable"> <td>
<select name="halgo" class="formselect"> <select name="halgo" class="formselect">
<?php foreach ($p1_halgos as $algo => $algoname) : <?php
$p1_halgos = array(
'md5' => 'MD5',
'sha1' => 'SHA1',
'sha256' => 'SHA256',
'sha384' => 'SHA384',
'sha512' => 'SHA512',
'aesxcbc' => 'AES-XCBC'
);
foreach ($p1_halgos as $algo => $algoname) :
?> ?>
<option value="<?=$algo;?>" <?php if ($algo == $pconfig['halgo']) { <option value="<?=$algo;?>" <?= $algo == $pconfig['halgo'] ? "selected=\"selected\"" : "";?>>
echo "selected=\"selected\""; <?=$algoname;?>
} ?>>
<?=htmlspecialchars($algoname);?>
</option> </option>
<?php <?php endforeach;
endforeach; ?> ?>
</select> </select>
<br /> <div class="hidden" for="help_for_halgo">
<span class="vexpl">
<?=gettext("Must match the setting chosen on the remote side"); ?>. <?=gettext("Must match the setting chosen on the remote side"); ?>.
</span> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("DH key group"); ?></td> <td><a id="help_for_dhgroup" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("DH key group"); ?></td>
<td width="78%" class="vtable"> <td>
<select name="dhgroup" class="formselect"> <select name="dhgroup" class="formselect">
<?php foreach ($p1_dhgroups as $keygroup => $keygroupname) : <?php
$p1_dhgroups = array(
1 => '1 (768 bit)',
2 => '2 (1024 bit)',
5 => '5 (1536 bit)',
14 => '14 (2048 bit)',
15 => '15 (3072 bit)',
16 => '16 (4096 bit)',
17 => '17 (6144 bit)',
18 => '18 (8192 bit)',
22 => '22 (1024(sub 160) bit)',
23 => '23 (2048(sub 224) bit)',
24 => '24 (2048(sub 256) bit)'
);
foreach ($p1_dhgroups as $keygroup => $keygroupname) :
?> ?>
<option value="<?=$keygroup;?>" <?php if ($keygroup == $pconfig['dhgroup']) { <option value="<?=$keygroup;?>" <?= $keygroup == $pconfig['dhgroup'] ? "selected=\"selected\"" : "";?>>
echo "selected=\"selected\""; <?=$keygroupname;?>
} ?>>
<?=htmlspecialchars($keygroupname);?>
</option> </option>
<?php <?php endforeach;
endforeach; ?> ?>
</select> </select>
<br /> <div class="hidden" for="help_for_dhgroup">
<span class="vexpl">
<?=gettext("Must match the setting chosen on the remote side"); ?>. <?=gettext("Must match the setting chosen on the remote side"); ?>.
</span> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Lifetime"); ?></td> <td><a id="help_for_lifetime" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Lifetime"); ?></td>
<td width="78%" class="vtable"> <td>
<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="20" value="<?=htmlspecialchars($pconfig['lifetime']);?>" /> <input name="lifetime" type="text" id="lifetime" size="20" value="<?=$pconfig['lifetime'];?>" />
<div class="hidden" for="help_for_lifetime">
<?=gettext("seconds"); ?> <?=gettext("seconds"); ?>
</div>
</td> </td>
</tr> </tr>
</tbody>
</table>
<table class="table table-striped table-sort">
<thead>
<tr> <tr>
<th colspan="2" class="listtopic"><?=gettext("Advanced Options"); ?></th> <td colspan="2"><?=gettext("Advanced Options"); ?></td>
</tr> </tr>
</thead>
<tbody>
<tr> <tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Disable Rekey");?></td> <td><a id="help_for_rekey_enable" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Enable Rekey");?></td>
<td width="78%" class="vtable"> <td>
<input name="rekey_enable" type="checkbox" id="rekey_enable" value="yes" <?php if (isset($pconfig['rekey_enable'])) { <input name="rekey_enable" type="checkbox" id="rekey_enable" value="yes" <?=isset($pconfig['rekey_enable']) ? "checked=\"checked\"" : ""; ?> />
echo "checked=\"checked\""; <div class="hidden" for="help_for_rekey_enable">
} ?> /> <?=gettext("Whether a connection should be renegotiated when it is about to expire."); ?>
<?=gettext("Whether a connection should be renegotiated when it is about to expire."); ?><br /> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Disable Reauth");?></td> <td><a id="help_for_reauth_enable" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Enable Reauth");?></td>
<td width="78%" class="vtable"> <td>
<input name="reauth_enable" type="checkbox" id="reauth_enable" value="yes" <?php if (isset($pconfig['reauth_enable'])) { <input name="reauth_enable" type="checkbox" id="reauth_enable" value="yes" <?= isset($pconfig['reauth_enable']) ? "checked=\"checked\"" : "";?> />
echo "checked=\"checked\""; <div class="hidden" for="help_for_reauth_enable">
} ?> /> <?=gettext("Whether rekeying of an IKE_SA should also reauthenticate the peer. In IKEv1, reauthentication is always done."); ?>
<?=gettext("Whether rekeying of an IKE_SA should also reauthenticate the peer. In IKEv1, reauthentication is always done."); ?><br /> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top" class="vncell"><?=gettext("NAT Traversal"); ?></td> <td><a id="help_for_nat_traversal" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("NAT Traversal"); ?></td>
<td width="78%" class="vtable"> <td>
<select name="nat_traversal" class="formselect"> <select name="nat_traversal" class="formselect">
<option value="off" <?php if ($pconfig['nat_traversal'] == "off") { <option value="off" <?= isset($pconfig['nat_traversal']) && $pconfig['nat_traversal'] == "off" ? "selected=\"selected\"" :"" ;?> >
echo "selected=\"selected\""; <?=gettext("Disable"); ?>
</option>
} ?>><?=gettext("Disable"); ?></option> <option value="on" <?= isset($pconfig['nat_traversal']) && $pconfig['nat_traversal'] == "on" ? "selected=\"selected\"" :"" ;?> >
<option value="on" <?php if ($pconfig['nat_traversal'] == "on") { <?=gettext("Enable"); ?>
echo "selected=\"selected\""; </option>
<option value="force" <?= isset($pconfig['nat_traversal']) && $pconfig['nat_traversal'] == "force" ? "selected=\"selected\"" :"" ;?> >
} ?>><?=gettext("Enable"); ?></option> <?=gettext("Force"); ?>
<option value="force" <?php if ($pconfig['nat_traversal'] == "force") { </option>
echo "selected=\"selected\"";
} ?>><?=gettext("Force"); ?></option>
</select> </select>
<br /> <div class="hidden" for="help_for_nat_traversal">
<span class="vexpl">
<?=gettext("Set this option to enable the use of NAT-T (i.e. the encapsulation of ESP in UDP packets) if needed, " . <?=gettext("Set this option to enable the use of NAT-T (i.e. the encapsulation of ESP in UDP packets) if needed, " .
"which can help with clients that are behind restrictive firewalls"); ?>. "which can help with clients that are behind restrictive firewalls"); ?>.
</span> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Dead Peer Detection"); ?></td> <td><a id="help_for_dpd_enable" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Dead Peer Detection"); ?></td>
<td width="78%" class="vtable"> <td>
<input name="dpd_enable" type="checkbox" id="dpd_enable" value="yes" <?php if (isset($pconfig['dpd_enable'])) { <input name="dpd_enable" type="checkbox" id="dpd_enable" value="yes" <?=!empty($pconfig['dpd_delay']) && !empty($pconfig['dpd_maxfail'])?"checked=\"checked\"":"";?> onclick="dpdchkbox_change()" />
echo "checked=\"checked\""; <div class="hidden" for="help_for_dpd_enable">
} ?> onclick="dpdchkbox_change()" /> <?=gettext("Enable DPD"); ?>
<?=gettext("Enable DPD"); ?><br /> </div>
<div id="opt_dpd"> <div id="opt_dpd">
<br /> <br />
<input name="dpd_delay" type="text" class="formfld unknown" id="dpd_delay" size="5" value="<?=htmlspecialchars($pconfig['dpd_delay']);?>" /> <input name="dpd_delay" type="text" class="formfld unknown" id="dpd_delay" size="5" value="<?=$pconfig['dpd_delay'];?>" />
<?=gettext("seconds"); ?><br /> <?=gettext("seconds"); ?>
<span class="vexpl"> <div class="hidden" for="help_for_dpd_enable">
<?=gettext("Delay between requesting peer acknowledgement"); ?>. <?=gettext("Delay between requesting peer acknowledgement"); ?>.
</span><br /> </div>
<br /> <br />
<input name="dpd_maxfail" type="text" class="formfld unknown" id="dpd_maxfail" size="5" value="<?=htmlspecialchars($pconfig['dpd_maxfail']);?>" /> <input name="dpd_maxfail" type="text" class="formfld unknown" id="dpd_maxfail" size="5" value="<?=$pconfig['dpd_maxfail'];?>" />
<?=gettext("retries"); ?><br /> <?=gettext("retries"); ?>
<span class="vexpl"> <div class="hidden" for="help_for_dpd_enable">
<?=gettext("Number of consecutive failures allowed before disconnect"); ?>. <?=gettext("Number of consecutive failures allowed before disconnect"); ?>.
</span> </div>
<br />
</div> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top">&nbsp;</td> <td>&nbsp;</td>
<td width="78%"> <td>
<?php if (isset($p1index) && $a_phase1[$p1index]) : <?php if (isset($p1index) && isset($a_phase1[$p1index]) && !(isset($_GET['dup']) && is_numericint($_GET['dup']))) :
?> ?>
<input name="p1index" type="hidden" value="<?=htmlspecialchars($p1index);?>" /> <input name="p1index" type="hidden" value="<?=$p1index;?>" />
<?php <?php
endif; ?> endif; ?>
<?php if ($pconfig['mobile']) : <?php if (!empty($pconfig['mobile'])) :
?> ?>
<input name="mobile" type="hidden" value="true" /> <input name="mobile" type="hidden" value="true" />
<?php <?php
endif; ?> endif; ?>
<input name="ikeid" type="hidden" value="<?=htmlspecialchars($pconfig['ikeid']);?>" /> <input name="ikeid" type="hidden" value="<?=$pconfig['ikeid'];?>" />
<input name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" /> <input name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
</td> </td>
</tr> </tr>
...@@ -1128,30 +1059,10 @@ endif; ?> ...@@ -1128,30 +1059,10 @@ endif; ?>
</table> </table>
</div> </div>
</form> </form>
</div> </div>
</section> </section>
</div> </div>
</div> </div>
</section> </section>
<script type="text/javascript">
//<![CDATA[
<?php
/* determine if we should init the key length */
$keyset = '';
if (isset($pconfig['ealgo']['keylen'])) {
if (is_numeric($pconfig['ealgo']['keylen'])) {
$keyset = $pconfig['ealgo']['keylen'];
}
}
?>
myidsel_change();
peeridsel_change();
methodsel_change();
ealgosel_change(<?=$keyset;?>);
dpdchkbox_change();
//]]>
</script>
<?php include("foot.inc"); <?php include("foot.inc");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment