schedialer

package module
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 6 Imported by: 1

README

schedialer

A dial scheduler, which will select the best dialer to dial according to the score calculated by the plugin

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddAndDelPlugin

type AddAndDelPlugin interface {
	Plugin
	OnAdd(ctx context.Context, proxy *Proxy) error
	OnDel(ctx context.Context, proxy *Proxy) error
}

type ComparisonScorePlugin

type ComparisonScorePlugin interface {
	Plugin
	ComparisonScore(ctx context.Context, target *Target, proxies []*Proxy) ([]int, error)
}

type Dialer

type Dialer interface {
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

type Feedback

type Feedback struct {
	Successful bool
	Error      error
}

type FeedbackPlugin

type FeedbackPlugin interface {
	Plugin
	Feedback(ctx context.Context, target *Target, proxy *Proxy, feedback *Feedback)
}

type FilterPlugin

type FilterPlugin interface {
	Plugin
	Filter(ctx context.Context, target *Target, proxy *Proxy) bool
}

type Plugin

type Plugin interface {
	Name() string
}

type Plugins

type Plugins struct {
	AddAndDelPlugins       []AddAndDelPlugin
	FilterPlugins          []FilterPlugin
	ComparisonScorePlugins []ComparisonScorePlugin
	ScorePlugins           []ScorePlugin
	FeedbackPlugins        []FeedbackPlugin
	Proxies                map[string]*Proxy
}

func NewPlugins

func NewPlugins(plugins ...Plugin) *Plugins

func (*Plugins) AddProxy

func (m *Plugins) AddProxy(ctx context.Context, proxy *Proxy) error

func (*Plugins) DelProxy

func (m *Plugins) DelProxy(ctx context.Context, proxy *Proxy) error

func (*Plugins) Feedback

func (m *Plugins) Feedback(ctx context.Context, target *Target, proxy *Proxy, feedback *Feedback)

func (*Plugins) Ranking added in v0.2.0

func (m *Plugins) Ranking(ctx context.Context, target *Target) ([]*Proxy, error)

func (*Plugins) Register

func (m *Plugins) Register(plugins ...Plugin)

type Proxy

type Proxy struct {
	Name   string
	IP     net.IP
	Port   int
	Dialer Dialer

	Aver    func() uint64
	MaxAver func() uint64

	Total func() uint64
}

func (*Proxy) String

func (p *Proxy) String() string

type Schedialer

type Schedialer struct {
	Plugins     *Plugins
	Resolver    *net.Resolver
	DialTimeout time.Duration
}

func NewSchedialer

func NewSchedialer(plugins *Plugins) *Schedialer

func (*Schedialer) DialContext

func (s *Schedialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

func (*Schedialer) Ranking added in v0.2.0

func (s *Schedialer) Ranking(ctx context.Context, network, address string) ([]*Proxy, error)

type ScorePlugin

type ScorePlugin interface {
	Plugin
	Score(ctx context.Context, target *Target, proxy *Proxy) (int, error)
}

type Target

type Target struct {
	Address string
	IPs     []net.IP
	Port    int
}

Directories

Path Synopsis
plugins

Jump to

Keyboard shortcuts

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