Code maintenance: GetPassword signature changed
This commit is contained in:
@@ -18,15 +18,13 @@ func (r *reader) GetUser() (user string, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetPassword obtains the password to use to connect to the VPN servers.
|
// GetPassword obtains the password to use to connect to the VPN servers.
|
||||||
func (r *reader) GetPassword(required bool) (s string, err error) {
|
func (r *reader) GetPassword() (s string, err error) {
|
||||||
options := []libparams.GetEnvSetter{
|
options := []libparams.GetEnvSetter{
|
||||||
libparams.CaseSensitiveValue(),
|
libparams.CaseSensitiveValue(),
|
||||||
libparams.Unset(),
|
libparams.Unset(),
|
||||||
|
libparams.Compulsory(),
|
||||||
libparams.RetroKeys([]string{"PASSWORD"}, r.onRetroActive),
|
libparams.RetroKeys([]string{"PASSWORD"}, r.onRetroActive),
|
||||||
}
|
}
|
||||||
if required {
|
|
||||||
options = append(options, libparams.Compulsory())
|
|
||||||
}
|
|
||||||
return r.envParams.GetEnv("OPENVPN_PASSWORD", options...)
|
return r.envParams.GetEnv("OPENVPN_PASSWORD", options...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ type Reader interface {
|
|||||||
|
|
||||||
// VPN getters
|
// VPN getters
|
||||||
GetUser() (s string, err error)
|
GetUser() (s string, err error)
|
||||||
GetPassword(required bool) (s string, err error)
|
GetPassword() (s string, err error)
|
||||||
GetNetworkProtocol() (protocol models.NetworkProtocol, err error)
|
GetNetworkProtocol() (protocol models.NetworkProtocol, err error)
|
||||||
GetOpenVPNVerbosity() (verbosity int, err error)
|
GetOpenVPNVerbosity() (verbosity int, err error)
|
||||||
GetOpenVPNRoot() (root bool, err error)
|
GetOpenVPNRoot() (root bool, err error)
|
||||||
|
|||||||
@@ -28,12 +28,13 @@ func GetOpenVPNSettings(paramsReader params.Reader, vpnProvider models.VPNProvid
|
|||||||
}
|
}
|
||||||
// Remove spaces in user ID to simplify user's life, thanks @JeordyR
|
// Remove spaces in user ID to simplify user's life, thanks @JeordyR
|
||||||
settings.User = strings.ReplaceAll(settings.User, " ", "")
|
settings.User = strings.ReplaceAll(settings.User, " ", "")
|
||||||
isMullvad := vpnProvider == constants.Mullvad
|
if vpnProvider == constants.Mullvad {
|
||||||
settings.Password, err = paramsReader.GetPassword(!isMullvad)
|
|
||||||
if err != nil {
|
|
||||||
return settings, err
|
|
||||||
} else if isMullvad {
|
|
||||||
settings.Password = "m"
|
settings.Password = "m"
|
||||||
|
} else {
|
||||||
|
settings.Password, err = paramsReader.GetPassword()
|
||||||
|
if err != nil {
|
||||||
|
return settings, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
settings.Verbosity, err = paramsReader.GetOpenVPNVerbosity()
|
settings.Verbosity, err = paramsReader.GetOpenVPNVerbosity()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user