mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-05 14:43:03 +00:00
079d0bd8a9
* Refactor log * Add new log methods * Fix logger test * Change all logging code * Clean up pathObj * Rebase to latest main * Remove invoking method name after the dot
52 lines
1.4 KiB
Go
52 lines
1.4 KiB
Go
package vmess
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/xtls/xray-core/common/errors"
|
|
"github.com/xtls/xray-core/common/protocol"
|
|
"github.com/xtls/xray-core/common/uuid"
|
|
)
|
|
|
|
// MemoryAccount is an in-memory form of VMess account.
|
|
type MemoryAccount struct {
|
|
// ID is the main ID of the account.
|
|
ID *protocol.ID
|
|
// Security type of the account. Used for client connections.
|
|
Security protocol.SecurityType
|
|
|
|
AuthenticatedLengthExperiment bool
|
|
NoTerminationSignal bool
|
|
}
|
|
|
|
// Equals implements protocol.Account.
|
|
func (a *MemoryAccount) Equals(account protocol.Account) bool {
|
|
vmessAccount, ok := account.(*MemoryAccount)
|
|
if !ok {
|
|
return false
|
|
}
|
|
return a.ID.Equals(vmessAccount.ID)
|
|
}
|
|
|
|
// AsAccount implements protocol.Account.
|
|
func (a *Account) AsAccount() (protocol.Account, error) {
|
|
id, err := uuid.ParseString(a.Id)
|
|
if err != nil {
|
|
return nil, errors.New("failed to parse ID").Base(err).AtError()
|
|
}
|
|
protoID := protocol.NewID(id)
|
|
var AuthenticatedLength, NoTerminationSignal bool
|
|
if strings.Contains(a.TestsEnabled, "AuthenticatedLength") {
|
|
AuthenticatedLength = true
|
|
}
|
|
if strings.Contains(a.TestsEnabled, "NoTerminationSignal") {
|
|
NoTerminationSignal = true
|
|
}
|
|
return &MemoryAccount{
|
|
ID: protoID,
|
|
Security: a.SecuritySettings.GetSecurityType(),
|
|
AuthenticatedLengthExperiment: AuthenticatedLength,
|
|
NoTerminationSignal: NoTerminationSignal,
|
|
}, nil
|
|
}
|