From 04a6e90048da109b5bde1a9263afc16adb7c9b9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=C3=A7i?= Date: Fri, 11 Apr 2008 21:03:10 +0000 Subject: Differentiate between shared key and pki on the GUI. Fix some errors with the javascript --- etc/inc/openvpn.inc | 55 ++++++++++++++++++++++++++++------------------- usr/local/pkg/openvpn.xml | 9 +++++++- 2 files changed, 41 insertions(+), 23 deletions(-) diff --git a/etc/inc/openvpn.inc b/etc/inc/openvpn.inc index 53b4ce8..9323194 100644 --- a/etc/inc/openvpn.inc +++ b/etc/inc/openvpn.inc @@ -58,12 +58,25 @@ function openvpn_get_ciphers($pkg) { if (is_array($config['openvpn']['keys'])) { if (count($config['openvpn']['keys']) > 0) { $option_array = &$pkg['fields']['field'][$i]['options']['option']; - foreach ($config['openvpn']['keys'] as $cipher => $none) { - $option_array[] = array('value' => $cipher, 'name' => $cipher); + foreach ($config['openvpn']['keys'] as $cipher => $type) { + if ($type['shared.key']) + $option_array[] = array('value' => $cipher, 'name' => $cipher); } } } } + if ($field['fieldname'] == 'cipherpki') { + if (is_array($config['openvpn']['keys'])) { + if (count($config['openvpn']['keys']) > 0) { + $option_array = &$pkg['fields']['field'][$i]['options']['option']; + foreach ($config['openvpn']['keys'] as $cipher => $type) { + if ($type['auth_method'] == 'pki') + $option_array[] = array('value' => $cipher, 'name' => $cipher); + } + } + } + } + } } @@ -465,9 +478,13 @@ EOD; } foreach ($keys as $key) { - if ($mode == "server" && isset($settings['cipher']) && $settings['cipher'] != "none") { - - $openvpn_conf .= $key['directive'] . " " . $base_file . $settings['cipher'] . "/".$key['field'] . "\n"; + if ($mode == "server") { + $openvpn_conf .= $key['directive'] . " " . $base_file; + if ($settings['auth_method'] == 'pki' && isset($settings['cipherpki']) && $settings['cipherpki'] != "none") + $openvpn_conf .= $settings['cipherpki']; + else + $openvpn_conf .= $settings['cipher']; + $openvpn_conf .= "/".$key['field']."\n"; } else { $filename = $g['varetc_path']."/openvpn_{$mode}{$id}." . $key['field']; file_put_contents($filename, base64_decode($settings[$key['field']])); @@ -699,33 +716,27 @@ function openvpn_resync_all() { function openvpn_print_javascript($mode) { $javascript = << - @@ -738,7 +749,7 @@ EOD; function openvpn_print_javascript2() { $javascript = << - diff --git a/usr/local/pkg/openvpn.xml b/usr/local/pkg/openvpn.xml index f6df929..9a2aef1 100644 --- a/usr/local/pkg/openvpn.xml +++ b/usr/local/pkg/openvpn.xml @@ -159,10 +159,17 @@ cipher Certificates to apply - Certificates generated from the certificate generation tab. + Shared key to use. select none + + cipherpki + Certificates to apply + Certificates generated from the certificate generation tab. + select + none + dhcp_domainname DHCP-Opt.: DNS-Domainname -- cgit v1.1