2015-09-25 15:00:51 -04:00
|
|
|
package json
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
AuthMethodNoAuth = "noauth"
|
|
|
|
AuthMethodUserPass = "password"
|
|
|
|
)
|
|
|
|
|
|
|
|
type SocksConfig struct {
|
|
|
|
AuthMethod string `json:"auth"`
|
|
|
|
Username string `json:"user"`
|
|
|
|
Password string `json:"pass"`
|
2015-10-03 05:34:01 -04:00
|
|
|
UDPEnabled bool `json:"udp"`
|
2015-09-25 15:00:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (config SocksConfig) IsNoAuth() bool {
|
|
|
|
return config.AuthMethod == AuthMethodNoAuth
|
|
|
|
}
|
|
|
|
|
|
|
|
func (config SocksConfig) IsPassword() bool {
|
|
|
|
return config.AuthMethod == AuthMethodUserPass
|
|
|
|
}
|
|
|
|
|
|
|
|
func Load(rawConfig []byte) (SocksConfig, error) {
|
|
|
|
config := SocksConfig{}
|
|
|
|
err := json.Unmarshal(rawConfig, &config)
|
|
|
|
return config, err
|
|
|
|
}
|