adapter

package
v1.19.31-hako.2 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	URLTestFailureTimeout  = "timeout"
	URLTestFailureCanceled = "canceled"
	URLTestFailureStatus   = "status"
	URLTestFailureUnknown  = "unknown"
)

Variables

View Source
var ErrURLTestDeferred = errors.New("url test deferred: memory admission")
View Source
var UnifiedDelay = atomic.NewBool(false)

Functions

func IsBackgroundProbe

func IsBackgroundProbe(ctx context.Context) bool

func ParseProxy

func ParseProxy(mapping map[string]any, options ...ProxyOption) (C.Proxy, error)

func SetURLTestAdmission

func SetURLTestAdmission(f func(ctx context.Context) error)

func WithBackgroundProbe

func WithBackgroundProbe(ctx context.Context) context.Context

Types

type Proxy

type Proxy struct {
	C.ProxyAdapter
	// contains filtered or unexported fields
}

func NewProxy

func NewProxy(adapter C.ProxyAdapter) *Proxy

func (*Proxy) Adapter

func (p *Proxy) Adapter() C.ProxyAdapter

Adapter implements C.Proxy

func (*Proxy) AliveForTestUrl

func (p *Proxy) AliveForTestUrl(url string) bool

AliveForTestUrl implements C.Proxy

func (*Proxy) DelayHistory

func (p *Proxy) DelayHistory() []C.DelayHistory

DelayHistory implements C.Proxy

func (*Proxy) DelayHistoryForTestUrl

func (p *Proxy) DelayHistoryForTestUrl(url string) []C.DelayHistory

DelayHistoryForTestUrl implements C.Proxy

func (*Proxy) DialContext

func (p *Proxy) DialContext(ctx context.Context, metadata *C.Metadata) (C.Conn, error)

DialContext implements C.ProxyAdapter

func (*Proxy) ExtraDelayHistories

func (p *Proxy) ExtraDelayHistories() map[string]C.ProxyState

ExtraDelayHistories return all delay histories for each test URL implements C.Proxy

func (*Proxy) LastDelayForTestUrl

func (p *Proxy) LastDelayForTestUrl(url string) (delay uint16)

LastDelayForTestUrl return last history record of the specified URL. if proxy is not alive, return the max value of uint16. implements C.Proxy

func (*Proxy) LastURLTestRecord

func (p *Proxy) LastURLTestRecord(url string) (record C.DelayHistory, alive bool, expected string, ok bool)

func (*Proxy) ListenPacketContext

func (p *Proxy) ListenPacketContext(ctx context.Context, metadata *C.Metadata) (C.PacketConn, error)

ListenPacketContext implements C.ProxyAdapter

func (*Proxy) MarshalJSON

func (p *Proxy) MarshalJSON() ([]byte, error)

MarshalJSON implements C.ProxyAdapter

func (*Proxy) URLTest

func (p *Proxy) URLTest(ctx context.Context, url string, expectedStatus utils.IntRanges[uint16]) (t uint16, err error)

URLTest get the delay for the specified URL implements C.Proxy

func (*Proxy) URLTestOutcome

func (p *Proxy) URLTestOutcome(ctx context.Context, url string, expectedStatus utils.IntRanges[uint16]) (URLTestOutcome, error)

type ProxyOption

type ProxyOption func(opt *proxyOption)

func WithDialerForAPI

func WithDialerForAPI(dialer C.Dialer) ProxyOption

func WithProviderName

func WithProviderName(name string) ProxyOption

func WithTunnelForAPI

func WithTunnelForAPI(tunnel C.Tunnel) ProxyOption

type URLTestFailure

type URLTestFailure struct {
	Kind    string
	Errno   string
	Message string
}

func ClassifyURLTestFailure

func ClassifyURLTestFailure(err error, satisfied bool, status int) *URLTestFailure

type URLTestOutcome

type URLTestOutcome struct {
	Delay      uint16
	Satisfied  bool
	HTTPStatus int
}

type URLTestOutcomeProvider

type URLTestOutcomeProvider interface {
	URLTestOutcome(ctx context.Context, url string, expectedStatus utils.IntRanges[uint16]) (URLTestOutcome, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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