chore: refine comments in bittorrent.go

Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
This commit is contained in:
iosmanthus 2024-05-22 16:29:28 +08:00
parent a00b1e06f4
commit f97687e85f
No known key found for this signature in database
GPG Key ID: DEE5BAABFE092169

View File

@ -11,7 +11,7 @@ import (
"github.com/sagernet/sing-box/constant"
)
// BitTorrent detects if the input stream is a BitTorrent connection.
// BitTorrent detects if the stream is a BitTorrent connection.
// For the BitTorrent protocol specification, see https://www.bittorrent.org/beps/bep_0003.html
func BitTorrent(_ context.Context, reader io.Reader) (*adapter.InboundContext, error) {
var first byte
@ -38,12 +38,12 @@ func BitTorrent(_ context.Context, reader io.Reader) (*adapter.InboundContext, e
}, nil
}
// UTP detects if the input packet is a uTP connection header.
// UTP detects if the packet is a uTP connection packet.
// For the uTP protocol specification, see
// 1. https://www.bittorrent.org/beps/bep_0029.html
// 2. https://github.com/bittorrent/libutp/blob/2b364cbb0650bdab64a5de2abb4518f9f228ec44/utp_internal.cpp#L112
func UTP(_ context.Context, packet []byte) (*adapter.InboundContext, error) {
// A valid UTP must be at least 20 bytes long.
// A valid uTP packet must be at least 20 bytes long.
if len(packet) < 20 {
return nil, os.ErrInvalid
}