Feature: OPENVPN_VERSION which can be 2.4 or 2.5

This commit is contained in:
Quentin McGaw (desktop)
2021-05-31 18:54:36 +00:00
parent 7002bf8e34
commit b829490aac
12 changed files with 71 additions and 23 deletions

View File

@@ -21,7 +21,7 @@ type OpenVPN struct {
Auth string `json:"auth"`
Provider Provider `json:"provider"`
Config string `json:"custom_config"`
Version string `json:"-"` // injected at runtime
Version string `json:"version"`
}
func (settings *OpenVPN) String() string {
@@ -31,6 +31,8 @@ func (settings *OpenVPN) String() string {
func (settings *OpenVPN) lines() (lines []string) {
lines = append(lines, lastIndent+"OpenVPN:")
lines = append(lines, indent+lastIndent+"Version: "+settings.Version)
lines = append(lines, indent+lastIndent+"Verbosity level: "+strconv.Itoa(settings.Verbosity))
if settings.Root {
@@ -98,6 +100,12 @@ func (settings *OpenVPN) read(r reader) (err error) {
}
}
settings.Version, err = r.env.Inside("OPENVPN_VERSION",
[]string{constants.Openvpn24, constants.Openvpn25}, params.Default(constants.Openvpn25))
if err != nil {
return err
}
settings.Verbosity, err = r.env.IntRange("OPENVPN_VERBOSITY", 0, 6, params.Default("1"))
if err != nil {
return err

View File

@@ -52,7 +52,8 @@ func Test_OpenVPN_JSON(t *testing.T) {
"filepath": ""
}
},
"custom_config": ""
"custom_config": "",
"version": ""
}`, string(data))
var out OpenVPN
err = json.Unmarshal(data, &out)

View File

@@ -17,6 +17,7 @@ func Test_Settings_lines(t *testing.T) {
"default settings": {
settings: Settings{
OpenVPN: OpenVPN{
Version: constants.Openvpn25,
Provider: Provider{
Name: constants.Mullvad,
},
@@ -25,6 +26,7 @@ func Test_Settings_lines(t *testing.T) {
lines: []string{
"Settings summary below:",
"|--OpenVPN:",
" |--Version: 2.5",
" |--Verbosity level: 0",
" |--Provider:",
" |--Mullvad settings:",