sniffer.go 518 B

123456789101112131415161718192021222324252627282930313233343536
  1. package sniffer
  2. import "github.com/metacubex/mihomo/constant"
  3. type Sniffer interface {
  4. SupportNetwork() constant.NetWork
  5. // SniffData must not change input bytes
  6. SniffData(bytes []byte) (string, error)
  7. Protocol() string
  8. SupportPort(port uint16) bool
  9. }
  10. const (
  11. TLS Type = iota
  12. HTTP
  13. QUIC
  14. )
  15. var (
  16. List = []Type{TLS, HTTP, QUIC}
  17. )
  18. type Type int
  19. func (rt Type) String() string {
  20. switch rt {
  21. case TLS:
  22. return "TLS"
  23. case HTTP:
  24. return "HTTP"
  25. case QUIC:
  26. return "QUIC"
  27. default:
  28. return "Unknown"
  29. }
  30. }