Documentation ¶
Index ¶
- Variables
- func RegisterDialer(name string, c DialerCreator)
- func RegisterServer(name string, c ServerCreator)
- type Dialer
- type DialerCreator
- type Direct
- type Forwarder
- func (f *Forwarder) AddHandler(h StatusHandler)
- func (f *Forwarder) Addr() string
- func (f *Forwarder) Dial(network, addr string) (c net.Conn, err error)
- func (f *Forwarder) Disable()
- func (f *Forwarder) Enable()
- func (f *Forwarder) Enabled() bool
- func (f *Forwarder) Failures() uint32
- func (f *Forwarder) IncFailures()
- func (f *Forwarder) Latency() int64
- func (f *Forwarder) MaxFailures() uint32
- func (f *Forwarder) Priority() uint32
- func (f *Forwarder) SetLatency(l int64)
- func (f *Forwarder) SetMaxFailures(l uint32)
- func (f *Forwarder) SetPriority(l uint32)
- type Server
- type ServerCreator
- type StatusHandler
Constants ¶
This section is empty.
Variables ¶
var Default = &Direct{}
Default dialer
Functions ¶
func RegisterDialer ¶
func RegisterDialer(name string, c DialerCreator)
RegisterDialer is used to register a dialer
func RegisterServer ¶
func RegisterServer(name string, c ServerCreator)
RegisterServer is used to register a proxy server
Types ¶
type Dialer ¶
type Dialer interface { // Addr() Addr() string // Dial connects to the given address via the proxy. Dial(network, addr string) (c net.Conn, err error) // DialUDP connects to the given address via the proxy. DialUDP(network, addr string) (pc net.PacketConn, writeTo net.Addr, err error) // Get the dialer by dstAddr NextDialer(dstAddr string) Dialer }
Dialer means to establish a connection and relay it.
type DialerCreator ¶
DialerCreator is a function to create dialers.
type Direct ¶
type Direct struct {
// contains filtered or unexported fields
}
Direct proxy
func (*Direct) IFaceIPs ¶ added in v0.6.7
IFaceIPs returns ip addresses according to the specified interface
func (*Direct) NextDialer ¶ added in v0.6.7
NextDialer returns the next dialer
type Forwarder ¶ added in v0.6.7
type Forwarder struct { Dialer // contains filtered or unexported fields }
Forwarder is a forwarder
func ForwarderFromURL ¶ added in v0.6.7
ForwarderFromURL parses `forward=` command value and returns a new forwarder
func (*Forwarder) AddHandler ¶ added in v0.6.7
func (f *Forwarder) AddHandler(h StatusHandler)
AddHandler adds a custom handler to handle the status change event
func (*Forwarder) IncFailures ¶ added in v0.6.7
func (f *Forwarder) IncFailures()
IncFailures increase the failuer count by 1
func (*Forwarder) MaxFailures ¶ added in v0.6.7
MaxFailures returns the maxFailures of forwarder
func (*Forwarder) SetLatency ¶ added in v0.6.7
SetLatency sets the latency of forwarder
func (*Forwarder) SetMaxFailures ¶ added in v0.6.7
SetMaxFailures sets the maxFailures of forwarder
func (*Forwarder) SetPriority ¶ added in v0.6.7
SetPriority sets the priority of forwarder
type Server ¶
type Server interface {
// ListenAndServe as proxy server, use only in server mode.
ListenAndServe()
}
Server interface
type ServerCreator ¶
ServerCreator is a function to create proxy servers.
type StatusHandler ¶ added in v0.6.7
type StatusHandler func(*Forwarder)
StatusHandler function will be called when the forwarder's status changed