config.go 627 B

1234567891011121314151617181920212223242526272829
  1. package shadowsocks_2022
  2. import (
  3. "github.com/xtls/xray-core/common/protocol"
  4. )
  5. // MemoryAccount is an account type converted from Account.
  6. type MemoryAccount struct {
  7. Key string
  8. Email string
  9. Level int32
  10. }
  11. // AsAccount implements protocol.AsAccount.
  12. func (u *User) AsAccount() (protocol.Account, error) {
  13. return &MemoryAccount{
  14. Key: u.GetKey(),
  15. Email: u.GetEmail(),
  16. Level: u.GetLevel(),
  17. }, nil
  18. }
  19. // Equals implements protocol.Account.Equals().
  20. func (a *MemoryAccount) Equals(another protocol.Account) bool {
  21. if account, ok := another.(*MemoryAccount); ok {
  22. return a.Key == account.Key
  23. }
  24. return false
  25. }