transport

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(remoteAddr string, key string, threads int, handler GrpcHandler) *Client

func (*Client) ConnectWait

func (c *Client) ConnectWait()

func (*Client) GetTunLocalAddrWithPortOnConn

func (c *Client) GetTunLocalAddrWithPortOnConn(conn *ClientConn) string

func (*Client) SendAllPing

func (c *Client) SendAllPing()

func (*Client) SendPacket

func (c *Client) SendPacket(pkt iface.PacketIP)

func (*Client) SendPing

func (c *Client) SendPing(conn *ClientConn)

func (*Client) Start

func (c *Client) Start()

func (*Client) Stop

func (c *Client) Stop()

func (*Client) Write

func (c *Client) Write(data []byte)

func (*Client) WriteNow

func (c *Client) WriteNow(data []byte)

随机找一个连接发送请求

type ClientConn

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

func NewClientConn

func NewClientConn(remoteAddr, key string, index int, parentWG *sync.WaitGroup) *ClientConn

func (*ClientConn) Close

func (this *ClientConn) Close()

func (*ClientConn) GetConnPort

func (sc *ClientConn) GetConnPort() string

为了使用 10.4.4.3:port 这样的格式来表示一条tcp连接

func (*ClientConn) IsConnected

func (this *ClientConn) IsConnected() bool

func (*ClientConn) SetHander

func (this *ClientConn) SetHander(handler GrpcHandler)

func (*ClientConn) Write

func (this *ClientConn) Write(data []byte)

func (*ClientConn) WriteNow

func (this *ClientConn) WriteNow(data []byte) error

type GrpcHandler

type GrpcHandler interface {
	OnData([]byte, *net.TCPConn)
}

type Server

type Server struct {
	Mtx *sync.Mutex

	//为了能够删除已经断开的连接,并能够反过来查询连接,所以有两个map
	Conns        map[string]*ServerConn
	ConnsReverse map[*net.TCPConn]string
	// contains filtered or unexported fields
}

func NewServer

func NewServer(publicAddr string, handler GrpcHandler, key string) *Server

func (*Server) GetConnsByAddr

func (s *Server) GetConnsByAddr(dst string) *ServerConn

func (*Server) RemoveConnByConnPointer

func (s *Server) RemoveConnByConnPointer(conn *net.TCPConn)

func (*Server) SetConns

func (s *Server) SetConns(dst string, conn *net.TCPConn)

func (*Server) Start

func (s *Server) Start()

func (*Server) StartListen

func (s *Server) StartListen()

type ServerConn

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

func NewServerConn

func NewServerConn(conn *net.TCPConn, key string, handler GrpcHandler) *ServerConn

func (*ServerConn) ProcessWrite

func (cc *ServerConn) ProcessWrite() (err error)

func (*ServerConn) SendPacket

func (sc *ServerConn) SendPacket(pkt iface.PacketIP)

func (*ServerConn) Write

func (cc *ServerConn) Write(data []byte)

func (*ServerConn) WriteNow

func (cc *ServerConn) WriteNow(data []byte) error

Jump to

Keyboard shortcuts

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