config.go 682 B

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