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 {
|
2024-11-09 11:16:11 +00:00
|
|
|
Key string
|
2022-12-03 13:04:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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{
|
2024-11-09 11:16:11 +00:00
|
|
|
Key: u.GetKey(),
|
2022-12-03 13:04:14 +00: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 04:25:23 +00:00
|
|
|
|
|
|
|
func (a *MemoryAccount) ToProto() proto.Message {
|
|
|
|
return &Account{
|
|
|
|
Key: a.Key,
|
|
|
|
}
|
|
|
|
}
|