conn

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2019 License: MIT Imports: 22 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accept added in v0.19.0

func Accept(l net.Listener, f func(c net.Conn))

func CopyWaitGroup added in v0.18.0

func CopyWaitGroup(conn1, conn2 net.Conn, crypt bool, snappy bool, rate *rate.Rate, flow *file.Flow, isServer bool)

conn1 mux conn

func GetConn added in v0.18.0

func GetConn(conn net.Conn, cpt, snappy bool, rate *rate.Rate, isServer bool) io.ReadWriteCloser

get crypt or snappy conn

func GetLen added in v0.18.0

func GetLen(reader io.Reader) (int, error)

read length or id (content length=4)

func GetLenBytes

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

获取长度+内容

func NewKcpListenerAndProcess added in v0.19.0

func NewKcpListenerAndProcess(addr string, f func(c net.Conn)) error

func NewTcpListenerAndProcess added in v0.19.0

func NewTcpListenerAndProcess(addr string, f func(c net.Conn), listener *net.Listener) 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)

get task or host result of add

func (*Conn) GetConfigInfo added in v0.0.15

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

get task info

func (*Conn) GetHealthInfo added in v0.18.1

func (s *Conn) GetHealthInfo() (info string, status bool, err error)

get health info from conn

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)

func (*Conn) GetLinkInfo

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

get link info from conn

func (*Conn) GetShortContent added in v0.18.0

func (s *Conn) GetShortContent(l int) (b []byte, err error)

func (*Conn) GetShortLenContent added in v0.18.0

func (s *Conn) GetShortLenContent() (b []byte, err error)

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) ReadLen

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

读取指定长度内容

func (*Conn) SendConfigInfo added in v0.0.15

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

send task info

func (*Conn) SendHealthInfo added in v0.18.1

func (s *Conn) SendHealthInfo(info, status string) (int, error)

send info for link

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) SendTaskInfo

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

send task info

func (*Conn) SetAlive

func (s *Conn) SetAlive(tp string)

设置连接为长连接

func (*Conn) SetReadDeadline

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

设置连接为长连接

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) WriteLenContent added in v0.18.0

func (s *Conn) WriteLenContent(buf []byte) (err error)

func (*Conn) WriteMain

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

write main

type Link struct {
	ConnType   string //连接类型
	Host       string //目标
	Crypt      bool   //加密
	Compress   bool
	RemoteAddr string
}
func NewLink(connType string, host string, crypt bool, compress bool, remoteAddr string) *Link

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 io.ReadWriteCloser, crypt bool, rate *rate.Rate) *SnappyConn

func (*SnappyConn) Close added in v0.18.0

func (s *SnappyConn) Close() error

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