1
0
mirror of https://github.com/MetaCubeX/mihomo.git synced 2025-09-19 12:06:01 +08:00

fix: vision on vless encryption

This commit is contained in:
wwqgtxx
2025-08-18 09:34:20 +08:00
parent 03f4513f61
commit 0f76fdf4c5
2 changed files with 8 additions and 12 deletions

View File

@ -57,7 +57,7 @@ type ClientConn struct {
nonce []byte
peerAead cipher.AEAD
peerNonce []byte
PeerCache []byte
input bytes.Reader // peerCache
}
func (i *ClientInstance) Init(nfsEKeyBytes []byte, xor uint32, minutes time.Duration) (err error) {
@ -232,10 +232,8 @@ func (c *ClientConn) Read(b []byte) (int, error) {
c.peerAead = NewAead(ClientCipher, c.baseKey, peerRandomHello, c.random)
c.peerNonce = make([]byte, 12)
}
if len(c.PeerCache) != 0 {
n := copy(b, c.PeerCache)
c.PeerCache = c.PeerCache[n:]
return n, nil
if c.input.Len() > 0 {
return c.input.Read(b)
}
h, t, l, err := ReadAndDecodeHeader(c.Conn) // l: 17~17000
if err != nil {
@ -265,7 +263,7 @@ func (c *ClientConn) Read(b []byte) (int, error) {
return 0, err
}
if len(dst) > len(b) {
c.PeerCache = dst[copy(b, dst):]
c.input.Reset(dst[copy(b, dst):])
dst = b // for len(dst)
}
return len(dst), nil

View File

@ -40,7 +40,7 @@ type ServerConn struct {
peerRandom []byte
peerAead cipher.AEAD
peerNonce []byte
PeerCache []byte
input bytes.Reader // peerCache
aead cipher.AEAD
nonce []byte
}
@ -224,10 +224,8 @@ func (c *ServerConn) Read(b []byte) (int, error) {
c.peerAead = NewAead(c.cipher, c.baseKey, c.peerRandom, c.ticket)
c.peerNonce = make([]byte, 12)
}
if len(c.PeerCache) != 0 {
n := copy(b, c.PeerCache)
c.PeerCache = c.PeerCache[n:]
return n, nil
if c.input.Len() > 0 {
return c.input.Read(b)
}
h, t, l, err := ReadAndDecodeHeader(c.Conn) // l: 17~17000
if err != nil {
@ -257,7 +255,7 @@ func (c *ServerConn) Read(b []byte) (int, error) {
return 0, err
}
if len(dst) > len(b) {
c.PeerCache = dst[copy(b, dst):]
c.input.Reset(dst[copy(b, dst):])
dst = b // for len(dst)
}
return len(dst), nil