Commit 74e8e203 authored by Ad Schellevis's avatar Ad Schellevis

(openvpn) refactor openvpn_get_cipherlist and openvpn_get_digestlist, fix...

(openvpn) refactor openvpn_get_cipherlist and openvpn_get_digestlist, fix compatibilty with both --show-ciphers outputs
parent 6f503e56
...@@ -166,12 +166,12 @@ function openvpn_port_next($prot, $interface = "wan") ...@@ -166,12 +166,12 @@ function openvpn_port_next($prot, $interface = "wan")
function openvpn_get_cipherlist() function openvpn_get_cipherlist()
{ {
$ciphers = array(); $ciphers = array();
$cipher_out = shell_exec('/usr/local/sbin/openvpn --show-ciphers | /usr/bin/grep "default key" | /usr/bin/awk \'{print $1, "(" $2 "-" $3 ")";}\''); exec('/usr/local/sbin/openvpn --show-ciphers', $lines);
$cipher_lines = explode("\n", trim($cipher_out)); foreach ($lines as $line) {
sort($cipher_lines); if (strstr($line, '(') !== false) {
foreach ($cipher_lines as $line) { $cipher = explode(' ', $line)[0];
$words = explode(' ', $line); $ciphers[$cipher] = $line;
$ciphers[$words[0]] = "{$words[0]} {$words[1]}"; }
} }
$ciphers["none"] = gettext("None (No Encryption)"); $ciphers["none"] = gettext("None (No Encryption)");
return $ciphers; return $ciphers;
...@@ -180,13 +180,15 @@ function openvpn_get_cipherlist() ...@@ -180,13 +180,15 @@ function openvpn_get_cipherlist()
function openvpn_get_digestlist() function openvpn_get_digestlist()
{ {
$digests = array(); $digests = array();
$digest_out = shell_exec('/usr/local/sbin/openvpn --show-digests | /usr/bin/grep "digest size" | /usr/bin/awk \'{print $1, "(" $2 "-" $3 ")";}\''); exec('/usr/local/sbin/openvpn --show-digests', $lines);
$digest_lines = explode("\n", trim($digest_out)); foreach ($lines as $line) {
sort($digest_lines); if (strstr($line, 'digest size') !== false) {
foreach ($digest_lines as $line) { $digest = explode(' ', $line)[0];
$words = explode(' ', $line); $bits = explode(' ', explode('bit', $line)[0])[1];
$digests[$words[0]] = "{$words[0]} {$words[1]}"; $digests[$digest] = $digest . " (".$bits."-bit)";
}
} }
ksort($digests);
$digests["none"] = gettext("None (No Authentication)"); $digests["none"] = gettext("None (No Authentication)");
return $digests; return $digests;
} }
......
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