rule

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: GPL-3.0 Imports: 19 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListDir

func ListDir(dirPth string, suffix string) (files []string, err error)

ListDir returns file list named with suffix in dirPth.

Types

type Checker added in v0.13.0

type Checker interface {
	Check(dialer proxy.Dialer) (elap time.Duration, err error)
}

Checker is a forwarder health checker.

type Config

type Config struct {
	Name string

	Forward  []string
	Strategy Strategy

	DNSServers []string
	IPSet      string

	Domain []string
	IP     []string
	CIDR   []string
}

Config is config of rule.

func NewConfFromFile

func NewConfFromFile(ruleFile string) (*Config, error)

NewConfFromFile returns a new config from file.

type Forwarder added in v0.11.0

type Forwarder struct {
	proxy.Dialer
	// contains filtered or unexported fields
}

Forwarder associates with a `-forward` command, usually a dialer or a chain of dialers.

func DirectForwarder added in v0.11.0

func DirectForwarder(intface string, dialTimeout, relayTimeout time.Duration) *Forwarder

DirectForwarder returns a direct forwarder.

func ForwarderFromURL added in v0.11.0

func ForwarderFromURL(s, intface string, dialTimeout, relayTimeout time.Duration) (f *Forwarder, err error)

ForwarderFromURL parses `forward=` command value and returns a new forwarder.

func (*Forwarder) AddHandler added in v0.11.0

func (f *Forwarder) AddHandler(h StatusHandler)

AddHandler adds a custom handler to handle the status change event.

func (*Forwarder) Addr added in v0.11.0

func (f *Forwarder) Addr() string

Addr returns the forwarder's addr. NOTE: addr returns for chained dialers: dialer1Addr,dialer2Addr,...

func (*Forwarder) Dial added in v0.11.0

func (f *Forwarder) Dial(network, addr string) (c net.Conn, err error)

Dial dials to addr and returns conn.

func (*Forwarder) Disable added in v0.11.0

func (f *Forwarder) Disable()

Disable the forwarder.

func (*Forwarder) Enable added in v0.11.0

func (f *Forwarder) Enable()

Enable the forwarder.

func (*Forwarder) Enabled added in v0.11.0

func (f *Forwarder) Enabled() bool

Enabled returns the status of forwarder.

func (*Forwarder) Failures added in v0.11.0

func (f *Forwarder) Failures() uint32

Failures returns the failuer count of forwarder.

func (*Forwarder) IncFailures added in v0.11.0

func (f *Forwarder) IncFailures()

IncFailures increase the failuer count by 1.

func (*Forwarder) Latency added in v0.11.0

func (f *Forwarder) Latency() int64

Latency returns the latency of forwarder.

func (*Forwarder) MaxFailures added in v0.11.0

func (f *Forwarder) MaxFailures() uint32

MaxFailures returns the maxFailures of forwarder.

func (*Forwarder) Priority added in v0.11.0

func (f *Forwarder) Priority() uint32

Priority returns the priority of forwarder.

func (*Forwarder) SetLatency added in v0.11.0

func (f *Forwarder) SetLatency(l int64)

SetLatency sets the latency of forwarder.

func (*Forwarder) SetMaxFailures added in v0.11.0

func (f *Forwarder) SetMaxFailures(l uint32)

SetMaxFailures sets the maxFailures of forwarder.

func (*Forwarder) SetPriority added in v0.11.0

func (f *Forwarder) SetPriority(l uint32)

SetPriority sets the priority of forwarder.

type FwdrGroup added in v0.11.0

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

FwdrGroup is a forwarder group.

func NewFwdrGroup added in v0.11.0

func NewFwdrGroup(name string, s []string, c *Strategy) *FwdrGroup

NewFwdrGroup returns a new forward group.

func (*FwdrGroup) Check added in v0.11.0

func (p *FwdrGroup) Check()

Check runs the forwarder checks.

func (*FwdrGroup) Dial added in v0.11.0

func (p *FwdrGroup) Dial(network, addr string) (net.Conn, proxy.Dialer, error)

Dial connects to the address addr on the network net.

func (*FwdrGroup) DialUDP added in v0.11.0

func (p *FwdrGroup) DialUDP(network, addr string) (pc net.PacketConn, dialer proxy.UDPDialer, writeTo net.Addr, err error)

DialUDP connects to the given address.

func (*FwdrGroup) NextDialer added in v0.11.0

func (p *FwdrGroup) NextDialer(dstAddr string) proxy.Dialer

NextDialer returns the next dialer.

func (*FwdrGroup) Priority added in v0.11.0

func (p *FwdrGroup) Priority() uint32

Priority returns the active priority of dialer.

func (*FwdrGroup) SetPriority added in v0.11.0

func (p *FwdrGroup) SetPriority(pri uint32)

SetPriority sets the active priority of daler.

type Proxy added in v0.8.1

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

Proxy implements the proxy.Proxy interface with rule support.

func NewProxy added in v0.8.1

func NewProxy(mainForwarders []string, mainStrategy *Strategy, rules []*Config) *Proxy

NewProxy returns a new rule proxy.

func (*Proxy) AddDomainIP added in v0.8.1

func (p *Proxy) AddDomainIP(domain, ip string) error

AddDomainIP used to update ipMap rules according to domainMap rule.

func (*Proxy) Check added in v0.8.1

func (p *Proxy) Check()

Check checks availability of forwarders inside proxy.

func (*Proxy) Dial added in v0.8.1

func (p *Proxy) Dial(network, addr string) (net.Conn, proxy.Dialer, error)

Dial dials to targer addr and return a conn.

func (*Proxy) DialUDP added in v0.8.1

func (p *Proxy) DialUDP(network, addr string) (pc net.PacketConn, dialer proxy.UDPDialer, writeTo net.Addr, err error)

DialUDP connects to the given address via the proxy.

func (*Proxy) NextDialer added in v0.8.1

func (p *Proxy) NextDialer(dstAddr string) proxy.Dialer

NextDialer returns next dialer according to rule.

func (*Proxy) Record added in v0.10.0

func (p *Proxy) Record(dialer proxy.Dialer, success bool)

Record records result while using the dialer from proxy.

type StatusHandler added in v0.11.0

type StatusHandler func(*Forwarder)

StatusHandler function will be called when the forwarder's status changed.

type Strategy added in v0.13.0

type Strategy struct {
	Strategy          string
	Check             string
	CheckInterval     int
	CheckTimeout      int
	CheckTolerance    int
	CheckDisabledOnly bool
	MaxFailures       int
	DialTimeout       int
	RelayTimeout      int
	IntFace           string
}

Strategy configurations.

Jump to

Keyboard shortcuts

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