sniffer

package
v0.0.0-...-d0ac596 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: GPL-3.0 Imports: 16 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) SniffTCP

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

SniffTCP 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) SniffTCP

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

func (*HTTPSniffer) SupportNetwork

func (http *HTTPSniffer) 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

type TLSSniffer

type TLSSniffer struct {
	*BaseSniffer
}

func NewTLSSniffer

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

func (*TLSSniffer) Protocol

func (tls *TLSSniffer) Protocol() string

func (*TLSSniffer) SniffTCP

func (tls *TLSSniffer) SniffTCP(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