Documentation ¶
Index ¶
- type ProxyAuthHandler
- type ProxyConfig
- type ProxyCtx
- type ProxyHandler
- type ProxyServer
- func (ps *ProxyServer) AddForward(list string) error
- func (ps *ProxyServer) AddForwardMap(forward map[string]string) error
- func (ps *ProxyServer) DelForward(list string) error
- func (ps *ProxyServer) DelForwardMap(forward map[string]string) error
- func (ps *ProxyServer) ForwardInfo() map[string]string
- func (ps *ProxyServer) StartProxy()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ProxyAuthHandler ¶
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 ¶
LocalAddr returns local address for the given request.
Always returns non-nil result.
func (*ProxyCtx) ProtocolInfo ¶
ProtocolInfo returns protocol information for the given request.
Always returns non-nil result.
func (*ProxyCtx) RemoteAddr ¶
RemoteAddr returns client address for the given request.
Always returns non-nil result.
func (*ProxyCtx) SessionInfo ¶
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,