proxy

package
v0.0.0-...-84fdf29 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProxyPhaseNew         = "new"
	ProxyPhaseWaitStart   = "wait start"
	ProxyPhaseStartErr    = "start error"
	ProxyPhaseRunning     = "running"
	ProxyPhaseCheckFailed = "check failed"
	ProxyPhaseClosed      = "closed"
)

Variables

This section is empty.

Functions

func RegisterProxyFactory

func RegisterProxyFactory(proxyConfType reflect.Type, factory func(*BaseProxy, config.ProxyConf) Proxy)

Types

type BaseProxy

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

func (*BaseProxy) Close

func (pxy *BaseProxy) Close()

func (*BaseProxy) HandleTCPWorkConnection

func (pxy *BaseProxy) HandleTCPWorkConnection(workConn net.Conn, m *msg.StartWorkConn, encKey []byte)

Common handler for tcp work connections.

func (*BaseProxy) InWorkConn

func (pxy *BaseProxy) InWorkConn(conn net.Conn, m *msg.StartWorkConn)

func (*BaseProxy) Run

func (pxy *BaseProxy) Run() error

type GeneralTCPProxy

type GeneralTCPProxy struct {
	*BaseProxy
}

GeneralTCPProxy is a general implementation of Proxy interface for TCP protocol. If the default GeneralTCPProxy cannot meet the requirements, you can customize the implementation of the Proxy interface.

type Manager

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

func NewManager

func NewManager(
	ctx context.Context,
	clientCfg config.ClientCommonConf,
	msgTransporter transport.MessageTransporter,
) *Manager

func (*Manager) Close

func (pm *Manager) Close()

func (*Manager) GetAllProxyStatus

func (pm *Manager) GetAllProxyStatus() []*WorkingStatus

func (*Manager) HandleEvent

func (pm *Manager) HandleEvent(payload interface{}) error

func (*Manager) HandleWorkConn

func (pm *Manager) HandleWorkConn(name string, workConn net.Conn, m *msg.StartWorkConn)

func (*Manager) Reload

func (pm *Manager) Reload(pxyCfgs map[string]config.ProxyConf)

func (*Manager) StartProxy

func (pm *Manager) StartProxy(name string, remoteAddr string, serverRespErr string) error

type Proxy

type Proxy interface {
	Run() error

	// InWorkConn accept work connections registered to server.
	InWorkConn(net.Conn, *msg.StartWorkConn)

	Close()
}

Proxy defines how to handle work connections for different proxy type.

func NewGeneralTCPProxy

func NewGeneralTCPProxy(baseProxy *BaseProxy, _ config.ProxyConf) Proxy

func NewProxy

func NewProxy(
	ctx context.Context,
	pxyConf config.ProxyConf,
	clientCfg config.ClientCommonConf,
	msgTransporter transport.MessageTransporter,
) (pxy Proxy)

func NewSUDPProxy

func NewSUDPProxy(baseProxy *BaseProxy, cfg config.ProxyConf) Proxy

func NewUDPProxy

func NewUDPProxy(baseProxy *BaseProxy, cfg config.ProxyConf) Proxy

func NewXTCPProxy

func NewXTCPProxy(baseProxy *BaseProxy, cfg config.ProxyConf) Proxy

type SUDPProxy

type SUDPProxy struct {
	*BaseProxy
	// contains filtered or unexported fields
}

func (*SUDPProxy) Close

func (pxy *SUDPProxy) Close()

func (*SUDPProxy) InWorkConn

func (pxy *SUDPProxy) InWorkConn(conn net.Conn, _ *msg.StartWorkConn)

func (*SUDPProxy) Run

func (pxy *SUDPProxy) Run() (err error)

type UDPProxy

type UDPProxy struct {
	*BaseProxy
	// contains filtered or unexported fields
}

func (*UDPProxy) Close

func (pxy *UDPProxy) Close()

func (*UDPProxy) InWorkConn

func (pxy *UDPProxy) InWorkConn(conn net.Conn, _ *msg.StartWorkConn)

func (*UDPProxy) Run

func (pxy *UDPProxy) Run() (err error)

type WorkingStatus

type WorkingStatus struct {
	Name  string           `json:"name"`
	Type  string           `json:"type"`
	Phase string           `json:"status"`
	Err   string           `json:"err"`
	Cfg   config.ProxyConf `json:"cfg"`

	// Got from server.
	RemoteAddr string `json:"remote_addr"`
}

type Wrapper

type Wrapper struct {
	WorkingStatus
	// contains filtered or unexported fields
}

func NewWrapper

func NewWrapper(
	ctx context.Context,
	cfg config.ProxyConf,
	clientCfg config.ClientCommonConf,
	eventHandler event.Handler,
	msgTransporter transport.MessageTransporter,
) *Wrapper

func (*Wrapper) GetStatus

func (pw *Wrapper) GetStatus() *WorkingStatus

func (*Wrapper) InWorkConn

func (pw *Wrapper) InWorkConn(workConn net.Conn, m *msg.StartWorkConn)

func (*Wrapper) SetRunningStatus

func (pw *Wrapper) SetRunningStatus(remoteAddr string, respErr string) error

func (*Wrapper) Start

func (pw *Wrapper) Start()

func (*Wrapper) Stop

func (pw *Wrapper) Stop()

type XTCPProxy

type XTCPProxy struct {
	*BaseProxy
	// contains filtered or unexported fields
}

func (*XTCPProxy) InWorkConn

func (pxy *XTCPProxy) InWorkConn(conn net.Conn, startWorkConnMsg *msg.StartWorkConn)

Jump to

Keyboard shortcuts

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