mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Add wizard select_source & use for OpenVPN DH. Fixes #9748
This commit is contained in:
parent
17d967af8d
commit
52f686a97f
@ -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']) {
|
||||
|
||||
@ -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'])) {
|
||||
|
||||
@ -781,47 +781,12 @@
|
||||
<field>
|
||||
<displayname>DH Parameters Length</displayname>
|
||||
<name>dhparameters</name>
|
||||
<type>select</type>
|
||||
<type>select_source</type>
|
||||
<source><![CDATA[openvpn_wizard_get_dhparams()]]></source>
|
||||
<source_name>name</source_name>
|
||||
<source_value>value</source_value>
|
||||
<value>2048</value>
|
||||
<bindstofield>ovpnserver->step10->dhkey</bindstofield>
|
||||
<options>
|
||||
<option>
|
||||
<name>1024 bit</name>
|
||||
<value>1024</value>
|
||||
</option>
|
||||
<option>
|
||||
<name>2048 bit</name>
|
||||
<value>2048</value>
|
||||
</option>
|
||||
<option>
|
||||
<name>3072 bit</name>
|
||||
<value>3072</value>
|
||||
</option>
|
||||
<option>
|
||||
<name>4096 bit</name>
|
||||
<value>4096</value>
|
||||
</option>
|
||||
<option>
|
||||
<name>6144 bit</name>
|
||||
<value>6144</value>
|
||||
</option>
|
||||
<option>
|
||||
<name>7680 bit</name>
|
||||
<value>7680</value>
|
||||
</option>
|
||||
<option>
|
||||
<name>8192 bit</name>
|
||||
<value>8192</value>
|
||||
</option>
|
||||
<option>
|
||||
<name>15360 bit</name>
|
||||
<value>15360</value>
|
||||
</option>
|
||||
<option>
|
||||
<name>16384 bit</name>
|
||||
<value>16384</value>
|
||||
</option>
|
||||
</options>
|
||||
<description><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.</description>
|
||||
</field>
|
||||
<field>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user