2022-05-02 00:46:24 +00:00
|
|
|
package sniffer
|
|
|
|
|
|
|
|
import "github.com/Dreamacro/clash/constant"
|
2022-04-09 14:30:36 +00:00
|
|
|
|
|
|
|
type Sniffer interface {
|
2022-05-02 00:46:24 +00:00
|
|
|
SupportNetwork() constant.NetWork
|
2022-04-09 14:30:36 +00:00
|
|
|
SniffTCP(bytes []byte) (string, error)
|
|
|
|
Protocol() string
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
2022-05-02 00:46:24 +00:00
|
|
|
TLS Type = iota
|
|
|
|
HTTP
|
2022-04-09 14:30:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2022-05-02 00:46:24 +00:00
|
|
|
List = []Type{TLS, HTTP}
|
2022-04-09 14:30:36 +00:00
|
|
|
)
|
|
|
|
|
2022-05-02 00:46:24 +00:00
|
|
|
type Type int
|
2022-04-09 14:30:36 +00:00
|
|
|
|
2022-05-02 00:46:24 +00:00
|
|
|
func (rt Type) String() string {
|
2022-04-09 14:30:36 +00:00
|
|
|
switch rt {
|
|
|
|
case TLS:
|
|
|
|
return "TLS"
|
2022-05-01 21:10:18 +00:00
|
|
|
case HTTP:
|
|
|
|
return "HTTP"
|
2022-04-09 14:30:36 +00:00
|
|
|
default:
|
|
|
|
return "Unknown"
|
|
|
|
}
|
|
|
|
}
|