Documentation ¶
Index ¶
- Constants
- Variables
- func BindControl(c syscall.RawConn, lAddrPort netip.AddrPort) error
- func SoMarkControl(c syscall.RawConn, mark int) error
- func TproxyControl(c syscall.RawConn) error
- func TransparentControl(c syscall.RawConn) error
- type AliveDialerSet
- type AliveDialerSetSet
- type Annotation
- type CheckDnsOption
- type CheckDnsOptionRaw
- type CheckOption
- type Dialer
- func (d *Dialer) ActivateCheck()
- func (d *Dialer) Check(opts *CheckOption) (ok bool, err error)
- func (d *Dialer) Clone() *Dialer
- func (d *Dialer) Close() error
- func (d *Dialer) DnsCheck(ctx context.Context, dns netip.AddrPort, network string) (ok bool, err error)
- func (d *Dialer) HttpCheck(ctx context.Context, u *netutils.URL, ip netip.Addr, method string, ...) (ok bool, err error)
- func (d *Dialer) MustGetAlive(typ *NetworkType) bool
- func (d *Dialer) MustGetLatencies10(typ *NetworkType) *LatenciesN
- func (d *Dialer) NotifyCheck()
- func (d *Dialer) Property() *Property
- func (d *Dialer) RegisterAliveDialerSet(a *AliveDialerSet)
- func (d *Dialer) ReportUnavailable(typ *NetworkType, err error)
- func (d *Dialer) UnregisterAliveDialerSet(a *AliveDialerSet)
- type GlobalOption
- type InstanceOption
- type LatenciesN
- type NetworkType
- type Property
- type TcpCheckOption
- type TcpCheckOptionRaw
Constants ¶
View Source
const ( Init = 1 + iota NotAlive )
View Source
const (
AnnotationKey_AddLatency = "add_latency"
)
View Source
const Timeout = 10 * time.Second
Variables ¶
View Source
var ( UnexpectedFieldErr = fmt.Errorf("unexpected field") InvalidParameterErr = fmt.Errorf("invalid parameters") )
Functions ¶
func TproxyControl ¶
func TransparentControl ¶ added in v0.4.0
Types ¶
type AliveDialerSet ¶
type AliveDialerSet struct { CheckTyp *NetworkType // contains filtered or unexported fields }
AliveDialerSet assumes mapping between index and dialer MUST remain unchanged.
It is thread-safe.
func NewAliveDialerSet ¶
func NewAliveDialerSet( log *logrus.Logger, dialerGroupName string, networkType *NetworkType, tolerance time.Duration, selectionPolicy consts.DialerSelectionPolicy, dialers []*Dialer, dialersAnnotations []*Annotation, aliveChangeCallback func(alive bool), setAlive bool, ) *AliveDialerSet
func (*AliveDialerSet) GetMinLatency ¶
func (a *AliveDialerSet) GetMinLatency() (d *Dialer, latency time.Duration)
GetMinLatency acquires correct selectionPolicy.
func (*AliveDialerSet) GetRand ¶
func (a *AliveDialerSet) GetRand() *Dialer
func (*AliveDialerSet) NotifyLatencyChange ¶
func (a *AliveDialerSet) NotifyLatencyChange(dialer *Dialer, alive bool)
NotifyLatencyChange should be invoked when dialer every time latency and alive state changes.
func (*AliveDialerSet) SortingLatency ¶ added in v0.4.0
func (a *AliveDialerSet) SortingLatency(d *Dialer) time.Duration
type AliveDialerSetSet ¶
type AliveDialerSetSet map[*AliveDialerSet]int
type Annotation ¶ added in v0.2.2
func NewAnnotation ¶ added in v0.2.2
func NewAnnotation(annotation []*config_parser.Param) (*Annotation, error)
type CheckDnsOption ¶
func ParseCheckDnsOption ¶
type CheckDnsOptionRaw ¶
type CheckDnsOptionRaw struct { Raw []string ResolverNetwork string Somark uint32 // contains filtered or unexported fields }
func (*CheckDnsOptionRaw) Option ¶
func (c *CheckDnsOptionRaw) Option() (opt *CheckDnsOption, err error)
type CheckOption ¶
type CheckOption struct { CheckFunc func(ctx context.Context, typ *NetworkType) (ok bool, err error) // contains filtered or unexported fields }
type Dialer ¶
type Dialer struct { *GlobalOption InstanceOption netproxy.Dialer // contains filtered or unexported fields }
func NewDialer ¶
func NewDialer(dialer netproxy.Dialer, option *GlobalOption, iOption InstanceOption, property *Property) *Dialer
NewDialer is for register in general.
func NewFromLink ¶
func NewFromLink(gOption *GlobalOption, iOption InstanceOption, link string, subscriptionTag string) (*Dialer, error)
func (*Dialer) ActivateCheck ¶
func (d *Dialer) ActivateCheck()
func (*Dialer) MustGetAlive ¶
func (d *Dialer) MustGetAlive(typ *NetworkType) bool
func (*Dialer) MustGetLatencies10 ¶
func (d *Dialer) MustGetLatencies10(typ *NetworkType) *LatenciesN
func (*Dialer) NotifyCheck ¶
func (d *Dialer) NotifyCheck()
NotifyCheck will succeed only when CheckEnabled is true.
func (*Dialer) RegisterAliveDialerSet ¶
func (d *Dialer) RegisterAliveDialerSet(a *AliveDialerSet)
RegisterAliveDialerSet is thread-safe.
func (*Dialer) ReportUnavailable ¶ added in v0.7.0
func (d *Dialer) ReportUnavailable(typ *NetworkType, err error)
func (*Dialer) UnregisterAliveDialerSet ¶
func (d *Dialer) UnregisterAliveDialerSet(a *AliveDialerSet)
UnregisterAliveDialerSet is thread-safe.
type GlobalOption ¶
type GlobalOption struct { D.ExtraOption Log *logrus.Logger TcpCheckOptionRaw TcpCheckOptionRaw // Lazy parse CheckDnsOptionRaw CheckDnsOptionRaw // Lazy parse CheckInterval time.Duration CheckTolerance time.Duration CheckDnsTcp bool }
func NewGlobalOption ¶ added in v0.8.0
func NewGlobalOption(global *config.Global, log *logrus.Logger) *GlobalOption
type InstanceOption ¶
type InstanceOption struct {
DisableCheck bool
}
type LatenciesN ¶
type LatenciesN struct { N int LastNLatencies *list.List SumNLatencies time.Duration // contains filtered or unexported fields }
func NewLatenciesN ¶
func NewLatenciesN(n int) *LatenciesN
func (*LatenciesN) AppendLatency ¶
func (ln *LatenciesN) AppendLatency(l time.Duration)
AppendLatency appends a new latency to the back and keep the number in the list. Appending a fixed duration for failed or timeout situation is recommended.
It is thread-safe.
func (*LatenciesN) AvgLatency ¶
func (ln *LatenciesN) AvgLatency() (time.Duration, bool)
func (*LatenciesN) LastLatency ¶
func (ln *LatenciesN) LastLatency() (time.Duration, bool)
type NetworkType ¶
type NetworkType struct { L4Proto consts.L4ProtoStr IpVersion consts.IpVersionStr IsDns bool }
func (*NetworkType) String ¶
func (t *NetworkType) String() string
func (*NetworkType) StringWithoutDns ¶
func (t *NetworkType) StringWithoutDns() string
type Property ¶
func NewBlockDialer ¶
func NewBlockDialer(option *GlobalOption, dialCallback func()) (netproxy.Dialer, *Property)
func NewDirectDialer ¶
func NewDirectDialer(option *GlobalOption, fullcone bool) (netproxy.Dialer, *Property)
type TcpCheckOption ¶
func ParseTcpCheckOption ¶
type TcpCheckOptionRaw ¶
type TcpCheckOptionRaw struct { Log *logrus.Logger Raw []string ResolverNetwork string Method string // contains filtered or unexported fields }
func (*TcpCheckOptionRaw) Option ¶
func (c *TcpCheckOptionRaw) Option() (opt *TcpCheckOption, err error)
Click to show internal directories.
Click to hide internal directories.