github.com/xraypb/Xray-core@v1.8.1/proxy/shadowsocks_2022/config.go (about)

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