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.
|
||||
func (r *reader) GetPassword(required bool) (s string, err error) {
|
||||
func (r *reader) GetPassword() (s string, err error) {
|
||||
options := []libparams.GetEnvSetter{
|
||||
libparams.CaseSensitiveValue(),
|
||||
libparams.Unset(),
|
||||
libparams.Compulsory(),
|
||||
libparams.RetroKeys([]string{"PASSWORD"}, r.onRetroActive),
|
||||
}
|
||||
if required {
|
||||
options = append(options, libparams.Compulsory())
|
||||
}
|
||||
return r.envParams.GetEnv("OPENVPN_PASSWORD", options...)
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ type Reader interface {
|
||||
|
||||
// VPN getters
|
||||
GetUser() (s string, err error)
|
||||
GetPassword(required bool) (s string, err error)
|
||||
GetPassword() (s string, err error)
|
||||
GetNetworkProtocol() (protocol models.NetworkProtocol, err error)
|
||||
GetOpenVPNVerbosity() (verbosity int, 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
|
||||
settings.User = strings.ReplaceAll(settings.User, " ", "")
|
||||
isMullvad := vpnProvider == constants.Mullvad
|
||||
settings.Password, err = paramsReader.GetPassword(!isMullvad)
|
||||
if vpnProvider == constants.Mullvad {
|
||||
settings.Password = "m"
|
||||
} else {
|
||||
settings.Password, err = paramsReader.GetPassword()
|
||||
if err != nil {
|
||||
return settings, err
|
||||
} else if isMullvad {
|
||||
settings.Password = "m"
|
||||
}
|
||||
}
|
||||
settings.Verbosity, err = paramsReader.GetOpenVPNVerbosity()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user