sniffer

package
v1.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTP1 version = iota
	HTTP2
)

Variables

View Source
var (
	ErrorUnsupportedSniffer = errors.New("unsupported sniffer")
	ErrorSniffFailed        = errors.New("all sniffer failed")
	ErrNoClue               = errors.New("not enough information for making a decision")
)

Functions

func IsValidTLSVersion

func IsValidTLSVersion(major, minor byte) bool

func NewSniffer

func NewSniffer(name sniffer.Type, snifferConfig SnifferConfig) (sniffer.Sniffer, error)

func ReadClientHello

func ReadClientHello(data []byte) (*string, error)

ReadClientHello returns server name (if any) from TLS client hello message. https://github.com/golang/go/blob/master/src/crypto/tls/handshake_messages.go#L300

func SniffHTTP

func SniffHTTP(b []byte) (*string, error)

func SniffTLS

func SniffTLS(b []byte) (*string, error)

Types

type BaseSniffer

type BaseSniffer struct {
	// contains filtered or unexported fields
}

func NewBaseSniffer

func NewBaseSniffer(ports utils.IntRanges[uint16], networkType constant.NetWork) *BaseSniffer

func (*BaseSniffer) Protocol

func (*BaseSniffer) Protocol() string

Protocol implements sniffer.Sniffer

func (*BaseSniffer) SniffData

func (*BaseSniffer) SniffData(bytes []byte) (string, error)

SniffData implements sniffer.Sniffer

func (*BaseSniffer) SupportNetwork

func (bs *BaseSniffer) SupportNetwork() constant.NetWork

SupportNetwork implements sniffer.Sniffer

func (*BaseSniffer) SupportPort

func (bs *BaseSniffer) SupportPort(port uint16) bool

SupportPort implements sniffer.Sniffer

type Config added in v1.18.8

type Config struct {
	Enable          bool
	Sniffers        map[sniffer.Type]SnifferConfig
	ForceDomain     []C.DomainMatcher
	SkipSrcAddress  []C.IpMatcher
	SkipDstAddress  []C.IpMatcher
	SkipDomain      []C.DomainMatcher
	ForceDnsMapping bool
	ParsePureIp     bool
}

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

func NewDispatcher added in v1.18.8

func NewDispatcher(snifferConfig *Config) (*Dispatcher, error)

func (*Dispatcher) Enable added in v1.18.8

func (sd *Dispatcher) Enable() bool

func (*Dispatcher) TCPSniff added in v1.18.8

func (sd *Dispatcher) TCPSniff(conn *N.BufferedConn, metadata *C.Metadata) bool

TCPSniff returns true if the connection is sniffed to have a domain

func (*Dispatcher) UDPSniff added in v1.18.8

func (sd *Dispatcher) UDPSniff(packet C.PacketAdapter) bool

type HTTPSniffer

type HTTPSniffer struct {
	*BaseSniffer
	// contains filtered or unexported fields
}

func NewHTTPSniffer

func NewHTTPSniffer(snifferConfig SnifferConfig) (*HTTPSniffer, error)

func (*HTTPSniffer) Protocol

func (http *HTTPSniffer) Protocol() string

func (*HTTPSniffer) SniffData

func (http *HTTPSniffer) SniffData(bytes []byte) (string, error)

func (*HTTPSniffer) SupportNetwork

func (http *HTTPSniffer) SupportNetwork() C.NetWork

type QuicSniffer

type QuicSniffer struct {
	*BaseSniffer
}

func NewQuicSniffer

func NewQuicSniffer(snifferConfig SnifferConfig) (*QuicSniffer, error)

func (QuicSniffer) Protocol

func (quic QuicSniffer) Protocol() string

func (QuicSniffer) SniffData

func (quic QuicSniffer) SniffData(b []byte) (string, error)

func (QuicSniffer) SupportNetwork

func (quic QuicSniffer) SupportNetwork() C.NetWork

type SnifferConfig

type SnifferConfig struct {
	OverrideDest bool
	Ports        utils.IntRanges[uint16]
}

type TLSSniffer

type TLSSniffer struct {
	*BaseSniffer
}

func NewTLSSniffer

func NewTLSSniffer(snifferConfig SnifferConfig) (*TLSSniffer, error)

func (*TLSSniffer) Protocol

func (tls *TLSSniffer) Protocol() string

func (*TLSSniffer) SniffData

func (tls *TLSSniffer) SniffData(bytes []byte) (string, error)

func (*TLSSniffer) SupportNetwork

func (tls *TLSSniffer) SupportNetwork() C.NetWork

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL