VMess inbound: Optimize replay filter (#5562)

And https://github.com/XTLS/Xray-core/pull/5562#issuecomment-3765387903
This commit is contained in:
风扇滑翔翼
2026-01-28 02:34:46 +08:00
committed by GitHub
parent 077070dbe0
commit f6a7e93923
12 changed files with 84 additions and 160 deletions
+2 -21
View File
@@ -5,11 +5,11 @@ import (
"crypto/cipher"
"crypto/md5"
"crypto/sha1"
"google.golang.org/protobuf/proto"
"io"
"google.golang.org/protobuf/proto"
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/antireplay"
"github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/common/crypto"
"github.com/xtls/xray-core/common/errors"
@@ -24,8 +24,6 @@ type MemoryAccount struct {
CipherType CipherType
Key []byte
Password string
replayFilter antireplay.GeneralizedReplayFilter
}
var ErrIVNotUnique = errors.New("IV is not unique")
@@ -42,20 +40,9 @@ func (a *MemoryAccount) ToProto() proto.Message {
return &Account{
CipherType: a.CipherType,
Password: a.Password,
IvCheck: a.replayFilter != nil,
}
}
func (a *MemoryAccount) CheckIV(iv []byte) error {
if a.replayFilter == nil {
return nil
}
if a.replayFilter.Check(iv) {
return nil
}
return ErrIVNotUnique
}
func createAesGcm(key []byte) cipher.AEAD {
return crypto.NewAesGcm(key)
}
@@ -116,12 +103,6 @@ func (a *Account) AsAccount() (protocol.Account, error) {
CipherType: a.CipherType,
Key: passwordToCipherKey([]byte(a.Password), Cipher.KeySize()),
Password: a.Password,
replayFilter: func() antireplay.GeneralizedReplayFilter {
if a.IvCheck {
return antireplay.NewBloomRing()
}
return nil
}(),
}, nil
}