From 0b028c1799196d13d58bf9c0214ab2be949d85cc Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 19 Nov 2018 21:58:14 +0100 Subject: [PATCH] OpenVPN export, work in progress for https://github.com/opnsense/core/issues/2787 Add custom input and cleanup supportedOptions() method --- .../OPNsense/OpenVPN/forms/export_options.xml | 19 ++++--------------- .../OPNsense/OpenVPN/ArchiveOpenVPN.php | 2 +- .../library/OPNsense/OpenVPN/PlainOpenVPN.php | 10 +++++++++- .../app/models/OPNsense/OpenVPN/Export.xml | 1 + .../app/views/OPNsense/OpenVPN/export.volt | 5 +++++ 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/OpenVPN/forms/export_options.xml b/src/opnsense/mvc/app/controllers/OPNsense/OpenVPN/forms/export_options.xml index 2b85cebf0..0b82e933b 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/OpenVPN/forms/export_options.xml +++ b/src/opnsense/mvc/app/controllers/OPNsense/OpenVPN/forms/export_options.xml @@ -45,21 +45,10 @@ Verify the server certificate Common Name (CN) when the client connects - openvpn_export.testxx1 - + openvpn_export.plain_config + - text - - - openvpn_export.testxx2 - - - text - - - openvpn_export.testxx3 - - - text + textbox + Custom configuration, which will be returned in the output file without modifications diff --git a/src/opnsense/mvc/app/library/OPNsense/OpenVPN/ArchiveOpenVPN.php b/src/opnsense/mvc/app/library/OPNsense/OpenVPN/ArchiveOpenVPN.php index 09396a35c..855df8b30 100644 --- a/src/opnsense/mvc/app/library/OPNsense/OpenVPN/ArchiveOpenVPN.php +++ b/src/opnsense/mvc/app/library/OPNsense/OpenVPN/ArchiveOpenVPN.php @@ -37,6 +37,6 @@ class ArchiveOpenVPN extends PlainOpenVPN public function supportedOptions() { - return array("testxx2"); + return array("plain_config"); } } diff --git a/src/opnsense/mvc/app/library/OPNsense/OpenVPN/PlainOpenVPN.php b/src/opnsense/mvc/app/library/OPNsense/OpenVPN/PlainOpenVPN.php index 337cb9d6f..dbc7b7167 100644 --- a/src/opnsense/mvc/app/library/OPNsense/OpenVPN/PlainOpenVPN.php +++ b/src/opnsense/mvc/app/library/OPNsense/OpenVPN/PlainOpenVPN.php @@ -37,7 +37,7 @@ class PlainOpenVPN extends BaseExporter implements IExportProvider public function supportedOptions() { - return array("testxx1", "testxx3"); + return array("plain_config"); } /** @@ -107,6 +107,14 @@ class PlainOpenVPN extends BaseExporter implements IExportProvider $conf[] = "auth-user-pass"; } + if (!empty($this->config['plain_config'])) { + foreach (preg_split('/\r\n|\r|\n/', $this->config['plain_config']) as $line) { + if (!empty($line)) { + $conf[] = $line; + } + } + } + return $conf; } diff --git a/src/opnsense/mvc/app/models/OPNsense/OpenVPN/Export.xml b/src/opnsense/mvc/app/models/OPNsense/OpenVPN/Export.xml index 5d1dcede2..ee0d61428 100644 --- a/src/opnsense/mvc/app/models/OPNsense/OpenVPN/Export.xml +++ b/src/opnsense/mvc/app/models/OPNsense/OpenVPN/Export.xml @@ -26,6 +26,7 @@ 1 Y + diff --git a/src/opnsense/mvc/app/views/OPNsense/OpenVPN/export.volt b/src/opnsense/mvc/app/views/OPNsense/OpenVPN/export.volt index 1759317b7..74f0c4b24 100644 --- a/src/opnsense/mvc/app/views/OPNsense/OpenVPN/export.volt +++ b/src/opnsense/mvc/app/views/OPNsense/OpenVPN/export.volt @@ -29,6 +29,11 @@ margin-top: 5px; margin-bottom: 5px; } + + textarea { + white-space: nowrap; + overflow: auto; + }