2022-05-02 08:46:24 +08:00
|
|
|
package sniffer
|
|
|
|
|
|
|
|
import "github.com/Dreamacro/clash/constant"
|
2022-04-09 22:30:36 +08:00
|
|
|
|
|
|
|
type Sniffer interface {
|
2022-05-02 08:46:24 +08:00
|
|
|
SupportNetwork() constant.NetWork
|
2023-10-19 23:51:37 +08:00
|
|
|
// SniffData must not change input bytes
|
2023-10-19 18:30:20 +08:00
|
|
|
SniffData(bytes []byte) (string, error)
|
2022-04-09 22:30:36 +08:00
|
|
|
Protocol() string
|
2023-01-23 13:16:25 +08:00
|
|
|
SupportPort(port uint16) bool
|
2022-04-09 22:30:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
2022-05-02 08:46:24 +08:00
|
|
|
TLS Type = iota
|
|
|
|
HTTP
|
2023-10-19 18:30:20 +08:00
|
|
|
QUIC
|
2022-04-09 22:30:36 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2023-10-19 18:30:20 +08:00
|
|
|
List = []Type{TLS, HTTP, QUIC}
|
2022-04-09 22:30:36 +08:00
|
|
|
)
|
|
|
|
|
2022-05-02 08:46:24 +08:00
|
|
|
type Type int
|
2022-04-09 22:30:36 +08:00
|
|
|
|
2022-05-02 08:46:24 +08:00
|
|
|
func (rt Type) String() string {
|
2022-04-09 22:30:36 +08:00
|
|
|
switch rt {
|
|
|
|
case TLS:
|
|
|
|
return "TLS"
|
2022-05-02 05:10:18 +08:00
|
|
|
case HTTP:
|
|
|
|
return "HTTP"
|
2023-10-19 18:30:20 +08:00
|
|
|
case QUIC:
|
|
|
|
return "QUIC"
|
2022-04-09 22:30:36 +08:00
|
|
|
default:
|
|
|
|
return "Unknown"
|
|
|
|
}
|
|
|
|
}
|