Help us shape the future of Go! Take the 2026 Go Developer Survey

group

package
v0.0.166 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAllOutboundsFailed = errors.New("all outbounds failed")

ErrAllOutboundsFailed is returned by MutableURLTest.DialContext and MutableURLTest.ListenPacket after every attempted outbound has failed.

Functions

func NewFallback

func NewFallback(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.FallbackOutboundOptions) (adapter.Outbound, error)

NewFallback creates a new Fallback outbound adapter.

func NewMutableAutoSelect

func NewMutableAutoSelect(ctx context.Context, _ A.Router, logger log.ContextLogger, tag string, options option.MutableAutoSelectOutboundOptions) (A.Outbound, error)

func NewMutableSelector

func NewMutableSelector(ctx context.Context, router A.Router, logger log.ContextLogger, tag string, options option.MutableSelectorOutboundOptions) (A.Outbound, error)

func NewMutableURLTest

func NewMutableURLTest(ctx context.Context, _ A.Router, logger log.ContextLogger, tag string, options option.MutableURLTestOutboundOptions) (A.Outbound, error)

func RegisterFallback

func RegisterFallback(registry *outbound.Registry)

func RegisterMutableAutoSelect

func RegisterMutableAutoSelect(registry *outbound.Registry)

func RegisterMutableSelector

func RegisterMutableSelector(registry *outbound.Registry)

func RegisterMutableURLTest

func RegisterMutableURLTest(registry *outbound.Registry)

Types

type Fallback

type Fallback struct {
	outbound.Adapter
	// contains filtered or unexported fields
}

Fallback is an outbound adapter that attempts to use a primary outbound, and falls back to a secondary outbound if the primary fails.

func (*Fallback) DialContext

func (d *Fallback) DialContext(ctx context.Context, network string, destination metadata.Socksaddr) (net.Conn, error)

DialContext attempts to dial using the primary outbound. If it fails, it falls back to the fallback outbound.

func (*Fallback) ListenPacket

func (d *Fallback) ListenPacket(ctx context.Context, destination metadata.Socksaddr) (net.PacketConn, error)

ListenPacket attempts to create a packet connection using the primary outbound. If it fails, it falls back to the fallback outbound.

func (*Fallback) Start

func (d *Fallback) Start() error

Start checks that both the primary and fallback outbounds are available.

type MutableAutoSelect

type MutableAutoSelect struct {
	outbound.Adapter
	// contains filtered or unexported fields
}

MutableAutoSelect is the client-side server-selection group.

func (*MutableAutoSelect) Add

func (s *MutableAutoSelect) Add(tags ...string) (n int, err error)

func (*MutableAutoSelect) All

func (s *MutableAutoSelect) All() []string

func (*MutableAutoSelect) CheckOutbounds

func (s *MutableAutoSelect) CheckOutbounds()

func (*MutableAutoSelect) Close

func (s *MutableAutoSelect) Close() error

func (*MutableAutoSelect) DialContext

func (s *MutableAutoSelect) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error)

func (*MutableAutoSelect) ExhaustionSignal

func (s *MutableAutoSelect) ExhaustionSignal() <-chan struct{}

ExhaustionSignal returns a receive-only channel that emits when every candidate fails within a ladder's budget. Buffers one pending signal; an unread signal is replaced by the next ladder's emission. Closed on group Close so range-loop consumers terminate cleanly.

func (*MutableAutoSelect) InterfaceUpdated

func (s *MutableAutoSelect) InterfaceUpdated()

func (*MutableAutoSelect) ListenPacket

func (s *MutableAutoSelect) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error)

func (*MutableAutoSelect) NewConnectionEx

func (s *MutableAutoSelect) NewConnectionEx(ctx context.Context, conn net.Conn, metadata A.InboundContext, onClose N.CloseHandlerFunc)

func (*MutableAutoSelect) NewPacketConnectionEx

func (s *MutableAutoSelect) NewPacketConnectionEx(ctx context.Context, conn N.PacketConn, metadata A.InboundContext, onClose N.CloseHandlerFunc)

func (*MutableAutoSelect) Now

func (s *MutableAutoSelect) Now() string

Now reports the most recent dial-time selection, TCP preferred, UDP fallback. Single representative tag for telemetry; not a per-network route — TCP and UDP select independently at dial time.

func (*MutableAutoSelect) PostStart

func (s *MutableAutoSelect) PostStart() error

PostStart is idempotent: a second invocation is a no-op rather than a duplicate background loop.

func (*MutableAutoSelect) Remove

func (s *MutableAutoSelect) Remove(tags ...string) (n int, err error)

