outbound

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: AGPL-3.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const DirectHandlerTag = "direct"
View Source
const DnsHandlerTag = "dns"

Variables

View Source
var ErrIpv6NotSupported = errors.New("ipv6 not supported")

Functions

func GetAllProxyhandlers

func GetAllProxyhandlers(om i.OutboundManager) []i.Outbound

return all handlers except direct and dns

func NewHandler

func NewHandler(config *HandlerConfig) (i.Outbound, error)

func NewOutHandler

func NewOutHandler(config *Config) (i.Outbound, error)

TODO: Validate config

Types

type ChainHandler

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

func NewChainHandler

func NewChainHandler(config *ChainHandlerConfig) (*ChainHandler, error)

func (*ChainHandler) HandleFlow

func (c *ChainHandler) HandleFlow(ctx context.Context, dst net.Destination, rw buf.ReaderWriter) error

func (*ChainHandler) HandlePacketConn

func (c *ChainHandler) HandlePacketConn(ctx context.Context, dst net.Destination, p udp.PacketReaderWriter) error

func (*ChainHandler) Tag

func (c *ChainHandler) Tag() string

type ChainHandlerConfig

type ChainHandlerConfig struct {
	*configs.ChainHandlerConfig
	Policy                      *policy.Policy
	IPResolver                  i.IPResolver
	DF                          transport.DialerFactory
	IPResolverForRequestAddress i.IPResolver
	// used to lookup ech config
	DnsServer  i.ECHResolver
	RejectQuic bool
}

type Config

type Config struct {
	*configs.OutboundHandlerConfig
	DialerFactory transport.DialerFactory
	Policy        i.TimeoutSetting
	// some outbound require it to lookup server addresses
	IPResolver i.IPResolver
	// some outbounds need it to lookup ips of request addresses
	IPResolverForRequestAddress i.IPResolver
	//
	RejectQuic bool
}

type HandlerConfig

type HandlerConfig struct {
	*configs.HandlerConfig
	DialerFactory transport.DialerFactory
	Policy        *policy.Policy
	// for node domain
	IPResolver                  i.IPResolver
	IPResolverForRequestAddress i.IPResolver
	DnsServer                   i.ECHResolver
	RejectQuic                  bool
}

type HandlerObserver

type HandlerObserver interface {
	OnHandlerChanged()
}

type HandlerWithStats

type HandlerWithStats struct {
	i.Outbound
	Stats *OutboundHandlerStats
}

func (*HandlerWithStats) GetHandlerStats

func (i *HandlerWithStats) GetHandlerStats() *OutboundHandlerStats

type HandlerWithSupport6Info

type HandlerWithSupport6Info struct {
	i.Outbound
	util.IPv6SupportChangeNotifier
	// contains filtered or unexported fields
}

func (*HandlerWithSupport6Info) SetSupport6

func (h *HandlerWithSupport6Info) SetSupport6(support6 bool)

func (*HandlerWithSupport6Info) Support6

func (h *HandlerWithSupport6Info) Support6() bool

type Manager

type Manager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

holds all outbound handlers. notify its listeners when a change happens.

func NewManager

func NewManager() *Manager

func (*Manager) AddHandlerObserver

func (m *Manager) AddHandlerObserver(o HandlerObserver)

func (*Manager) AddHandlers

func (m *Manager) AddHandlers(handlers ...i.Outbound) error

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) GetAllHandlers

func (m *Manager) GetAllHandlers() []i.Outbound

func (*Manager) GetHandler

func (m *Manager) GetHandler(tag string) i.Outbound

func (*Manager) RemoveHandlerObserver

func (m *Manager) RemoveHandlerObserver(observer HandlerObserver)

func (*Manager) RemoveHandlers

func (m *Manager) RemoveHandlers(tags []string) error

func (*Manager) ReplaceHandlers

func (m *Manager) ReplaceHandlers(handlers ...i.Outbound) error

replace all proxy handlers with new ones

func (*Manager) Start

func (m *Manager) Start() error

type OnHandlerChangedFunc

type OnHandlerChangedFunc func()

func (OnHandlerChangedFunc) OnHandlerChanged

func (f OnHandlerChangedFunc) OnHandlerChanged()

type OutStats

type OutStats struct {
	sync.Mutex
	Map map[string]*OutboundHandlerStats
}

func NewOutStats

func NewOutStats() *OutStats

func (*OutStats) CleanOldStats

func (o *OutStats) CleanOldStats()

func (*OutStats) Get

func (o *OutStats) Get(tag string) *OutboundHandlerStats

type OutboundHandlerStats

type OutboundHandlerStats struct {
	UpCounter   atomic.Uint64
	DownCounter atomic.Uint64
	Throughput  atomic.Uint64
	Ping        atomic.Uint64
	Time        atomic.Value
}

func NewHandlerStats

func NewHandlerStats(throughput uint64, ping uint64) *OutboundHandlerStats

func (*OutboundHandlerStats) AddPing

func (s *OutboundHandlerStats) AddPing(v uint64)

func (*OutboundHandlerStats) AddThroughput

func (s *OutboundHandlerStats) AddThroughput(v uint64)

type ProxyHandler

type ProxyHandler struct {
	i.Handler
	// contains filtered or unexported fields
}

implement outbound.ProxyHandler and transport.Dialer

func NewProxyHandler

func NewProxyHandler(settings ProxyHandlerSettings) *ProxyHandler

func (*ProxyHandler) Close

func (h *ProxyHandler) Close() error

func (*ProxyHandler) HandleFlow

func (h *ProxyHandler) HandleFlow(ctx context.Context, dst net.Destination, rw buf.ReaderWriter) error

func (*ProxyHandler) HandlePacketConn

func (h *ProxyHandler) HandlePacketConn(ctx context.Context, dst net.Destination,
	rw udp.PacketReaderWriter) error

func (*ProxyHandler) Start

func (h *ProxyHandler) Start() error

func (*ProxyHandler) Tag

func (h *ProxyHandler) Tag() string

type ProxyHandlerSettings

type ProxyHandlerSettings struct {
	Tag       string
	Handler   i.Handler
	Uot       bool
	EnableMux bool
	MuxConfig mux.ClientStrategy
}

type RandomPortSelector

type RandomPortSelector struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewRandomPortSelector

func NewRandomPortSelector(ranges []*net.PortRange) *RandomPortSelector

func (*RandomPortSelector) SelectPort

func (s *RandomPortSelector) SelectPort() uint16

randomly select one enabled port from the list

Jump to

Keyboard shortcuts

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