mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-06-12 11:29:36 +03:00
v1.0.0
This commit is contained in:
32
common/protocol/bittorrent/bittorrent.go
Normal file
32
common/protocol/bittorrent/bittorrent.go
Normal file
@ -0,0 +1,32 @@
|
||||
package bittorrent
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/xtls/xray-core/v1/common"
|
||||
)
|
||||
|
||||
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, common.ErrNoClue
|
||||
}
|
||||
|
||||
if b[0] == 19 && string(b[1:20]) == "BitTorrent protocol" {
|
||||
return &SniffHeader{}, nil
|
||||
}
|
||||
|
||||
return nil, errNotBittorrent
|
||||
}
|
Reference in New Issue
Block a user