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 (*Client) ConnectWait ¶
func (c *Client) ConnectWait()
func (*Client) GetRemotePortRandom ¶
随机找一个可用的连接,为了获取连接地址
func (*Client) SetHandler ¶
func (c *Client) SetHandler(handler ServerHandler)
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 ¶
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 ¶
Click to show internal directories.
Click to hide internal directories.