| 1234567891011121314151617181920212223242526272829303132 |
- package bittorrent
- import (
- "errors"
- "v2ray.com/core"
- )
- type SniffHeader struct {
- }
- func (h *SniffHeader) Protocol() string {
- return "bittorrent"
- }
- func (h *SniffHeader) Domain() string {
- return ""
- }
- var errNotBittorrent = errors.New("not bittorrent header")
- func SniffBittorrent(b []byte) (*SniffHeader, error) {
- if len(b) < 20 {
- return nil, core.ErrNoClue
- }
- if b[0] == 19 && string(b[1:20]) == "BitTorrent protocol" {
- return &SniffHeader{}, nil
- }
- return nil, errNotBittorrent
- }
|