Update buffer usage

This commit is contained in:
世界 2022-07-26 11:16:21 +08:00
parent 45a2ad9cd4
commit ebbaadcae0
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
5 changed files with 6 additions and 6 deletions

2
go.mod
View file

@ -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
)

4
go.sum
View file

@ -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=

View file

@ -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
}

View file

@ -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() {

View file

@ -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 {