sniffing

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 35 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ProtoHTTP = "http"
	ProtoTLS  = "tls"
	ProtoSSH  = "ssh"
)
View Source
const (
	DefaultReadTimeout = 30 * time.Second

	// DefaultBodySize is the default HTTP body or websocket frame size to record.
	DefaultBodySize = 64 * 1024 // 64KB
	// MaxBodySize is the maximum HTTP body or websocket frame size to record.
	MaxBodySize = 1024 * 1024 // 1MB
	// DeafultSampleRate is the default websocket sample rate (samples per second).
	DefaultSampleRate = 10.0
)

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

type HandleOption func(opts *HandleOptions)

func WithBypass

func WithBypass(bypass bypass.Bypass) HandleOption

func WithDial

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

func WithDialTLS

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

func WithLog

func WithLog(log logger.Logger) HandleOption

type HandleOptions

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

type Sniffer

type Sniffer struct {
	Websocket           bool
	WebsocketSampleRate float64

	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

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

func (*Sniffer) HandleTLS

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

Jump to

Keyboard shortcuts

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