0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-06-19 14:48:03 +03:00

VMess AEAD based packet length

(cherry picked from commit 08221600082a79376bdc262f2ffec1a3129ae98d)
This commit is contained in:
Shelikhoo
2021-04-29 06:29:42 +08:00
committed by 世界
parent 5bf2b31883
commit 778876df9e
8 changed files with 232 additions and 6 deletions

View File

@ -1,6 +1,8 @@
package vmess
import (
"strings"
"github.com/xtls/xray-core/common/dice"
"github.com/xtls/xray-core/common/protocol"
"github.com/xtls/xray-core/common/uuid"
@ -14,6 +16,8 @@ type MemoryAccount struct {
AlterIDs []*protocol.ID
// Security type of the account. Used for client connections.
Security protocol.SecurityType
AuthenticatedLengthExperiment bool
}
// AnyValidID returns an ID that is either the main ID or one of the alternative IDs if any.
@ -41,9 +45,14 @@ func (a *Account) AsAccount() (protocol.Account, error) {
return nil, newError("failed to parse ID").Base(err).AtError()
}
protoID := protocol.NewID(id)
var AuthenticatedLength bool
if strings.Contains(a.TestsEnabled, "AuthenticatedLength") {
AuthenticatedLength = true
}
return &MemoryAccount{
ID: protoID,
AlterIDs: protocol.NewAlterIDs(protoID, uint16(a.AlterId)),
Security: a.SecuritySettings.GetSecurityType(),
ID: protoID,
AlterIDs: protocol.NewAlterIDs(protoID, uint16(a.AlterId)),
Security: a.SecuritySettings.GetSecurityType(),
AuthenticatedLengthExperiment: AuthenticatedLength,
}, nil
}