2015-09-25 19:00:51 +00:00
|
|
|
package json
|
|
|
|
|
|
|
|
import (
|
2015-10-06 21:11:08 +00:00
|
|
|
"github.com/v2ray/v2ray-core/config"
|
|
|
|
"github.com/v2ray/v2ray-core/config/json"
|
2015-09-25 19:00:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
AuthMethodNoAuth = "noauth"
|
|
|
|
AuthMethodUserPass = "password"
|
|
|
|
)
|
|
|
|
|
|
|
|
type SocksConfig struct {
|
|
|
|
AuthMethod string `json:"auth"`
|
|
|
|
Username string `json:"user"`
|
|
|
|
Password string `json:"pass"`
|
2015-10-03 09:34:01 +00:00
|
|
|
UDPEnabled bool `json:"udp"`
|
2015-09-25 19:00:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (config SocksConfig) IsNoAuth() bool {
|
|
|
|
return config.AuthMethod == AuthMethodNoAuth
|
|
|
|
}
|
|
|
|
|
|
|
|
func (config SocksConfig) IsPassword() bool {
|
|
|
|
return config.AuthMethod == AuthMethodUserPass
|
|
|
|
}
|
|
|
|
|
2015-10-06 21:11:08 +00:00
|
|
|
func init() {
|
|
|
|
json.RegisterConfigType("socks", config.TypeInbound, func() interface{} {
|
|
|
|
return new(SocksConfig)
|
|
|
|
})
|
2015-09-25 19:00:51 +00:00
|
|
|
}
|