diff --git a/src/usr/local/www/wizard.php b/src/usr/local/www/wizard.php index 54e04c56ca..e7b91ef3f3 100644 --- a/src/usr/local/www/wizard.php +++ b/src/usr/local/www/wizard.php @@ -806,6 +806,68 @@ if ($pkg['step'][$stepid]['fields']['field'] != "") { $section->addInput($tmpselect); + break; + case "select_source": + if ($field['displayname']) { + $etitle = $field['displayname']; + } else if (!$field['dontdisplayname']) { + $etitle = fixup_string($name); + } + + if ($field['size']) { + $size = " size='" . $field['size'] . "' "; + } + + if (isset($field['multiple'])) { + $items = explode(',', $value); + $name .= "[]"; + } else { + $items = array($value); + } + + $onchange = (isset($field['onchange']) ? "{$field['onchange']}" : ''); + + $source = $field['source']; + try{ + @eval("\$wizard_source_txt = &$source;"); + } catch (\Throwable | \Error | \Exception $e) { + //do nothing + } + #check if show disable option is present on xml + if (!is_array($wizard_source_txt)) { + $wizard_source_txt = array(); + } + if (isset($field['show_disable_value'])) { + array_push($wizard_source_txt, + array( + ($field['source_name'] ? $field['source_name'] : $name) => $field['show_disable_value'], + ($field['source_value'] ? $field['source_value'] : $value) => $field['show_disable_value'] + )); + } + + $srcoptions = array(); + $srcselected = array(); + + foreach ($wizard_source_txt as $opt) { + $source_name = ($field['source_name'] ? $opt[$field['source_name']] : $opt[$name]); + $source_value = ($field['source_value'] ? $opt[$field['source_value']] : $opt[$value]); + $srcoptions[$source_value] = $source_name; + + if (in_array($source_value, $items)) { + array_push($srcselected, $source_value); + } + } + + $descr = (isset($field['description'])) ? $field['description'] : ""; + + $section->addInput(new Form_Select( + $name, + $etitle, + isset($field['multiple']) ? $srcselected : $srcselected[0], + $srcoptions, + isset($field['multiple']) + ))->setHelp($descr)->setOnchange($onchange); + break; case "textarea": if ($field['displayname']) { diff --git a/src/usr/local/www/wizards/openvpn_wizard.inc b/src/usr/local/www/wizards/openvpn_wizard.inc index 8274a48316..5223ec8bad 100644 --- a/src/usr/local/www/wizards/openvpn_wizard.inc +++ b/src/usr/local/www/wizards/openvpn_wizard.inc @@ -30,6 +30,18 @@ require_once("util.inc"); // Load valid country codes $dn_cc = get_cert_country_codes(); +function openvpn_wizard_get_dhparams() { + global $openvpn_dh_lengths; + $dhparams = array(); + foreach ($openvpn_dh_lengths as $value => $name) { + $dhparams[] = array( + "value" => $value, + "name" => $name + ); + } + return $dhparams; +} + function step1_stepsubmitbeforesave() { global $stepid, $config; if (($_POST['authtype'] != NULL) && ($_POST['authtype'] != $config['ovpnserver']['step1']['type'])) { diff --git a/src/usr/local/www/wizards/openvpn_wizard.xml b/src/usr/local/www/wizards/openvpn_wizard.xml index 16702453ad..e5d154a469 100644 --- a/src/usr/local/www/wizards/openvpn_wizard.xml +++ b/src/usr/local/www/wizards/openvpn_wizard.xml @@ -781,47 +781,12 @@ DH Parameters Length dhparameters - select + select_source + + name + value 2048 ovpnserver->step10->dhkey - - - - - - - - - - - <br/>Length of Diffie-Hellman (DH) key exchange parameters, used for establishing a secure communications channel. The DH parameters are different from key sizes, but as with other such settings, the larger the key, the more security it offers, but larger keys take considerably more time to generate. As of 2016, 2048 bit is a common and typical selection.