File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
transport/vless/encryption Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ type CommonConn struct {
23
23
PreWrite []byte
24
24
GCM * GCM
25
25
PeerGCM * GCM
26
- PeerCache [] byte
26
+ input bytes. Reader // PeerCache
27
27
}
28
28
29
29
func (c * CommonConn ) Write (b []byte ) (int , error ) {
@@ -72,10 +72,8 @@ func (c *CommonConn) Read(b []byte) (int, error) {
72
72
xorConn .PeerCTR = NewCTR (c .UnitedKey , serverRandom [16 :])
73
73
}
74
74
}
75
- if len (c .PeerCache ) != 0 {
76
- n := copy (b , c .PeerCache )
77
- c .PeerCache = c .PeerCache [n :]
78
- return n , nil
75
+ if c .input .Len () > 0 {
76
+ return c .input .Read (b )
79
77
}
80
78
h , l , err := ReadAndDecodeHeader (c .Conn ) // l: 17~17000
81
79
if err != nil {
@@ -110,7 +108,7 @@ func (c *CommonConn) Read(b []byte) (int, error) {
110
108
return 0 , err
111
109
}
112
110
if len (dst ) > len (b ) {
113
- c .PeerCache = dst [copy (b , dst ):]
111
+ c .input . Reset ( dst [copy (b , dst ):])
114
112
dst = b // for len(dst)
115
113
}
116
114
return len (dst ), nil
You can’t perform that action at this time.
0 commit comments