From 77a38dfcfcf944e497023fd2375031859d00e88c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sat, 28 May 2022 22:51:35 +0800 Subject: [PATCH] Update readfrom0 usage --- go.mod | 2 +- go.sum | 4 ++-- none.go | 4 ++-- shadowaead/protocol.go | 3 ++- shadowaead/service.go | 3 ++- shadowaead_2022/protocol.go | 3 ++- shadowaead_2022/service.go | 4 ++-- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index e670822..9acccb8 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/sagernet/sing-shadowsocks go 1.18 require ( - github.com/sagernet/sing v0.0.0-20220528022605-7ba6439364fa + github.com/sagernet/sing v0.0.0-20220528143524-3c8df0a57c72 golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e lukechampine.com/blake3 v1.1.7 ) diff --git a/go.sum b/go.sum index 69a7820..83637db 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.12 h1:p9dKCg8i4gmOxtv35DvrYoWqYzQrvEVdjQ762Y0OqZE= github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= -github.com/sagernet/sing v0.0.0-20220528022605-7ba6439364fa h1:h6VfxGy7dxiLn65xilHfETBYuA3UiS//iHCs0YZldnc= -github.com/sagernet/sing v0.0.0-20220528022605-7ba6439364fa/go.mod h1:w2HnJzXKHpD6F5Z/9XlSD4qbcpHY2RSZuQnFzqgELMg= +github.com/sagernet/sing v0.0.0-20220528143524-3c8df0a57c72 h1:A/kpbNaEg7ISgADmVV036rrkmng2sQU2AP1gJqnRVhE= +github.com/sagernet/sing v0.0.0-20220528143524-3c8df0a57c72/go.mod h1:w2HnJzXKHpD6F5Z/9XlSD4qbcpHY2RSZuQnFzqgELMg= golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= diff --git a/none.go b/none.go index a3613cd..a1085e0 100644 --- a/none.go +++ b/none.go @@ -12,7 +12,6 @@ import ( "github.com/sagernet/sing/common/bufio" M "github.com/sagernet/sing/common/metadata" N "github.com/sagernet/sing/common/network" - "github.com/sagernet/sing/common/rw" "github.com/sagernet/sing/common/udpnat" ) @@ -72,6 +71,7 @@ func (c *noneConn) clientHandshake() error { return nil } +// TODO: add write buffer support func (c *noneConn) Write(b []byte) (n int, err error) { if c.handshake { return c.Conn.Write(b) @@ -97,7 +97,7 @@ func (c *noneConn) ReadFrom(r io.Reader) (n int64, err error) { c.access.Lock() if !c.handshake { c.access.Unlock() - return rw.ReadFrom0(c, r) + return bufio.ReadFrom0(c, r) } c.access.Unlock() } diff --git a/shadowaead/protocol.go b/shadowaead/protocol.go index 3682ccf..20ab017 100644 --- a/shadowaead/protocol.go +++ b/shadowaead/protocol.go @@ -11,6 +11,7 @@ import ( "github.com/sagernet/sing-shadowsocks" "github.com/sagernet/sing/common" "github.com/sagernet/sing/common/buf" + "github.com/sagernet/sing/common/bufio" E "github.com/sagernet/sing/common/exceptions" M "github.com/sagernet/sing/common/metadata" N "github.com/sagernet/sing/common/network" @@ -272,7 +273,7 @@ func (c *clientConn) Write(p []byte) (n int, err error) { func (c *clientConn) ReadFrom(r io.Reader) (n int64, err error) { if c.writer == nil { - return rw.ReadFrom0(c, r) + return bufio.ReadFrom0(c, r) } return c.writer.ReadFrom(r) } diff --git a/shadowaead/service.go b/shadowaead/service.go index 82a9bd6..b3e1ccf 100644 --- a/shadowaead/service.go +++ b/shadowaead/service.go @@ -12,6 +12,7 @@ import ( "github.com/sagernet/sing-shadowsocks" "github.com/sagernet/sing/common" "github.com/sagernet/sing/common/buf" + "github.com/sagernet/sing/common/bufio" E "github.com/sagernet/sing/common/exceptions" M "github.com/sagernet/sing/common/metadata" N "github.com/sagernet/sing/common/network" @@ -175,7 +176,7 @@ func (c *serverConn) Write(p []byte) (n int, err error) { func (c *serverConn) ReadFrom(r io.Reader) (n int64, err error) { if c.writer == nil { - return rw.ReadFrom0(c, r) + return bufio.ReadFrom0(c, r) } return c.writer.ReadFrom(r) } diff --git a/shadowaead_2022/protocol.go b/shadowaead_2022/protocol.go index cef8cd2..927ad01 100644 --- a/shadowaead_2022/protocol.go +++ b/shadowaead_2022/protocol.go @@ -22,6 +22,7 @@ import ( "github.com/sagernet/sing-shadowsocks/shadowaead_2022/wg_replay" "github.com/sagernet/sing/common" "github.com/sagernet/sing/common/buf" + "github.com/sagernet/sing/common/bufio" E "github.com/sagernet/sing/common/exceptions" M "github.com/sagernet/sing/common/metadata" N "github.com/sagernet/sing/common/network" @@ -407,7 +408,7 @@ func (c *clientConn) Write(p []byte) (n int, err error) { func (c *clientConn) ReadFrom(r io.Reader) (n int64, err error) { if c.writer == nil { - return rw.ReadFrom0(c, r) + return bufio.ReadFrom0(c, r) } return c.writer.ReadFrom(r) } diff --git a/shadowaead_2022/service.go b/shadowaead_2022/service.go index 9f2636f..d255bc5 100644 --- a/shadowaead_2022/service.go +++ b/shadowaead_2022/service.go @@ -20,12 +20,12 @@ import ( "github.com/sagernet/sing-shadowsocks/shadowaead_2022/wg_replay" "github.com/sagernet/sing/common" "github.com/sagernet/sing/common/buf" + "github.com/sagernet/sing/common/bufio" "github.com/sagernet/sing/common/cache" E "github.com/sagernet/sing/common/exceptions" M "github.com/sagernet/sing/common/metadata" N "github.com/sagernet/sing/common/network" "github.com/sagernet/sing/common/replay" - "github.com/sagernet/sing/common/rw" "github.com/sagernet/sing/common/udpnat" "golang.org/x/crypto/chacha20poly1305" ) @@ -293,7 +293,7 @@ func (c *serverConn) Write(p []byte) (n int, err error) { func (c *serverConn) ReadFrom(r io.Reader) (n int64, err error) { if c.writer == nil { - return rw.ReadFrom0(c, r) + return bufio.ReadFrom0(c, r) } return c.writer.ReadFrom(r) }