config.go 653 B

1234567891011121314151617181920212223242526272829303132
  1. package json
  2. import (
  3. "github.com/v2ray/v2ray-core/config"
  4. "github.com/v2ray/v2ray-core/config/json"
  5. )
  6. const (
  7. AuthMethodNoAuth = "noauth"
  8. AuthMethodUserPass = "password"
  9. )
  10. type SocksConfig struct {
  11. AuthMethod string `json:"auth"`
  12. Username string `json:"user"`
  13. Password string `json:"pass"`
  14. UDPEnabled bool `json:"udp"`
  15. }
  16. func (config SocksConfig) IsNoAuth() bool {
  17. return config.AuthMethod == AuthMethodNoAuth
  18. }
  19. func (config SocksConfig) IsPassword() bool {
  20. return config.AuthMethod == AuthMethodUserPass
  21. }
  22. func init() {
  23. json.RegisterConfigType("socks", config.TypeInbound, func() interface{} {
  24. return new(SocksConfig)
  25. })
  26. }