sniffer

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: GPL-3.0 Imports: 23 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 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 SnifferDispatcher

type SnifferDispatcher struct {
	// contains filtered or unexported fields
}
var Dispatcher *SnifferDispatcher

func NewCloseSnifferDispatcher

func NewCloseSnifferDispatcher() (*SnifferDispatcher, error)

func NewSnifferDispatcher

func NewSnifferDispatcher(snifferConfig map[sniffer.Type]SnifferConfig,
	forceDomain *trie.DomainSet, skipSNI *trie.DomainSet,
	forceDnsMapping bool, parsePureIp bool) (*SnifferDispatcher, error)

func (*SnifferDispatcher) Enable

func (sd *SnifferDispatcher) Enable() bool

func (*SnifferDispatcher) TCPSniff

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

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

func (*SnifferDispatcher) UDPSniff

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

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