conn

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: MIT Imports: 20 Imported by: 4

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) GetAddStatus added in v0.0.15

func (s *Conn) GetAddStatus() (b bool)

func (*Conn) GetConfigInfo added in v0.0.15

func (s *Conn) GetConfigInfo() (c *file.Client, err error)

get task info

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) GetHostInfo added in v0.0.15

func (s *Conn) GetHostInfo() (h *file.Host, err error)

get task info

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) SendConfigInfo added in v0.0.15

func (s *Conn) SendConfigInfo(c *config.CommonConfig) (int, error)

send task info

func (*Conn) SendHostInfo added in v0.0.15

func (s *Conn) SendHostInfo(h *file.Host) (int, error)

send host info

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) WriteAddFail added in v0.0.15

func (s *Conn) WriteAddFail() error

func (*Conn) WriteAddOk added in v0.0.15

func (s *Conn) WriteAddOk() error

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) WriteConfig added in v0.0.15

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

write main

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)

单独写(加密|压缩)

func (*Conn) WriteWriteSuccess added in v0.0.16

func (s *Conn) WriteWriteSuccess(id int) 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
	MsgCh         chan []byte
	MsgConn       *Conn
	StatusCh      chan bool
	FinishUse     bool
}
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

func (*Link) Run added in v0.0.16

func (s *Link) Run(flow bool)

type Secret added in v0.0.16

type Secret struct {
	Password string
	Conn     *Conn
}

func NewSecret added in v0.0.16

func NewSecret(p string, conn *Conn) *Secret

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