1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-30 05:56:54 -05:00

Make isAEAD more efficient

This commit is contained in:
RPRX 2020-09-21 03:20:04 +00:00 committed by GitHub
parent 470dc8523b
commit 010fbf4d8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,6 @@ package outbound
import ( import (
"context" "context"
"os"
"time" "time"
"v2ray.com/core" "v2ray.com/core"
@ -31,7 +30,6 @@ type Handler struct {
serverList *protocol.ServerList serverList *protocol.ServerList
serverPicker protocol.ServerPicker serverPicker protocol.ServerPicker
policyManager policy.Manager policyManager policy.Manager
aead_disabled bool
} }
// New creates a new VMess outbound handler. // New creates a new VMess outbound handler.
@ -52,10 +50,6 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),
} }
if disabled, _ := os.LookupEnv("V2RAY_VMESS_AEAD_DISABLED"); disabled == "true" {
handler.aead_disabled = true
}
return handler, nil return handler, nil
} }
@ -120,7 +114,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
output := link.Writer output := link.Writer
isAEAD := false isAEAD := false
if !h.aead_disabled && len(account.AlterIDs) == 0 { if !aead_disabled && len(account.AlterIDs) == 0 {
isAEAD = true isAEAD = true
} }
@ -185,6 +179,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
var ( var (
enablePadding = false enablePadding = false
aead_disabled = false
) )
func shouldEnablePadding(s protocol.SecurityType) bool { func shouldEnablePadding(s protocol.SecurityType) bool {
@ -197,8 +192,14 @@ func init() {
})) }))
const defaultFlagValue = "NOT_DEFINED_AT_ALL" const defaultFlagValue = "NOT_DEFINED_AT_ALL"
paddingValue := platform.NewEnvFlag("v2ray.vmess.padding").GetValue(func() string { return defaultFlagValue }) paddingValue := platform.NewEnvFlag("v2ray.vmess.padding").GetValue(func() string { return defaultFlagValue })
if paddingValue != defaultFlagValue { if paddingValue != defaultFlagValue {
enablePadding = true enablePadding = true
} }
aeadDisabled := platform.NewEnvFlag("v2ray.vmess.aead.disabled").GetValue(func() string { return defaultFlagValue })
if aeadDisabled == "true" {
aead_disabled = true
}
} }