From 65174fa487d582cb23c764b083122438eebfa8c6 Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Sun, 7 Nov 2021 22:45:36 +0000 Subject: [PATCH] rename buf type adaptor into FromBytes --- common/buf/buffer.go | 4 ++-- common/protocol/bittorrent/bittorrent.go | 2 +- common/protocol/quic/sniff.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/buf/buffer.go b/common/buf/buffer.go index 2db468c49..fe03eb9bb 100644 --- a/common/buf/buffer.go +++ b/common/buf/buffer.go @@ -30,8 +30,8 @@ func New() *Buffer { } } -// As creates a Buffer with an existed bytearray -func As(data []byte) *Buffer { +// FromBytes creates a Buffer with an existed bytearray +func FromBytes(data []byte) *Buffer { return &Buffer{ v: data, end: int32(len(data)), diff --git a/common/protocol/bittorrent/bittorrent.go b/common/protocol/bittorrent/bittorrent.go index b3c8e4ed4..84b151166 100644 --- a/common/protocol/bittorrent/bittorrent.go +++ b/common/protocol/bittorrent/bittorrent.go @@ -40,7 +40,7 @@ func SniffUTP(b []byte) (*SniffHeader, error) { return nil, common.ErrNoClue } - buffer := buf.As(b) + buffer := buf.FromBytes(b) var typeAndVersion uint8 diff --git a/common/protocol/quic/sniff.go b/common/protocol/quic/sniff.go index 58f306dc2..db42e7a28 100644 --- a/common/protocol/quic/sniff.go +++ b/common/protocol/quic/sniff.go @@ -49,7 +49,7 @@ var ( ) func SniffQUIC(b []byte) (*SniffHeader, error) { - buffer := buf.As(b) + buffer := buf.FromBytes(b) typeByte, err := buffer.ReadByte() if err != nil { return nil, errNotQuic @@ -161,7 +161,7 @@ func SniffQUIC(b []byte) (*SniffHeader, error) { if err != nil { return nil, err } - buffer = buf.As(decrypted) + buffer = buf.FromBytes(decrypted) frameType, err := buffer.ReadByte() if err != nil { return nil, io.ErrUnexpectedEOF