1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-02 17:27:50 -04:00
v2fly/proxy/socks/config/json/config.go
2015-09-25 21:00:51 +02:00

31 lines
577 B
Go

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"`
}
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
}