proxy

package
v0.16.3 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: GPL-3.0 Imports: 14 Imported by: 51

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TCPBufSize is the size of tcp buffer.
	TCPBufSize = 32 << 10

	// UDPBufSize is the size of udp buffer.
	UDPBufSize = 2 << 10
)
View Source
var (
	// ErrNotSupported indicates that the operation is not supported
	ErrNotSupported = errors.New("not supported")
)

Functions

func AddUsage added in v0.16.0

func AddUsage(name, usage string)

AddUsage adds help message for the named proxy.

func Copy added in v0.11.0

func Copy(dst io.Writer, src io.Reader) (written int64, err error)

Copy copies from src to dst.

func CopyBuffer added in v0.11.0

func CopyBuffer(dst io.Writer, src io.Reader) (written int64, err error)

CopyBuffer copies from src to dst with a userspace buffer.

func CopyN added in v0.11.0

func CopyN(dst io.Writer, src io.Reader, n int64) (written int64, err error)

CopyN copies n bytes (or until an error) from src to dst.

func CopyUDP added in v0.16.0

func CopyUDP(dst net.PacketConn, writeTo net.Addr, src net.PacketConn, timeout time.Duration, step time.Duration) error

CopyUDP copys from src to dst at target with read timeout. if step sets to non-zero value, the read timeout will be increased from 0 to timeout by step in every read operation.

func DialerSchemes added in v0.16.0

func DialerSchemes() string

DialerSchemes returns the registered dialer schemes.

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.

func Relay added in v0.11.0

func Relay(left, right net.Conn) error

Relay relays between left and right.

func ServerSchemes added in v0.16.0

func ServerSchemes() string

ServerSchemes returns the registered server schemes.

func Usage added in v0.16.0

func Usage(name string) string

Usage returns help message of the named proxy.

Types

type Conn added in v0.11.0

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

Conn is a connection with buffered reader.

func NewConn added in v0.11.0

func NewConn(c net.Conn) *Conn

NewConn returns a new conn.

func (*Conn) Close added in v0.12.2

func (c *Conn) Close() error

Close closes the Conn.

func (*Conn) Peek added in v0.11.0

func (c *Conn) Peek(n int) ([]byte, error)

Peek returns the next n bytes without advancing the reader.

func (*Conn) Read added in v0.11.0

func (c *Conn) Read(p []byte) (int, error)

func (*Conn) Reader added in v0.11.0

func (c *Conn) Reader() *bufio.Reader

Reader returns the internal bufio.Reader.

func (*Conn) WriteTo added in v0.12.1

func (c *Conn) WriteTo(w io.Writer) (n int64, err error)

WriteTo implements io.WriterTo.

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.

func NewDirectDialer added in v0.15.0

func NewDirectDialer(s string, d Dialer) (Dialer, error)

NewDirectDialer returns a direct dialer.

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, 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 PacketServer added in v0.16.0

type PacketServer interface {
	ServePacket(pc net.PacketConn)
}

PacketServer 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, dialer UDPDialer, 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, proxy Proxy) (Server, error)

ServerFromURL calls the registered creator to create proxy servers. proxy can not be nil.

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, 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.
ss
ssr

Jump to

Keyboard shortcuts

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