multiproxy

package module
v0.0.0-...-0ae8ef8 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: MIT Imports: 7 Imported by: 2

README

multiproxy

multiproxy for create multi-proxy in one application, write in Go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProxyAuthHandler

type ProxyAuthHandler func(ctx *ProxyCtx) error

ProxyAuthHandler is a function to handle proxy auth, return nil for auth ok, or error message

type ProxyConfig

type ProxyConfig struct {
	Forwards          map[string]string // map[link-protocol(tcp/udp)/<frontend addr>]<backend addr|passive,...>
	KeepaliveInterval time.Duration
	KeepaliveTimeout  time.Duration
	SynTimeout        time.Duration
	Coolingtimeout    time.Duration

	LogWriter   *lumberjack.Logger
	AuthHandler ProxyAuthHandler
}

ProxyConfig for setup proxy server

func NewDefaultConfig

func NewDefaultConfig() *ProxyConfig

NewDefaultConfig return a *ProxyConfig with initial settings

func NewForwardConfig

func NewForwardConfig(forwards map[string]string, authHandler ProxyAuthHandler, logWriter *lumberjack.Logger) *ProxyConfig

NewForwardConfig return a *ProxyConfig with initial settings

func NewListConfig

func NewListConfig(list string, authHandler ProxyAuthHandler, logWriter *lumberjack.Logger) *ProxyConfig

NewListConfig return a *ProxyConfig with initial settings, list should has format: <protocol>/<front address>/backend addr,...+another frontend, word "passive" as backend means backend connection initial from peer, example: tcp/0.0.0.0:80/10.0.0.2:8080,10.0.0.3:9080+udp/0.0.0.0:53/10.0.0.2:5353,passive

type ProxyCtx

type ProxyCtx struct {
	Err      error
	AuthOK   bool
	AuthInfo string
	// contains filtered or unexported fields
}

ProxyCtx contains incoming request and manages outgoing response.

func (*ProxyCtx) LocalAddr

func (ctx *ProxyCtx) LocalAddr() net.Addr

LocalAddr returns local address for the given request.

Always returns non-nil result.

func (*ProxyCtx) ProtocolInfo

func (ctx *ProxyCtx) ProtocolInfo() string

ProtocolInfo returns protocol information for the given request.

Always returns non-nil result.

func (*ProxyCtx) RemoteAddr

func (ctx *ProxyCtx) RemoteAddr() net.Addr

RemoteAddr returns client address for the given request.

Always returns non-nil result.

func (*ProxyCtx) SessionInfo

func (ctx *ProxyCtx) SessionInfo() string

SessionInfo returns session information for the given request.

Always returns non-nil result.

type ProxyHandler

type ProxyHandler func(ctx *ProxyCtx)

ProxyHandler is a function to handle proxy connections

type ProxyServer

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

ProxyServer represent a proxy server

func NewProxyServer

func NewProxyServer(list string, auth ProxyAuthHandler, logWriter *lumberjack.Logger) *ProxyServer

NewProxyServer return a ProxyServer base on input proxy list, list should has format: <protocol>/<front address>/backend addr,..., word "passive" as backend means backend connection initial from peer, example: tcp/0.0.0.0:80/10.0.0.2:8080,10.0.0.3:9080, example2: udp/0.0.0.0:53/10.0.0.2:5353,passive,

func NewProxyServerByConf

func NewProxyServerByConf(cfg *ProxyConfig) *ProxyServer

NewProxyServerByConf return a ProxyServer base on input proxy list

func (*ProxyServer) AddForward

func (ps *ProxyServer) AddForward(list string) error

AddForward create new forward tunnel and process income connections

func (*ProxyServer) AddForwardMap

func (ps *ProxyServer) AddForwardMap(forward map[string]string) error

AddForwardMap create new forward tunnel and process income connections

func (*ProxyServer) DelForward

func (ps *ProxyServer) DelForward(list string) error

DelForward delete forward tunnel

func (*ProxyServer) DelForwardMap

func (ps *ProxyServer) DelForwardMap(forward map[string]string) error

DelForwardMap create new forward tunnel and process income connections

func (*ProxyServer) ForwardInfo

func (ps *ProxyServer) ForwardInfo() map[string]string

ForwardInfo return forward info in map

func (*ProxyServer) StartProxy

func (ps *ProxyServer) StartProxy()

StartProxy create listen sockets and process income connections,

Jump to

Keyboard shortcuts

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