From 95f02e9d84030a2efbbba2262a234cabeeaac3fc Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Wed, 21 Nov 2018 12:42:10 +0100 Subject: luci-app-openvpn: fix whitespaces in openvpn-basic Signed-off-by: Florian Eckert --- applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua') diff --git a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua index 47b1799918..65f7adf9a9 100644 --- a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua +++ b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua @@ -4,7 +4,7 @@ local fs = require("nixio.fs") local basicParams = { - -- + -- -- Widget, Name, Default(s), Description -- { ListValue, "verb", { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, translate("Set output verbosity") }, @@ -54,7 +54,7 @@ for _, option in ipairs(basicParams) do option[1], option[2], option[2], option[4] ) - + o.optional = true if option[1] == DummyValue then -- cgit v1.2.3 From 9881ad5a6b558dbff21703724b29d34c96d1d327 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Wed, 21 Nov 2018 12:46:29 +0100 Subject: luci-app-openvpn: sync code style with openvpn-advanced Signed-off-by: Florian Eckert --- .../luasrc/model/cbi/openvpn-basic.lua | 110 ++++++++++++++++----- 1 file changed, 84 insertions(+), 26 deletions(-) (limited to 'applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua') diff --git a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua index 65f7adf9a9..42eb4cfd82 100644 --- a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua +++ b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua @@ -7,32 +7,90 @@ local basicParams = { -- -- Widget, Name, Default(s), Description -- - { ListValue, "verb", { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, translate("Set output verbosity") }, - { Value, "nice",0, translate("Change process priority") }, - { Value,"port",1194, translate("TCP/UDP port # for both local and remote") }, - { ListValue,"dev_type",{ "tun", "tap" }, translate("Type of used device") }, - - { Value,"ifconfig","10.200.200.3 10.200.200.1", translate("Set tun/tap adapter parameters") }, - { Value,"server","10.200.200.0 255.255.255.0", translate("Configure server mode") }, - { Value,"server_bridge","192.168.1.1 255.255.255.0 192.168.1.128 192.168.1.254", translate("Configure server bridge") }, - { Flag,"nobind",0, translate("Do not bind to local address and port") }, - - { Value,"keepalive","10 60", translate("Helper directive to simplify the expression of --ping and --ping-restart in server mode configurations") }, - - { ListValue,"proto",{ "udp", "tcp-client", "tcp-server" }, translate("Use protocol") }, - - { Flag,"client",0, translate("Configure client mode") }, - { Flag,"client_to_client",0, translate("Allow client-to-client traffic") }, - { DynamicList,"remote","vpnserver.example.org", translate("Remote host name or ip address") }, - - { FileUpload,"secret","/etc/openvpn/secret.key", translate("Enable Static Key encryption mode (non-TLS)") }, - { ListValue,"key_direction", { 0, 1 }, translate("The key direction for 'tls-auth' and 'secret' options") }, - { FileUpload,"pkcs12","/etc/easy-rsa/keys/some-client.pk12", translate("PKCS#12 file containing keys") }, - { FileUpload,"ca","/etc/easy-rsa/keys/ca.crt", translate("Certificate authority") }, - { FileUpload,"dh","/etc/easy-rsa/keys/dh1024.pem", translate("Diffie Hellman parameters") }, - { FileUpload,"cert","/etc/easy-rsa/keys/some-client.crt", translate("Local certificate") }, - { FileUpload,"key","/etc/easy-rsa/keys/some-client.key", translate("Local private key") }, - { Value,"config","/etc/openvpn/ovpn-file.ovpn", translate("Local OVPN configuration file") }, + { ListValue, + "verb", + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, + translate("Set output verbosity") }, + { Value, + "nice", + 0, + translate("Change process priority") }, + { Value, + "port", + 1194, + translate("TCP/UDP port # for both local and remote") }, + { ListValue, + "dev_type", + { "tun", "tap" }, + translate("Type of used device") }, + { Value, + "ifconfig", + "10.200.200.3 10.200.200.1", + translate("Set tun/tap adapter parameters") }, + { Value, + "server", + "10.200.200.0 255.255.255.0", + translate("Configure server mode") }, + { Value, + "server_bridge", + "192.168.1.1 255.255.255.0 192.168.1.128 192.168.1.254", + translate("Configure server bridge") }, + { Flag, + "nobind", + 0, + translate("Do not bind to local address and port") }, + { Value, + "keepalive", + "10 60", + translate("Helper directive to simplify the expression of --ping and --ping-restart in server mode configurations") }, + { ListValue, + "proto", + { "udp", "tcp-client", "tcp-server" }, + translate("Use protocol") }, + { Flag, + "client", + 0, + translate("Configure client mode") }, + { Flag, + "client_to_client", + 0, + translate("Allow client-to-client traffic") }, + { DynamicList, + "remote", + "vpnserver.example.org", + translate("Remote host name or ip address") }, + { FileUpload, + "secret", + "/etc/openvpn/secret.key", + translate("Enable Static Key encryption mode (non-TLS)") }, + { ListValue, + "key_direction", + { 0, 1 }, + translate("The key direction for 'tls-auth' and 'secret' options") }, + { FileUpload, + "pkcs12", + "/etc/easy-rsa/keys/some-client.pk12", + translate("PKCS#12 file containing keys") }, + { FileUpload, + "ca", + "/etc/easy-rsa/keys/ca.crt", + translate("Certificate authority") }, + { FileUpload, + "dh", + "/etc/easy-rsa/keys/dh1024.pem", + translate("Diffie Hellman parameters") }, + { FileUpload, + "cert", + "/etc/easy-rsa/keys/some-client.crt", + translate("Local certificate") }, + { FileUpload, + "key", + "/etc/easy-rsa/keys/some-client.key", + translate("Local private key") }, + { Value, + "config", + "/etc/openvpn/ovpn-file.ovpn", + translate("Local OVPN configuration file") }, } -- cgit v1.2.3 From 1986dc2751517f11da943863a8cca6b3fe50be3b Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Wed, 21 Nov 2018 13:15:29 +0100 Subject: luci-app-openvpn: On apply/save redirect to OpenVPN overview page This change will redirect on apply/save to the OpenVPN overview page. This is the default behaviour on LuCI. Signed-off-by: Florian Eckert --- applications/luci-app-openvpn/luasrc/model/cbi/openvpn-advanced.lua | 4 ++-- applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua') diff --git a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-advanced.lua b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-advanced.lua index 3fb734aeb0..a693e0cf0c 100644 --- a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-advanced.lua +++ b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-advanced.lua @@ -703,10 +703,10 @@ local cts = { } local params = { } local m = Map("openvpn") -local p = m:section( SimpleSection ) - +m.redirect = luci.dispatcher.build_url("admin", "services", "openvpn") m.apply_on_parse = true +local p = m:section( SimpleSection ) p.template = "openvpn/pageswitch" p.mode = "advanced" p.instance = arg[1] diff --git a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua index 42eb4cfd82..cee5f9d31d 100644 --- a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua +++ b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua @@ -95,11 +95,10 @@ local basicParams = { local m = Map("openvpn") -local p = m:section( SimpleSection ) - +m.redirect = luci.dispatcher.build_url("admin", "services", "openvpn") m.apply_on_parse = true - +local p = m:section( SimpleSection ) p.template = "openvpn/pageswitch" p.mode = "basic" p.instance = arg[1] -- cgit v1.2.3 From 1987b380110e967d1dc7ad88d8462e2f2ab6aa61 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Thu, 22 Nov 2018 10:53:55 +0100 Subject: luci-app-openvpn: do not show all boolean option by default If a new instance is edit then all boolean option are shown on the LuCI. This is confusing. To fix this hide all boolean ellements on the config page which are not enabled by default. They must be add first. Signed-off-by: Florian Eckert --- applications/luci-app-openvpn/luasrc/model/cbi/openvpn-advanced.lua | 2 ++ applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua | 2 ++ 2 files changed, 4 insertions(+) (limited to 'applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua') diff --git a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-advanced.lua b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-advanced.lua index a693e0cf0c..9a37ba8022 100644 --- a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-advanced.lua +++ b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-advanced.lua @@ -772,6 +772,8 @@ for _, option in ipairs(params) do end return AbstractValue.remove(self, section) end + elseif option[1] == Flag then + o.default = nil else if option[1] == DynamicList then function o.cfgvalue(...) diff --git a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua index cee5f9d31d..3be274dc8b 100644 --- a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua +++ b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-basic.lua @@ -148,6 +148,8 @@ for _, option in ipairs(basicParams) do end return AbstractValue.remove(self, section) end + elseif option[1] == Flag then + o.default = nil else if option[1] == DynamicList then function o.cfgvalue(...) -- cgit v1.2.3