From ebbaadcae06b5d6defce767f5cdd5d002bdfa58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 26 Jul 2022 11:16:21 +0800 Subject: [PATCH] Update buffer usage --- go.mod | 2 +- go.sum | 4 ++-- none.go | 2 +- shadowaead/service.go | 2 +- shadowaead_2022/relay.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 6765d91..d38a5e2 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-20220717063925-00f98eb6bc34 + github.com/sagernet/sing v0.0.0-20220726034811-bc109486f14e golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d lukechampine.com/blake3 v1.1.7 ) diff --git a/go.sum b/go.sum index 0d37356..9b14d15 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-20220717063925-00f98eb6bc34 h1:1kFruA2QzuH2R6txJXEDSasfdxzsjNyzC4Z1kZjMkHg= -github.com/sagernet/sing v0.0.0-20220717063925-00f98eb6bc34/go.mod h1:GbtQfZSpmtD3cXeD1qX2LCMwY8dH+bnnInDTqd92IsM= +github.com/sagernet/sing v0.0.0-20220726034811-bc109486f14e h1:5lfrAc+vSv0iW6eHGNLyHC+a/k6BDGJvYxYxwB/68Kk= +github.com/sagernet/sing v0.0.0-20220726034811-bc109486f14e/go.mod h1:GbtQfZSpmtD3cXeD1qX2LCMwY8dH+bnnInDTqd92IsM= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= diff --git a/none.go b/none.go index 776727a..92555b6 100644 --- a/none.go +++ b/none.go @@ -121,7 +121,7 @@ type nonePacketConn struct { } func (c *nonePacketConn) ReadPacket(buffer *buf.Buffer) (M.Socksaddr, error) { - _, err := buffer.ReadFrom(c) + _, err := buffer.ReadOnceFrom(c) if err != nil { return M.Socksaddr{}, err } diff --git a/shadowaead/service.go b/shadowaead/service.go index af58c84..693c218 100644 --- a/shadowaead/service.go +++ b/shadowaead/service.go @@ -85,7 +85,7 @@ func (s *Service) newConnection(ctx context.Context, conn net.Conn, metadata M.M header := common.Dup(_header) defer header.Release() - _, err := header.ReadFrom(conn) + _, err := header.ReadOnceFrom(conn) if err != nil { return E.Cause(err, "read header") } else if !header.IsFull() { diff --git a/shadowaead_2022/relay.go b/shadowaead_2022/relay.go index 529ffeb..c2ae39f 100644 --- a/shadowaead_2022/relay.go +++ b/shadowaead_2022/relay.go @@ -147,7 +147,7 @@ func (s *RelayService[U]) newConnection(ctx context.Context, conn net.Conn, meta defer common.KeepAlive(_requestHeader) requestHeader := common.Dup(_requestHeader) defer requestHeader.Release() - n, err := requestHeader.ReadFrom(conn) + n, err := requestHeader.ReadOnceFrom(conn) if err != nil { return err } else if int(n) < s.keySaltLength+aes.BlockSize {