2022-12-03 15:04:14 +02:00
|
|
|
package shadowsocks_2022
|
|
|
|
|
|
|
|
import (
|
2024-11-03 06:25:23 +02:00
|
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
|
2022-12-03 15:04:14 +02:00
|
|
|
"github.com/xtls/xray-core/common/protocol"
|
|
|
|
)
|
|
|
|
|
|
|
|
// MemoryAccount is an account type converted from Account.
|
|
|
|
type MemoryAccount struct {
|
2024-11-09 13:16:11 +02:00
|
|
|
Key string
|
2022-12-03 15:04:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// AsAccount implements protocol.AsAccount.
|
2024-11-03 06:25:23 +02:00
|
|
|
func (u *Account) AsAccount() (protocol.Account, error) {
|
2022-12-03 15:04:14 +02:00
|
|
|
return &MemoryAccount{
|
2024-11-09 13:16:11 +02:00
|
|
|
Key: u.GetKey(),
|
2022-12-03 15:04:14 +02:00
|
|
|
}, 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 06:25:23 +02:00
|
|
|
|
|
|
|
func (a *MemoryAccount) ToProto() proto.Message {
|
|
|
|
return &Account{
|
|
|
|
Key: a.Key,
|
|
|
|
}
|
|
|
|
}
|