You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Xray-core/proxy/vmess/account.go

51 lines
1.4 KiB

4 years ago
package vmess
import (
"strings"
4 years ago
"github.com/xtls/xray-core/common/protocol"
"github.com/xtls/xray-core/common/uuid"
4 years ago
)
// 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
4 years ago
}
// 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, newError("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
}
4 years ago
return &MemoryAccount{
ID: protoID,
Security: a.SecuritySettings.GetSecurityType(),
AuthenticatedLengthExperiment: AuthenticatedLength,
NoTerminationSignal: NoTerminationSignal,
4 years ago
}, nil
}