proxy

package
v0.61.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0 Imports: 30 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 added in v0.58.1

func RegisterProxyFactory(proxyConfType reflect.Type, factory func(*BaseProxy, v1.ProxyConfigurer) Proxy)

Types

type BaseProxy

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

func (*BaseProxy) Close added in v0.58.1

func (pxy *BaseProxy) Close()

func (*BaseProxy) HandleTCPWorkConnection added in v0.58.1

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

Common handler for tcp work connections.

func (*BaseProxy) InWorkConn added in v0.58.1

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

func (*BaseProxy) Run added in v0.58.1

func (pxy *BaseProxy) Run() error

func (*BaseProxy) SetInWorkConnCallback added in v0.58.1

func (pxy *BaseProxy) SetInWorkConnCallback(cb func(*v1.ProxyBaseConfig, net.Conn, *msg.StartWorkConn) bool)

type GeneralTCPProxy added in v0.58.1

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 added in v0.58.1

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

func NewManager added in v0.58.1

func NewManager(
	ctx context.Context,
	clientCfg *v1.ClientCommonConfig,
	msgTransporter transport.MessageTransporter,
) *Manager

func (*Manager) Close added in v0.58.1

func (pm *Manager) Close()

func (*Manager) GetAllProxyStatus added in v0.58.1

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

func (*Manager) GetProxyStatus added in v0.58.1

func (pm *Manager) GetProxyStatus(name string) (*WorkingStatus, bool)

func (*Manager) HandleEvent added in v0.58.1

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

func (*Manager) HandleWorkConn added in v0.58.1

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

func (*Manager) SetInWorkConnCallback added in v0.58.1

func (pm *Manager) SetInWorkConnCallback(cb func(*v1.ProxyBaseConfig, net.Conn, *msg.StartWorkConn) bool)

func (*Manager) StartProxy added in v0.58.1

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

func (*Manager) UpdateAll added in v0.58.1

func (pm *Manager) UpdateAll(proxyCfgs []v1.ProxyConfigurer)

type Proxy

type Proxy interface {
	Run() error
	// InWorkConn accept work connections registered to server.
	InWorkConn(net.Conn, *msg.StartWorkConn)
	SetInWorkConnCallback(func(*v1.ProxyBaseConfig, net.Conn, *msg.StartWorkConn) bool)
	Close()
}

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

func NewGeneralTCPProxy added in v0.58.1

func NewGeneralTCPProxy(baseProxy *BaseProxy, _ v1.ProxyConfigurer) Proxy

func NewProxy

func NewProxy(
	ctx context.Context,
	pxyConf v1.ProxyConfigurer,
	clientCfg *v1.ClientCommonConfig,
	msgTransporter transport.MessageTransporter,
) (pxy Proxy)

func NewSUDPProxy added in v0.58.1

func NewSUDPProxy(baseProxy *BaseProxy, cfg v1.ProxyConfigurer) Proxy

func NewUDPProxy added in v0.58.1

func NewUDPProxy(baseProxy *BaseProxy, cfg v1.ProxyConfigurer) Proxy

func NewXTCPProxy added in v0.58.1

func NewXTCPProxy(baseProxy *BaseProxy, cfg v1.ProxyConfigurer) Proxy

type SUDPProxy added in v0.58.1

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

func (*SUDPProxy) Close added in v0.58.1

func (pxy *SUDPProxy) Close()

func (*SUDPProxy) InWorkConn added in v0.58.1

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

func (*SUDPProxy) Run added in v0.58.1

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

type UDPProxy added in v0.58.1

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

func (*UDPProxy) Close added in v0.58.1

func (pxy *UDPProxy) Close()

func (*UDPProxy) InWorkConn added in v0.58.1

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

func (*UDPProxy) Run added in v0.58.1

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

type WorkingStatus added in v0.58.1

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

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

type Wrapper added in v0.58.1

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

func NewWrapper added in v0.58.1

func NewWrapper(
	ctx context.Context,
	cfg v1.ProxyConfigurer,
	clientCfg *v1.ClientCommonConfig,
	eventHandler event.Handler,
	msgTransporter transport.MessageTransporter,
) *Wrapper

func (*Wrapper) GetStatus added in v0.58.1

func (pw *Wrapper) GetStatus() *WorkingStatus

func (*Wrapper) InWorkConn added in v0.58.1

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

func (*Wrapper) SetInWorkConnCallback added in v0.58.1

func (pw *Wrapper) SetInWorkConnCallback(cb func(*v1.ProxyBaseConfig, net.Conn, *msg.StartWorkConn) bool)

func (*Wrapper) SetRunningStatus added in v0.58.1

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

func (*Wrapper) Start added in v0.58.1

func (pw *Wrapper) Start()

func (*Wrapper) Stop added in v0.58.1

func (pw *Wrapper) Stop()

type XTCPProxy added in v0.58.1

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

func (*XTCPProxy) InWorkConn added in v0.58.1

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