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:
@ -57,7 +57,7 @@ type ClientConn struct {
|
|||||||
nonce []byte
|
nonce []byte
|
||||||
peerAead cipher.AEAD
|
peerAead cipher.AEAD
|
||||||
peerNonce []byte
|
peerNonce []byte
|
||||||
PeerCache []byte
|
input bytes.Reader // peerCache
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ClientInstance) Init(nfsEKeyBytes []byte, xor uint32, minutes time.Duration) (err error) {
|
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.peerAead = NewAead(ClientCipher, c.baseKey, peerRandomHello, c.random)
|
||||||
c.peerNonce = make([]byte, 12)
|
c.peerNonce = make([]byte, 12)
|
||||||
}
|
}
|
||||||
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, t, l, err := ReadAndDecodeHeader(c.Conn) // l: 17~17000
|
h, t, l, err := ReadAndDecodeHeader(c.Conn) // l: 17~17000
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -265,7 +263,7 @@ func (c *ClientConn) 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
|
||||||
|
@ -40,7 +40,7 @@ type ServerConn struct {
|
|||||||
peerRandom []byte
|
peerRandom []byte
|
||||||
peerAead cipher.AEAD
|
peerAead cipher.AEAD
|
||||||
peerNonce []byte
|
peerNonce []byte
|
||||||
PeerCache []byte
|
input bytes.Reader // peerCache
|
||||||
aead cipher.AEAD
|
aead cipher.AEAD
|
||||||
nonce []byte
|
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.peerAead = NewAead(c.cipher, c.baseKey, c.peerRandom, c.ticket)
|
||||||
c.peerNonce = make([]byte, 12)
|
c.peerNonce = make([]byte, 12)
|
||||||
}
|
}
|
||||||
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, t, l, err := ReadAndDecodeHeader(c.Conn) // l: 17~17000
|
h, t, l, err := ReadAndDecodeHeader(c.Conn) // l: 17~17000
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -257,7 +255,7 @@ func (c *ServerConn) 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
|
||||||
|
Reference in New Issue
Block a user