datatunnel

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthAction   = "Auth"   // 认证,由SA发起
	CreateAction = "Create" // 认证通过, 创建数据通道客户端,由SC发起
	NewAction    = "New"    // 新建一个TCP连接,由SC发起
	ErrorAction  = "Error"  // 错误事件
)
View Source
const (
	DefaultTCPKeepAlivePeriod = (5 * time.Minute)
	DefaultLingerSecond       = 30
)
View Source
const (
	MonitorSleepTime = (time.Second * time.Duration(30))
)

Variables

This section is empty.

Functions

func GetActionData

func GetActionData(value string, data interface{}) (err error)

获取事件数据

func Proxy

func Proxy(from, to net.Conn)

Types

type AuthActionData

type AuthActionData struct {
	SAID        string `json:"sa_id"`
	Key         string `json:"key"`
	ServiceName string `json:"service_name"`
}

AuthActionData 认证事件数据格式

type CreateActionData

type CreateActionData struct {
	Port        int    `json:"port"`
	ServiceName string `json:"service_name"`
}

CreateActionData 新建时间数据格式

type DatatunnelControlServer

type DatatunnelControlServer struct {
	proto.UnimplementedDatatunnelControllerServer
	// contains filtered or unexported fields
}

func (*DatatunnelControlServer) ControlStream

func (*DatatunnelControlServer) GetSAConnection

func (s *DatatunnelControlServer) GetSAConnection(saID string, serviceName string, timeout int) net.Conn

GetSAConnection 获取SA连接

func (*DatatunnelControlServer) Go

func (s *DatatunnelControlServer) Go()

func (*DatatunnelControlServer) SAIsConnected

func (s *DatatunnelControlServer) SAIsConnected(saID string, serviceName string) bool

SAIsConnected SA的控制通道与数据通道是否已经连接成功

func (*DatatunnelControlServer) SendCreateAction

func (s *DatatunnelControlServer) SendCreateAction(server proto.DatatunnelController_ControlStreamServer,
	port int, serviceName string) (err error)

SendCreateAction 认证通过,通知SA创建数据通道客户端

func (*DatatunnelControlServer) SendNewConnection

func (s *DatatunnelControlServer) SendNewConnection(saID string, serviceName string) error

SendNewConnection 通知SA创建新连接

type DatatunnelControlServerOption

type DatatunnelControlServerOption struct {
	DoAuth     func(saID string, key string) bool
	ClientPort PortRange
}

type NewActionData

type NewActionData struct {
	ServiceName   string `json:"service_name"`
	ConnectionKey string `json:"key"`
}

NewActionData 新建TCP连接数据格式

type PortRange

type PortRange struct {
	Min int
	Max int
}

type TunnelClient

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

func NewTunnelClient

func NewTunnelClient(option *TunnelClientOption) *TunnelClient

func (*TunnelClient) NewProxy

func (c *TunnelClient) NewProxy(sendKey func(net.Conn) error)

type TunnelClientOption

type TunnelClientOption struct {
	// 服务端和需要代理的地址
	ServerAddr *net.TCPAddr
	ProxyAddr  *net.TCPAddr

	// 重试次数
	Retry int

	LogLevel string

	LingerSecond int // tcp参数SO_LINGER,单位秒
}

type TunnelServer

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

func NewTunnelServer

func NewTunnelServer(option *TunnelServerOption) *TunnelServer

func (*TunnelServer) GetClient

func (s *TunnelServer) GetClient(timeout int) net.Conn

func (*TunnelServer) Go

func (s *TunnelServer) Go()

func (*TunnelServer) GoClient

func (s *TunnelServer) GoClient(listener *net.TCPListener)

func (*TunnelServer) RunClient

func (s *TunnelServer) RunClient(addr *net.TCPAddr)

func (*TunnelServer) Stop

func (s *TunnelServer) Stop()

func (*TunnelServer) StopClient

func (s *TunnelServer) StopClient()

type TunnelServerOption

type TunnelServerOption struct {
	OnClientConnected func(conn net.Conn) error
	LingerSecond      int // 单位秒
	LogLevel          string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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