2022-12-03 13:04:14 +00:00
|
|
|
package shadowsocks_2022
|
|
|
|
|
|
|
|
import (
|
2024-11-03 04:25:23 +00:00
|
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
|
2022-12-03 13:04:14 +00:00
|
|
|
"github.com/xtls/xray-core/common/protocol"
|
|
|
|
)
|
|
|
|
|
|
|
|
// MemoryAccount is an account type converted from Account.
|
|
|
|
type MemoryAccount struct {
|
|
|
|
Key string
|
|
|
|
}
|
|
|
|
|
|
|
|
// AsAccount implements protocol.AsAccount.
|
2024-11-03 04:25:23 +00:00
|
|
|
func (u *Account) AsAccount() (protocol.Account, error) {
|
2022-12-03 13:04:14 +00:00
|
|
|
return &MemoryAccount{
|
|
|
|
Key: u.GetKey(),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Equals implements protocol.Account.Equals().
|
|
|
|
func (a *MemoryAccount) Equals(another protocol.Account) bool {
|
|
|
|
if account, ok := another.(*MemoryAccount); ok {
|
|
|
|
return a.Key == account.Key
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2024-11-03 04:25:23 +00:00
|
|
|
|
|
|
|
func (a *MemoryAccount) ToProto() proto.Message {
|
|
|
|
return &Account{
|
|
|
|
Key: a.Key,
|
|
|
|
}
|
|
|
|
}
|