func (*MutableAutoSelect) SetURLOverrides

func (s *MutableAutoSelect) SetURLOverrides(overrides map[string]string)

SetURLOverrides replaces per-member callback URL overrides. Changed or removed overrides keep history and mark probe results stale.

func (*MutableAutoSelect) Start

func (s *MutableAutoSelect) Start() error

Start resolves every configured tag to an outbound atomically: a missing tag aborts without partially populating s.members.

func (*MutableAutoSelect) URLTest

func (s *MutableAutoSelect) URLTest(ctx context.Context) (map[string]uint16, error)

URLTest implements sing-box's URLTestGroup contract: probes every member in parallel and returns delay_ms per success. Used by the offline pre-warm path before Start, so members are resolved lazily from the outbound manager when not already loaded.

type MutableSelector

type MutableSelector struct {
	outbound.Adapter
	// contains filtered or unexported fields
}

func (*MutableSelector) Add

func (s *MutableSelector) Add(tags ...string) (n int, err error)

Add adds the given outbound tags to the group and returns the number of outbounds added. If an outbound tag already exists, it will be ignored.

func (*MutableSelector) All

func (s *MutableSelector) All() []string

func (*MutableSelector) DialContext

func (s *MutableSelector) DialContext(ctx context.Context, network string, destination metadata.Socksaddr) (net.Conn, error)

func (*MutableSelector) ListenPacket

func (s *MutableSelector) ListenPacket(ctx context.Context, destination metadata.Socksaddr) (net.PacketConn, error)

func (*MutableSelector) Network

func (s *MutableSelector) Network() []string

func (*MutableSelector) NewConnectionEx

func (s *MutableSelector) NewConnectionEx(ctx context.Context, conn net.Conn, metadata A.InboundContext, onClose network.CloseHandlerFunc)

func (*MutableSelector) NewPacketConnectionEx

func (s *MutableSelector) NewPacketConnectionEx(ctx context.Context, conn network.PacketConn, metadata A.InboundContext, onClose network.CloseHandlerFunc)

func (*MutableSelector) Now

func (s *MutableSelector) Now() string

func (*MutableSelector) Remove

func (s *MutableSelector) Remove(tags ...string) (n int, err error)

Remove removes the given outbound tags from the group and returns the number of outbounds removed. A random outbound will be selected if the currently selected outbound is removed.

func (*MutableSelector) SelectOutbound

func (s *MutableSelector) SelectOutbound(tag string) bool

func (*MutableSelector) Start

func (s *MutableSelector) Start() error

type MutableURLTest

type MutableURLTest struct {
	outbound.Adapter
	// contains filtered or unexported fields
}

func (*MutableURLTest) Add

func (s *MutableURLTest) Add(tags ...string) (n int, err error)

Add adds the given outbound tags to the group and returns the number of outbounds added. If an outbound tag already exists, it will be ignored.

func (*MutableURLTest) All

func (s *MutableURLTest) All() []string

func (*MutableURLTest) CheckOutbounds

func (s *MutableURLTest) CheckOutbounds()

func (*MutableURLTest) Close

func (s *MutableURLTest) Close() error

func (*MutableURLTest) DialContext

func (s *MutableURLTest) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error)

func (*MutableURLTest) InterfaceUpdated

func (s *MutableURLTest) InterfaceUpdated()

func (*MutableURLTest) ListenPacket

func (s *MutableURLTest) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error)

func (*MutableURLTest) NewConnectionEx

func (s *MutableURLTest) NewConnectionEx(ctx context.Context, conn net.Conn, metadata A.InboundContext, onClose N.CloseHandlerFunc)

func (*MutableURLTest) NewPacketConnectionEx

func (s *MutableURLTest) NewPacketConnectionEx(ctx context.Context, conn N.PacketConn, metadata A.InboundContext, onClose N.CloseHandlerFunc)

func (*MutableURLTest) Now

func (s *MutableURLTest) Now() string

func (*MutableURLTest) PostStart

func (s *MutableURLTest) PostStart() error

func (*MutableURLTest) Remove

func (s *MutableURLTest) Remove(tags ...string) (n int, err error)

Remove removes the given outbound tags from the group and returns the number of outbounds removed.

func (*MutableURLTest) SetURLOverrides

func (s *MutableURLTest) SetURLOverrides(overrides map[string]string)

SetURLOverrides replaces the per-outbound URL override map used during URL testing.

func (*MutableURLTest) Start

func (s *MutableURLTest) Start() error

func (*MutableURLTest) URLTest

func (s *MutableURLTest) URLTest(ctx context.Context) (map[string]uint16, error)

Jump to

Keyboard shortcuts

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