yiguodev
2026-07-10 02:56:49 +00:00
committed by GitHub
parent c18b39ed80
commit d5bc58dc6b
15 changed files with 241 additions and 52 deletions
+11 -8
View File
@@ -5,6 +5,7 @@ import (
"crypto/hmac"
"crypto/sha256"
"hash/crc64"
"sync/atomic"
"time"
"github.com/xtls/xray-core/common"
@@ -218,10 +219,17 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
return nil
}
var enablePadding = false
var enablePadding atomic.Bool
func shouldEnablePadding(s protocol.SecurityType) bool {
return enablePadding || s == protocol.SecurityType_AES128_GCM || s == protocol.SecurityType_CHACHA20_POLY1305 || s == protocol.SecurityType_AUTO
return enablePadding.Load() || s == protocol.SecurityType_AES128_GCM || s == protocol.SecurityType_CHACHA20_POLY1305 || s == protocol.SecurityType_AUTO
}
func reloadEnvSettings() error {
const defaultFlagValue = "NOT_DEFINED_AT_ALL"
paddingValue := platform.NewEnvFlag(platform.UseVmessPadding).GetValue(func() string { return defaultFlagValue })
enablePadding.Store(paddingValue != defaultFlagValue)
return nil
}
func init() {
@@ -229,10 +237,5 @@ func init() {
return New(ctx, config.(*Config))
}))
const defaultFlagValue = "NOT_DEFINED_AT_ALL"
paddingValue := platform.NewEnvFlag(platform.UseVmessPadding).GetValue(func() string { return defaultFlagValue })
if paddingValue != defaultFlagValue {
enablePadding = true
}
platform.RegisterEnvReload(reloadEnvSettings)
}