probe

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Timeout    time.Duration
	SNI        string
	HostHeader string
	Path       string
	Rounds     int // 总测试次数,默认6
	SkipFirst  int // 跳过前N次,默认1(跳过第1次握手)
}

type DownloadConfig

type DownloadConfig struct {
	Timeout  time.Duration
	Bytes    int64
	SNI      string
	HostName string
	Path     string
	// CustomURL indicates the user supplied a custom download URL.
	// When true, the Path is used as-is (no "?bytes=N" appended).
	CustomURL bool
}

type DownloadProber

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

func NewDownloadProber

func NewDownloadProber(cfg DownloadConfig) *DownloadProber

func (*DownloadProber) Download

func (p *DownloadProber) Download(ctx context.Context, ip netip.Addr) DownloadResult

type DownloadResult

type DownloadResult struct {
	IP      netip.Addr `json:"ip"`
	OK      bool       `json:"ok"`
	Status  int        `json:"status"`
	Error   string     `json:"error,omitempty"`
	Bytes   int64      `json:"bytes"`
	TotalMS int64      `json:"total_ms"`
	Mbps    float64    `json:"mbps"`
	When    time.Time  `json:"when"`
}

type Prober

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

func NewProber

func NewProber(cfg Config) *Prober

NewProber creates a reusable, direct-connection (no proxy) prober.

func (*Prober) ProbeHTTPTrace

func (p *Prober) ProbeHTTPTrace(ctx context.Context, ip netip.Addr) Result

ProbeHTTPTrace probes https://<ip>/<path> with SNI/HostHeader. This is a convenience wrapper that calls probeOnce for backward compatibility.

func (*Prober) ProbeHTTPTraceMulti added in v0.2.1

func (p *Prober) ProbeHTTPTraceMulti(ctx context.Context, ip netip.Addr) Result

ProbeHTTPTraceMulti performs multiple probes and returns the average of rounds after skipping the first N. This avoids the TCP/TLS handshake overhead in the first request and provides more stable latency measurements.

type Result

type Result struct {
	IP        netip.Addr        `json:"ip"`
	OK        bool              `json:"ok"`
	Status    int               `json:"status"`
	Error     string            `json:"error,omitempty"`
	ConnectMS int64             `json:"connect_ms"`
	TLSMS     int64             `json:"tls_ms"`
	TTFBMS    int64             `json:"ttfb_ms"`
	TotalMS   int64             `json:"total_ms"`
	Trace     map[string]string `json:"trace,omitempty"`
	When      time.Time         `json:"when"`
}

Jump to

Keyboard shortcuts

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