proxy

package
v0.6.11 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2018 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

func DialerFromURL

func DialerFromURL(s string, dialer Dialer) (Dialer, error)

DialerFromURL calls the registered creator to create dialers. dialer is the default upstream dialer so cannot be nil, we can use Default when calling this function.

type DialerCreator

type DialerCreator func(s string, dialer Dialer) (Dialer, error)

DialerCreator is a function to create dialers.

type Direct

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

Direct proxy

func NewDirect added in v0.6.7

func NewDirect(intface string) (*Direct, error)

NewDirect returns a Direct dialer

func (*Direct) Addr added in v0.6.7

func (d *Direct) Addr() string

Addr returns forwarder's address

func (*Direct) Dial added in v0.6.7

func (d *Direct) Dial(network, addr string) (c net.Conn, err error)

Dial connects to the address addr on the network net

func (*Direct) DialUDP added in v0.6.7

func (d *Direct) DialUDP(network, addr string) (net.PacketConn, net.Addr, error)

DialUDP connects to the given address

func (*Direct) IFaceIPs added in v0.6.7

func (d *Direct) IFaceIPs() (ips []net.IP)

IFaceIPs returns ip addresses according to the specified interface

func (*Direct) NextDialer added in v0.6.7

func (d *Direct) NextDialer(dstAddr string) Dialer

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

func ForwarderFromURL(s, intface string) (f *Forwarder, err error)

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) Addr added in v0.6.7

func (f *Forwarder) Addr() string

Addr .

func (*Forwarder) Dial added in v0.6.7

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

Dial .

func (*Forwarder) Disable added in v0.6.7

func (f *Forwarder) Disable()

Disable the forwarder

func (*Forwarder) Enable added in v0.6.7

func (f *Forwarder) Enable()

Enable the forwarder

func (*Forwarder) Enabled added in v0.6.7

func (f *Forwarder) Enabled() bool

Enabled returns the status of forwarder

func (*Forwarder) Failures added in v0.6.7

func (f *Forwarder) Failures() uint32

Failures returns the failuer count of forwarder

func (*Forwarder) IncFailures added in v0.6.7

func (f *Forwarder) IncFailures()

IncFailures increase the failuer count by 1

func (*Forwarder) Latency added in v0.6.7

func (f *Forwarder) Latency() int64

Latency returns the latency of forwarder

func (*Forwarder) MaxFailures added in v0.6.7

func (f *Forwarder) MaxFailures() uint32

MaxFailures returns the maxFailures of forwarder

func (*Forwarder) Priority added in v0.6.7

func (f *Forwarder) Priority() uint32

Priority returns the priority of forwarder

func (*Forwarder) SetLatency added in v0.6.7

func (f *Forwarder) SetLatency(l int64)

SetLatency sets the latency of forwarder

func (*Forwarder) SetMaxFailures added in v0.6.7

func (f *Forwarder) SetMaxFailures(l uint32)

SetMaxFailures sets the maxFailures of forwarder

func (*Forwarder) SetPriority added in v0.6.7

func (f *Forwarder) SetPriority(l uint32)

SetPriority sets the priority of forwarder

type Server

type Server interface {
	// ListenAndServe sets up a listener and serve on it
	ListenAndServe()

	// Serve serves a connection
	Serve(c net.Conn)
}

Server interface

func ServerFromURL

func ServerFromURL(s string, dialer Dialer) (Server, error)

ServerFromURL calls the registered creator to create proxy servers dialer is the default upstream dialer so cannot be nil, we can use Default when calling this function

type ServerCreator

type ServerCreator func(s string, dialer Dialer) (Server, error)

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

Directories

Path Synopsis
Package obfs implements simple-obfs of ss
Package obfs implements simple-obfs of ss

Jump to

Keyboard shortcuts

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