transport

package
v0.0.0-...-8c1276b Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2019 License: Apache-2.0 Imports: 19 Imported by: 1

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) *Client

func (*Client) ConnectWait

func (c *Client) ConnectWait()

func (*Client) GetRemotePortRandom

func (c *Client) GetRemotePortRandom() string

随机找一个可用的连接,为了获取连接地址

func (*Client) SetHandler

func (c *Client) SetHandler(handler ServerHandler)

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 (cc *ClientConn) Close()

func (*ClientConn) GetConnPort

func (sc *ClientConn) GetConnPort() string

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

func (*ClientConn) IsConnected

func (cc *ClientConn) IsConnected() bool

func (*ClientConn) SetHander

func (cc *ClientConn) SetHander(handler ServerHandler)

func (*ClientConn) Write

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

func (*ClientConn) WriteNow

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

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, privateAddr string, handler ServerHandler, 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) SetConfig

func (s *Server) SetConfig(cfg config.Config)

func (*Server) SetConns

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

func (*Server) Start

func (s *Server) Start()

type ServerConn

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

func NewServerConn

func NewServerConn(conn *net.TCPConn, key string, handler ServerHandler) *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

type ServerHandler

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

Jump to

Keyboard shortcuts

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