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 {
2323 PreWrite []byte
2424 GCM * GCM
2525 PeerGCM * GCM
26- PeerCache [] byte
26+ input bytes. Reader // PeerCache
2727}
2828
2929func (c * CommonConn ) Write (b []byte ) (int , error ) {
@@ -72,10 +72,8 @@ func (c *CommonConn) Read(b []byte) (int, error) {
7272 xorConn .PeerCTR = NewCTR (c .UnitedKey , serverRandom [16 :])
7373 }
7474 }
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 )
7977 }
8078 h , l , err := ReadAndDecodeHeader (c .Conn ) // l: 17~17000
8179 if err != nil {
@@ -110,7 +108,7 @@ func (c *CommonConn) Read(b []byte) (int, error) {
110108 return 0 , err
111109 }
112110 if len (dst ) > len (b ) {
113- c .PeerCache = dst [copy (b , dst ):]
111+ c .input . Reset ( dst [copy (b , dst ):])
114112 dst = b // for len(dst)
115113 }
116114 return len (dst ), nil
You can’t perform that action at this time.
0 commit comments