config.go 686 B

1234567891011121314151617181920212223242526272829303132333435
  1. package socks
  2. import (
  3. "v2ray.com/core/common/net"
  4. "v2ray.com/core/common/protocol"
  5. )
  6. func (v *Account) Equals(another protocol.Account) bool {
  7. if account, ok := another.(*Account); ok {
  8. return v.Username == account.Username
  9. }
  10. return false
  11. }
  12. func (v *Account) AsAccount() (protocol.Account, error) {
  13. return v, nil
  14. }
  15. func (v *ServerConfig) HasAccount(username, password string) bool {
  16. if v.Accounts == nil {
  17. return false
  18. }
  19. storedPassed, found := v.Accounts[username]
  20. if !found {
  21. return false
  22. }
  23. return storedPassed == password
  24. }
  25. func (v *ServerConfig) GetNetAddress() net.Address {
  26. if v.Address == nil {
  27. return net.LocalHostIP
  28. }
  29. return v.Address.AsAddress()
  30. }