proxy

package
v0.0.0-...-c6b16a5 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterClient

func RegisterClient(name string, c ClientCreator)

RegisterClient is used to register a client.

func RegisterServer

func RegisterServer(name string, c ServerCreator)

RegisterServer is used to register a proxy server

Types

type Client

type Client interface {
	Name() string
	// Address to dail
	Addr() string
	// Handshake with TCP server
	Handshake(underlay net.Conn, target string) (StreamConn, error)
	// Pack underlay net.packetConn
	Pack(underlay net.Conn) (PacketConn, error)
}

Client is used to create connection.

func ClientFromURL

func ClientFromURL(ctx context.Context, s string) (Client, error)

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

type ClientCreator

type ClientCreator func(ctx context.Context, url *url.URL) (Client, error)

ClientCreator is a function to create client.

type PacketConn

type PacketConn interface {
	net.PacketConn
	GetTargetAddr() *TargetAddr
}

PacketConn for udp relay

type Proxy

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

Proxy

func NewProxy

func NewProxy(ctx context.Context, local, remote, route string) (*Proxy, error)

func (*Proxy) Execute

func (p *Proxy) Execute() error

type Server

type Server interface {
	Name() string
	// Address to listen
	Addr() string
	// Handshake with TCP client
	Handshake(underlay net.Conn) (StreamConn, *TargetAddr, error)
	// Pack underlay net.packetConn
	Pack(underlay net.Conn) (PacketConn, error)
}

Server interface

func ServerFromURL

func ServerFromURL(ctx context.Context, s string) (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(ctx context.Context, url *url.URL) (Server, error)

ServerCreator is a function to create proxy server

type StreamConn

type StreamConn interface {
	io.Reader
	io.Writer
	io.Closer
}

StreamConn for tcp relay

type TargetAddr

type TargetAddr struct {
	Name string // fully-qualified domain name
	IP   net.IP
	Port int
}

An Addr represents a address that you want to access by proxy. Either Name or IP is used exclusively.

func NewTargetAddr

func NewTargetAddr(addr string) (*TargetAddr, error)

func (*TargetAddr) Host

func (a *TargetAddr) Host() string

Returned host string

func (*TargetAddr) String

func (a *TargetAddr) String() string

Return host:port string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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