sniffing

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtoHTTP = "http"
	ProtoTLS  = "tls"
	ProtoSSH  = "ssh"
)
View Source
const (
	// Default max body size to record.
	DefaultBodySize = 1024 * 1024 // 1MB
)

Variables

View Source
var (
	DefaultCertPool = tls_util.NewMemoryCertPool()
)

Functions

func Sniff

func Sniff(ctx context.Context, r *bufio.Reader) (proto string, err error)

Types

type HandleOption added in v0.2.1

type HandleOption func(opts *HandleOptions)

func WithBypass added in v0.2.1

func WithBypass(bypass bypass.Bypass) HandleOption

func WithDial added in v0.2.1

func WithDial(dial func(ctx context.Context, network, address string) (net.Conn, error)) HandleOption

func WithDialTLS added in v0.2.1

func WithDialTLS(dialTLS func(ctx context.Context, network, address string, cfg *tls.Config) (net.Conn, error)) HandleOption

func WithLog added in v0.2.1

func WithLog(log logger.Logger) HandleOption

func WithRecorderObject added in v0.2.1

func WithRecorderObject(ro *xrecorder.HandlerRecorderObject) HandleOption

type HandleOptions added in v0.2.1

type HandleOptions struct {
	Dial    func(ctx context.Context, network, address string) (net.Conn, error)
	DialTLS func(ctx context.Context, network, address string, cfg *tls.Config) (net.Conn, error)

	Bypass         bypass.Bypass
	RecorderObject *xrecorder.HandlerRecorderObject
	Log            logger.Logger
}

type Sniffer added in v0.2.0

type Sniffer struct {
	Recorder        recorder.Recorder
	RecorderOptions *recorder.Options

	// MITM TLS termination
	Certificate        *x509.Certificate
	PrivateKey         crypto.PrivateKey
	NegotiatedProtocol string
	CertPool           tls_util.CertPool
	MitmBypass         bypass.Bypass

	ReadTimeout time.Duration
}

func (*Sniffer) HandleHTTP added in v0.2.0

func (h *Sniffer) HandleHTTP(ctx context.Context, conn net.Conn, opts ...HandleOption) error

func (*Sniffer) HandleTLS added in v0.2.0

func (h *Sniffer) HandleTLS(ctx context.Context, conn net.Conn, opts ...HandleOption) error

Jump to

Keyboard shortcuts

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