conn

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2019 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLenByBytes

func GetLenByBytes(buf []byte) (int, error)

解析出长度

func GetLenBytes

func GetLenBytes(buf []byte) (b []byte, err error)

获取长度+内容

func SetUdpSession

func SetUdpSession(sess *kcp.UDPSession)

Types

type Conn

type Conn struct {
	Conn net.Conn
	sync.Mutex
}

func NewConn

func NewConn(conn net.Conn) *Conn

new conn

func (*Conn) Close

func (s *Conn) Close() error

close

func (*Conn) GetConnStatus

func (s *Conn) GetConnStatus() (id int, status bool, err error)

read connect status

func (*Conn) GetHost

func (s *Conn) GetHost() (method, address string, rb []byte, err error, r *http.Request)

从tcp报文中解析出host,连接类型等

func (*Conn) GetLen

func (s *Conn) GetLen() (int, error)

read length or id (content length=4)

func (*Conn) GetLinkInfo

func (s *Conn) GetLinkInfo() (lk *Link, err error)

func (*Conn) GetMsgContent

func (s *Conn) GetMsgContent(link *Link) (content []byte, err error)

get msg content from conn

func (*Conn) GetTaskInfo

func (s *Conn) GetTaskInfo() (t *file.Tunnel, err error)

get task info

func (*Conn) Read

func (s *Conn) Read(b []byte) (int, error)

read

func (*Conn) ReadFlag

func (s *Conn) ReadFlag() (string, error)

read flag

func (*Conn) ReadFrom

func (s *Conn) ReadFrom(b []byte, compress int, crypt bool, rate *rate.Rate) (int, error)

单独读(加密|压缩)

func (*Conn) ReadLen

func (s *Conn) ReadLen(cLen int) ([]byte, error)

读取指定长度内容

func (*Conn) SendLinkInfo

func (s *Conn) SendLinkInfo(link *Link) (int, error)

send info for link

func (*Conn) SendMsg

func (s *Conn) SendMsg(content []byte, link *Link) (n int, err error)

send msg

func (*Conn) SendTaskInfo

func (s *Conn) SendTaskInfo(t *file.Tunnel) (int, error)

send task info

func (*Conn) SetAlive

func (s *Conn) SetAlive(tp string)

设置连接为长连接

func (*Conn) SetKcpReadDeadline

func (s *Conn) SetKcpReadDeadline(t time.Duration)

set read dead time

func (*Conn) SetReadDeadline

func (s *Conn) SetReadDeadline(t time.Duration, tp string)

设置连接为长连接

func (*Conn) SetTcpReadDeadline

func (s *Conn) SetTcpReadDeadline(t time.Duration)

set read dead time

func (*Conn) Write

func (s *Conn) Write(b []byte) (int, error)

write

func (*Conn) WriteChan

func (s *Conn) WriteChan() (int, error)

write chan

func (*Conn) WriteClose

func (s *Conn) WriteClose() (int, error)

write sign flag

func (*Conn) WriteError

func (s *Conn) WriteError() (int, error)

write error

func (*Conn) WriteFail

func (s *Conn) WriteFail(id int) (int, error)

write connect fail

func (*Conn) WriteMain

func (s *Conn) WriteMain() (int, error)

write main

func (*Conn) WriteSign

func (s *Conn) WriteSign() (int, error)

write sign flag

func (*Conn) WriteSuccess

func (s *Conn) WriteSuccess(id int) (int, error)

write connect success

func (*Conn) WriteTo

func (s *Conn) WriteTo(b []byte, compress int, crypt bool, rate *rate.Rate) (n int, err error)

单独写(加密|压缩)

type CryptConn

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

func NewCryptConn

func NewCryptConn(conn net.Conn, crypt bool, rate *rate.Rate) *CryptConn

func (*CryptConn) Read

func (s *CryptConn) Read(b []byte) (n int, err error)

解密读

func (*CryptConn) Write

func (s *CryptConn) Write(b []byte) (n int, err error)

加密写

type Link struct {
	Id            int    //id
	ConnType      string //连接类型
	Host          string //目标
	En            int    //加密
	De            int    //解密
	Crypt         bool   //加密
	Conn          *Conn
	Flow          *file.Flow
	UdpListener   *net.UDPConn
	Rate          *rate.Rate
	UdpRemoteAddr *net.UDPAddr
}
func NewLink(id int, connType string, host string, en, de int, crypt bool, c *Conn, flow *file.Flow, udpListener *net.UDPConn, rate *rate.Rate, UdpRemoteAddr *net.UDPAddr) *Link

type SnappyConn

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

func NewSnappyConn

func NewSnappyConn(conn net.Conn, crypt bool, rate *rate.Rate) *SnappyConn

func (*SnappyConn) Read

func (s *SnappyConn) Read(b []byte) (n int, err error)

snappy压缩读 包含解密

func (*SnappyConn) Write

func (s *SnappyConn) Write(b []byte) (n int, err error)

snappy压缩写 包含加密

Jump to

Keyboard shortcuts

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