selector

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: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDbFilter

func NewDbFilter(db Db, filterConfig *configs.SelectorConfig_Filter,
	landHandlers []*xsqlite.OutboundHandler, createHandler CreateHandlerFunc) *dbFilter

func NewOmFilter

func NewOmFilter(filterConfig *configs.SelectorConfig_Filter, om *outbound.Manager) *omFilter

func TestHandler6

func TestHandler6(ctx context.Context, s Tester, item outHandler)

func TestHandlerPing

func TestHandlerPing(ctx context.Context, s Tester, item outHandler)

func TestHandlerSpeed

func TestHandlerSpeed(ctx context.Context, s Tester, item outHandler)

func TestHandlerUsable

func TestHandlerUsable(ctx context.Context, s Tester, item outHandler)

used to test unusable handlers

Types

type Balancer

type Balancer interface {
	GetHandler(*session.Info) i.Outbound
	UpdateHandlers(handlers []i.HandlerWith6Info)
	Support6() bool
}

type CreateHandlerFunc

type CreateHandlerFunc func(h *configs.HandlerConfig, landHandlerIds []*xsqlite.OutboundHandler) (i.Outbound, error)

type Db

type Db interface {
	GetAllHandlers() ([]*xsqlite.OutboundHandler, error)
	GetHandlersByGroup(group string) ([]*xsqlite.OutboundHandler, error)
	GetBatchedHandlers(batchSize int, offset int) ([]*xsqlite.OutboundHandler, error)
	GetHandler(id int) *xsqlite.OutboundHandler
}

type Filter

type Filter interface {
	GetHandlers() ([]outHandler, error)
}

type HandlerErrorChangeSubject

type HandlerErrorChangeSubject interface {
	AddHandlerErrorObserver(observer i.HandlerErrorObserver)
	RemoveHandlerErrorObserver(observer i.HandlerErrorObserver)
}

type HandlersBeingUsedUpdate

type HandlersBeingUsedUpdate func([]string)

type MemoryBalancer

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

func NewMemoryBalancer

func NewMemoryBalancer() *MemoryBalancer

func (*MemoryBalancer) GetHandler

func (b *MemoryBalancer) GetHandler(info *session.Info) i.Outbound

func (*MemoryBalancer) Support6

func (b *MemoryBalancer) Support6() bool

func (*MemoryBalancer) UpdateHandlers

func (b *MemoryBalancer) UpdateHandlers(handlers []i.HandlerWith6Info)

type RandomBanlancer

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

func NewRandomBanlancer

func NewRandomBanlancer() *RandomBanlancer

func (*RandomBanlancer) GetHandler

func (b *RandomBanlancer) GetHandler(info *session.Info) i.Outbound

func (*RandomBanlancer) Support6

func (b *RandomBanlancer) Support6() bool

func (*RandomBanlancer) UpdateHandlers

func (b *RandomBanlancer) UpdateHandlers(handlers []i.HandlerWith6Info)

type Selector

type Selector struct {
	util.IPv6SupportChangeNotifier

	LandHandlers []*xsqlite.OutboundHandler
	// contains filtered or unexported fields
}

func NewSelector

func NewSelector(config SelectorConfig) *Selector

func (*Selector) Close

func (s *Selector) Close() error

func (*Selector) GetHandler

func (s *Selector) GetHandler(info *session.Info) i.Outbound

func (*Selector) Load

func (s *Selector) Load()

func (*Selector) OnHandlerChanged

func (s *Selector) OnHandlerChanged()

func (*Selector) OnHandlerError

func (s *Selector) OnHandlerError(tag string, err error)

func (*Selector) OnHandlerSpeedChanged

func (s *Selector) OnHandlerSpeedChanged(tag string, speed int32)

func (*Selector) Start

func (s *Selector) Start() error

func (*Selector) Tag

func (s *Selector) Tag() string

func (*Selector) TestAllUnusable

func (s *Selector) TestAllUnusable() error

func (*Selector) TestPingAll

func (s *Selector) TestPingAll() error

func (*Selector) TestSpeedAll

func (s *Selector) TestSpeedAll() error

func (*Selector) UpdateBalancer

func (s *Selector) UpdateBalancer(balancer Balancer)

func (*Selector) UpdateFilter

func (s *Selector) UpdateFilter(filter Filter)

type SelectorConfig

type SelectorConfig struct {
	*configs.SelectorConfig
	CreateHandler             CreateHandlerFunc
	HandlerErrorChangeSubject HandlerErrorChangeSubject
	Tester                    Tester
	Database                  Db
	OutboundManager           *outbound.Manager
	OnHandlerBeingUsedChange  HandlersBeingUsedUpdate
	LandHandlers              []*xsqlite.OutboundHandler
}

type Selectors

type Selectors struct {

	// notify listeners when any selector's ipv6 support changed or any selector is added or removed
	i.IPv6SupportChangeSubject
	// contains filtered or unexported fields
}

func NewSelectors

func NewSelectors() *Selectors

func (*Selectors) AddSelector

func (s *Selectors) AddSelector(selector *Selector)

func (*Selectors) Close

func (s *Selectors) Close() error

func (*Selectors) GetAllSelectors

func (s *Selectors) GetAllSelectors() []*Selector

func (*Selectors) GetSelector

func (s *Selectors) GetSelector(tag string) *Selector

func (*Selectors) OnHandlerChanged

func (s *Selectors) OnHandlerChanged()

func (*Selectors) OnHandlerSpeedChanged

func (s *Selectors) OnHandlerSpeedChanged(tag string, speed int32)

func (*Selectors) OnIPv6SupportChanged

func (s *Selectors) OnIPv6SupportChanged()

func (*Selectors) RemoveAllSelectors

func (s *Selectors) RemoveAllSelectors()

func (*Selectors) RemoveSelector

func (s *Selectors) RemoveSelector(tag string)

func (*Selectors) Start

func (s *Selectors) Start() error

type Tester

type Tester interface {
	TestSpeed(context.Context, i.Outbound, bool) int64
	TestUsable(context.Context, i.Outbound, bool) bool
	TestIPv6(context.Context, i.Outbound) bool
	TestPing(context.Context, i.Outbound) int
}

Jump to

Keyboard shortcuts

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