1
0
mirror of https://github.com/MetaCubeX/mihomo.git synced 2025-09-19 20:15:59 +08:00

fix: vision on vless encryption

This commit is contained in:
wwqgtxx
2025-08-24 09:48:07 +08:00
parent 1ae050ca3b
commit e3d9a8e2fd

View File

@ -23,7 +23,7 @@ type CommonConn struct {
PreWrite []byte PreWrite []byte
GCM *GCM GCM *GCM
PeerGCM *GCM PeerGCM *GCM
PeerCache []byte input bytes.Reader // PeerCache
} }
func (c *CommonConn) Write(b []byte) (int, error) { func (c *CommonConn) Write(b []byte) (int, error) {
@ -72,10 +72,8 @@ func (c *CommonConn) Read(b []byte) (int, error) {
xorConn.PeerCTR = NewCTR(c.UnitedKey, serverRandom[16:]) xorConn.PeerCTR = NewCTR(c.UnitedKey, serverRandom[16:])
} }
} }
if len(c.PeerCache) != 0 { if c.input.Len() > 0 {
n := copy(b, c.PeerCache) return c.input.Read(b)
c.PeerCache = c.PeerCache[n:]
return n, nil
} }
h, l, err := ReadAndDecodeHeader(c.Conn) // l: 17~17000 h, l, err := ReadAndDecodeHeader(c.Conn) // l: 17~17000
if err != nil { if err != nil {
@ -110,7 +108,7 @@ func (c *CommonConn) Read(b []byte) (int, error) {
return 0, err return 0, err
} }
if len(dst) > len(b) { if len(dst) > len(b) {
c.PeerCache = dst[copy(b, dst):] c.input.Reset(dst[copy(b, dst):])
dst = b // for len(dst) dst = b // for len(dst)
} }
return len(dst), nil return len(dst), nil