proxy

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTunClient      = tun.NewClient()
	DefaultTunCrypt       = xor.NewCrypt(975135745)
	DefaultListenAddress  = ":"
	DefaultConnectAddress = ":3218"
)

default proxy options

View Source
var (
	DefaultTunServer = tun.NewServer()
)

default endpoint options

Functions

func NewTunClientHandler

func NewTunClientHandler() tun.Handler

NewTunClientHandler create a new tunnel handler for proxy

func NewTunServerHandler

func NewTunServerHandler() tun.Handler

NewTunServerHandler create a new tunnel handler for endpoint

Types

type Cmd

type Cmd int8

Cmd is command code of tunnel packet

const (
	CmdConfig Cmd = iota
	CmdTunID
	CmdConnect
	CmdConnectResult
	CmdSend
	CmdClose
)

command values

type Endpoint

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

Endpoint for connecting remote tcp server

func NewEndpoint

func NewEndpoint(opts ...EndpointOption) *Endpoint

NewEndpoint create a new Endpoint

func (*Endpoint) ListenAndServe

func (p *Endpoint) ListenAndServe() error

ListenAndServe starts endpoint

type EndpointOption

type EndpointOption func(opts *EndpointOptions)

EndpointOption is option setter for endpoint

func WithTunServer

func WithTunServer(tun tun.Server) EndpointOption

WithTunServer sets tunnel server opt

func WithTunServerCrypt

func WithTunServerCrypt(crypt crypt.Crypt) EndpointOption

WithTunServerCrypt sets tunnel crypt opt

type EndpointOptions

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

EndpointOptions is the options of endpoint

type Proxy

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

Proxy for proxying remote tcp server to local address

func NewProxy

func NewProxy(opts ...ProxyOption) *Proxy

NewProxy create a new proxy

func (*Proxy) DialAndServe

func (p *Proxy) DialAndServe() error

DialAndServe starts proxy

type ProxyOption

type ProxyOption func(opts *ProxyOptions)

ProxyOption is option setter for proxy

func WithConnectAddress

func WithConnectAddress(addr string) ProxyOption

WithConnectAddress sets remote endpoint connect address opt

func WithDownloadCounter added in v0.3.3

func WithDownloadCounter(counter counter.Counter) ProxyOption

WithDownloadCounter sets download counter opt

func WithListenAddress

func WithListenAddress(addr string) ProxyOption

WithListenAddress sets local proxy listen address opt

func WithTunClient

func WithTunClient(tun tun.Client) ProxyOption

WithTunClient sets tunnel client opt

func WithTunClientCrypt

func WithTunClientCrypt(crypt crypt.Crypt) ProxyOption

WithTunClientCrypt sets tunnel crypt opt

func WithUploadCounter added in v0.3.3

func WithUploadCounter(counter counter.Counter) ProxyOption

WithUploadCounter sets upload counter opt

type ProxyOptions

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

ProxyOptions is options of proxy

Jump to

Keyboard shortcuts

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