proxy

package
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: GPL-3.0 Imports: 6 Imported by: 51

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = &Direct{dialTimeout: time.Second * 3}

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 {
	TCPDialer
	UDPDialer
}

Dialer is used to create connection.

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, dialTimeout, relayTimeout time.Duration) (*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.

type Proxy added in v0.8.1

type Proxy interface {
	// Dial connects to the given address via the proxy.
	Dial(network, addr string) (c net.Conn, dialer Dialer, 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

	// Record records result while using the dialer from proxy.
	Record(dialer Dialer, success bool)
}

Proxy is a dialer manager

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, p Proxy) (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, proxy Proxy) (Server, error)

ServerCreator is a function to create proxy servers

type TCPDialer added in v0.10.0

type TCPDialer interface {
	// Addr is the dialer's addr
	Addr() string

	// Dial connects to the given address
	Dial(network, addr string) (c net.Conn, err error)
}

TCPDialer is used to create tcp connection.

type UDPDialer added in v0.10.0

type UDPDialer interface {
	// Addr is the dialer's addr
	Addr() string

	// DialUDP connects to the given address
	DialUDP(network, addr string) (pc net.PacketConn, writeTo net.Addr, err error)
}

UDPDialer is used to create udp PacketConn.

Directories

Path Synopsis
Package http implements a http proxy.
Package http implements a http proxy.
Package obfs implements simple-obfs of ss
Package obfs implements simple-obfs of ss
Package reject implements a virtual proxy which always reject requests.
Package reject implements a virtual proxy which always reject requests.
Package socks5 implements a socks5 proxy.
Package socks5 implements a socks5 proxy.
Package ws implements a simple websocket client.
Package ws implements a simple websocket client.

Jump to

Keyboard shortcuts

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