Documentation
¶
Index ¶
- Constants
- Variables
- func AppendJSONString(b []byte, s string) []byte
- func AppendProxiesJSON(b []byte, proxies map[string]C.Proxy) ([]byte, error)
- func AppendProxyJSON(b []byte, proxy C.Proxy) ([]byte, error)
- func AppendProxySummaryJSON(b []byte, proxy C.Proxy) ([]byte, error)
- func BuildLibraryNode(mapping map[string]any, options ...ProxyOption) (outbound.ProxyAdapter, string, error)
- func ClashHealthCounts(list C.ProxyList) (alive, dead int)
- func ClashMappingNodeName(mapping map[string]any) (string, bool)
- func ClashNodeName(value any) (string, bool)
- func ClashObserveParsedProxies(observer func(outbound.ProxyAdapter)) (stop func())
- func CountBuilds(count func()) (restore func())
- func HeldProxy(proxy C.Proxy) C.Proxy
- func IsBackgroundProbe(ctx context.Context) bool
- func IsLibraryNode(proxy C.Proxy) bool
- func LibraryNodeConfig(mapping map[string]any) (string, error)
- func NodeConfigMapping(proxy C.Proxy) (mapping map[string]any, ok bool, err error)
- func NodeHasRecord(proxy C.Proxy) bool
- func NodeKeepsBuilt(proxyType string) bool
- func NodeLibraryProxies(library *outbound.NodeLibrary, options ...ProxyOption) []C.Proxy
- func ParseProxy(mapping map[string]any, options ...ProxyOption) (C.Proxy, error)
- func PinnedProxy(proxy C.Proxy) C.Proxy
- func SetNodeCatalog(on bool) (previous bool)
- func SetNodeCatalogDirectory(dir string)
- func SetURLTestAdmission(f func(ctx context.Context) error)
- func SetURLTestFinished(f func(ctx context.Context, proxy *Proxy))
- func SetURLTestGate(f func(ctx context.Context) (func(), error))
- func WithBackgroundProbe(ctx context.Context) context.Context
- func WithURLTestTimeout(ctx context.Context, timeout time.Duration) context.Context
- func WriteProxiesJSON(w io.Writer, proxies map[string]C.Proxy, library C.ProxyLibrary) error
- func WriteProxiesJSONPage(w io.Writer, proxies map[string]C.Proxy, library C.ProxyLibrary, after string, ...) (string, error)
- func WriteProxiesJSONPageFunc(w io.Writer, proxies map[string]C.Proxy, library C.ProxyLibrary, after string, ...) (string, error)
- type DelayRecords
- type LibraryNodes
- func (l *LibraryNodes) At(i int) C.Proxy
- func (l *LibraryNodes) Group(name string) ([]uint32, bool)
- func (l *LibraryNodes) Len() int
- func (l *LibraryNodes) LiveCount() int
- func (l *LibraryNodes) Lookup(name string) (C.Proxy, bool)
- func (l *LibraryNodes) Proxies() []C.Proxy
- func (l *LibraryNodes) RangeLive(f func(C.Proxy) bool)
- func (l *LibraryNodes) Rank(name string) int
- func (l *LibraryNodes) Sorted() C.ProxyList
- func (l *LibraryNodes) Sweep()
- type NodeCatalogSession
- type Proxy
- func (p *Proxy) Adapter() C.ProxyAdapter
- func (p *Proxy) AliveForTestUrl(url string) bool
- func (p *Proxy) AppendURLDelays(dst []URLDelay) []URLDelay
- func (p *Proxy) DelayHistory() []C.DelayHistory
- func (p *Proxy) DelayHistoryForTestUrl(url string) []C.DelayHistory
- func (p *Proxy) DialContext(ctx context.Context, metadata *C.Metadata) (C.Conn, error)
- func (p *Proxy) ExtraDelayHistories() map[string]C.ProxyState
- func (p *Proxy) LastDelay() (record C.DelayHistory, ok bool)
- func (p *Proxy) LastDelayForTestUrl(url string) (delay uint16)
- func (p *Proxy) LastURLTestRecord(url string) (record C.DelayHistory, alive bool, expected string, ok bool)
- func (p *Proxy) ListenPacketContext(ctx context.Context, metadata *C.Metadata) (C.PacketConn, error)
- func (p *Proxy) MarshalJSON() ([]byte, error)
- func (p *Proxy) URLTest(ctx context.Context, url string, expectedStatus utils.IntRanges[uint16]) (t uint16, err error)
- func (p *Proxy) URLTestOutcome(ctx context.Context, url string, expectedStatus utils.IntRanges[uint16]) (URLTestOutcome, error)
- type ProxyOption
- type URLDelay
- type URLTestFailure
- type URLTestOutcome
- type URLTestOutcomeProvider
Constants ¶
const ( URLTestFailureTimeout = "timeout" URLTestFailureCanceled = "canceled" URLTestFailureStatus = "status" URLTestFailureUnknown = "unknown" )
Variables ¶
var ErrNotLibraryNode = fmt.Errorf("the node stays in the configuration's proxies")
var ErrURLTestDeferred = errors.New("url test deferred: memory admission")
var UnifiedDelay = atomic.NewBool(false)
Functions ¶
func AppendJSONString ¶
func AppendProxiesJSON ¶
func BuildLibraryNode ¶
func BuildLibraryNode(mapping map[string]any, options ...ProxyOption) (outbound.ProxyAdapter, string, error)
func ClashHealthCounts ¶
func ClashNodeName ¶
func ClashObserveParsedProxies ¶
func ClashObserveParsedProxies(observer func(outbound.ProxyAdapter)) (stop func())
func CountBuilds ¶
func CountBuilds(count func()) (restore func())
func IsBackgroundProbe ¶
func IsLibraryNode ¶
func NodeConfigMapping ¶
func NodeHasRecord ¶
func NodeKeepsBuilt ¶
func NodeLibraryProxies ¶
func NodeLibraryProxies(library *outbound.NodeLibrary, options ...ProxyOption) []C.Proxy
func ParseProxy ¶
func SetNodeCatalog ¶
func SetNodeCatalogDirectory ¶
func SetNodeCatalogDirectory(dir string)
func SetURLTestAdmission ¶
func SetURLTestFinished ¶
func SetURLTestGate ¶
func WithURLTestTimeout ¶
func WriteProxiesJSON ¶
func WriteProxiesJSONPage ¶
Types ¶
type DelayRecords ¶
type DelayRecords interface {
LastDelay() (C.DelayHistory, bool)
AppendURLDelays(dst []URLDelay) []URLDelay
}
type LibraryNodes ¶
type LibraryNodes struct {
// contains filtered or unexported fields
}
func NewLibraryNodes ¶
func NewLibraryNodes(library *outbound.NodeLibrary, options ...ProxyOption) *LibraryNodes
func (*LibraryNodes) Len ¶
func (l *LibraryNodes) Len() int
func (*LibraryNodes) LiveCount ¶
func (l *LibraryNodes) LiveCount() int
func (*LibraryNodes) Proxies ¶
func (l *LibraryNodes) Proxies() []C.Proxy
func (*LibraryNodes) Rank ¶
func (l *LibraryNodes) Rank(name string) int
func (*LibraryNodes) Sorted ¶
func (l *LibraryNodes) Sorted() C.ProxyList
func (*LibraryNodes) Sweep ¶
func (l *LibraryNodes) Sweep()
type NodeCatalogSession ¶
type NodeCatalogSession struct {
// contains filtered or unexported fields
}
func NewNodeCatalogSession ¶
func NewNodeCatalogSession() *NodeCatalogSession
func (*NodeCatalogSession) Seal ¶
func (s *NodeCatalogSession) Seal() error
func (*NodeCatalogSession) Stored ¶
func (s *NodeCatalogSession) Stored() (bytes int, mapped bool)
type Proxy ¶
type Proxy struct {
C.ProxyAdapter
// contains filtered or unexported fields
}
func NewProxy ¶
func NewProxy(adapter C.ProxyAdapter) *Proxy
func (*Proxy) AliveForTestUrl ¶
AliveForTestUrl implements C.Proxy
func (*Proxy) AppendURLDelays ¶
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 ¶
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 ¶
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 (*Proxy) ListenPacketContext ¶
func (p *Proxy) ListenPacketContext(ctx context.Context, metadata *C.Metadata) (C.PacketConn, error)
ListenPacketContext implements C.ProxyAdapter
func (*Proxy) MarshalJSON ¶
MarshalJSON implements C.ProxyAdapter
type ProxyOption ¶
type ProxyOption func(opt *proxyOption)
func WithDialerForAPI ¶
func WithDialerForAPI(dialer C.Dialer) ProxyOption
func WithNodeCatalogSession ¶
func WithNodeCatalogSession(session *NodeCatalogSession) ProxyOption
func WithProviderName ¶
func WithProviderName(name string) ProxyOption
func WithTunnelForAPI ¶
func WithTunnelForAPI(tunnel C.Tunnel) ProxyOption
type URLTestFailure ¶
func ClassifyURLTestFailure ¶
func ClassifyURLTestFailure(err error, satisfied bool, status int) *URLTestFailure