Code maintenance: Use Unset() option for params
This commit is contained in:
@@ -10,24 +10,15 @@ import (
|
||||
|
||||
// GetUser obtains the user to use to connect to the VPN servers.
|
||||
func (r *reader) GetUser() (s string, err error) {
|
||||
defer func() {
|
||||
unsetenvErr := r.os.Unsetenv("USER")
|
||||
if err == nil {
|
||||
err = unsetenvErr
|
||||
}
|
||||
}()
|
||||
return r.envParams.GetEnv("USER", libparams.CaseSensitiveValue(), libparams.Compulsory())
|
||||
return r.envParams.GetEnv("USER",
|
||||
libparams.CaseSensitiveValue(),
|
||||
libparams.Compulsory(),
|
||||
libparams.Unset())
|
||||
}
|
||||
|
||||
// GetPassword obtains the password to use to connect to the VPN servers.
|
||||
func (r *reader) GetPassword(required bool) (s string, err error) {
|
||||
defer func() {
|
||||
unsetenvErr := r.os.Unsetenv("PASSWORD")
|
||||
if err == nil {
|
||||
err = unsetenvErr
|
||||
}
|
||||
}()
|
||||
options := []libparams.GetEnvSetter{libparams.CaseSensitiveValue()}
|
||||
options := []libparams.GetEnvSetter{libparams.CaseSensitiveValue(), libparams.Unset()}
|
||||
if required {
|
||||
options = append(options, libparams.Compulsory())
|
||||
}
|
||||
|
||||
@@ -35,13 +35,7 @@ func (r *reader) GetShadowSocksPort() (port uint16, err error) {
|
||||
// GetShadowSocksPassword obtains the ShadowSocks server password from the environment variable
|
||||
// SHADOWSOCKS_PASSWORD.
|
||||
func (r *reader) GetShadowSocksPassword() (password string, err error) {
|
||||
defer func() {
|
||||
unsetErr := r.os.Unsetenv("SHADOWSOCKS_PASSWORD")
|
||||
if err == nil {
|
||||
err = unsetErr
|
||||
}
|
||||
}()
|
||||
return r.envParams.GetEnv("SHADOWSOCKS_PASSWORD", libparams.CaseSensitiveValue())
|
||||
return r.envParams.GetEnv("SHADOWSOCKS_PASSWORD", libparams.CaseSensitiveValue(), libparams.Unset())
|
||||
}
|
||||
|
||||
// GetShadowSocksMethod obtains the ShadowSocks method to use from the environment variable
|
||||
|
||||
Reference in New Issue
Block a user