conn

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2025 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accept

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

func BuildProxyProtocolHeader

func BuildProxyProtocolHeader(c net.Conn, proxyProtocol int) []byte

构造 Proxy Protocol 头部

func BuildProxyProtocolHeaderByAddr

func BuildProxyProtocolHeaderByAddr(clientAddr, targetAddr *net.TCPAddr, proxyProtocol int) []byte

func BuildProxyProtocolV1Header

func BuildProxyProtocolV1Header(clientAddr, targetAddr *net.TCPAddr) []byte

构造 Proxy Protocol v1 头部

func BuildProxyProtocolV2Header

func BuildProxyProtocolV2Header(clientAddr, targetAddr *net.TCPAddr) []byte

构造 Proxy Protocol v2 头部

func CopyWaitGroup

func CopyWaitGroup(conn1, conn2 net.Conn, crypt bool, snappy bool, rate *rate.Rate,
	flows []*file.Flow, isServer bool, proxyProtocol int, rb []byte, task *file.Tunnel)

conn1 mux conn

func DialWS added in v0.27.0

func DialWS(ctx context.Context, urlStr string, timeout time.Duration) (net.Conn, error)

func DialWSS added in v0.27.0

func DialWSS(ctx context.Context, urlStr string, timeout time.Duration) (net.Conn, error)

func GetConn

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

get crypt or snappy conn

func GetLenBytes

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

get the assembled amount data(len 4 and content)

func NewKcpListenerAndProcess

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

func NewTcpListenerAndProcess

func NewTcpListenerAndProcess(addr string, f func(c net.Conn), listener *net.Listener) error

func NewWSListener added in v0.27.0

func NewWSListener(base net.Listener, path string) net.Listener

func NewWSSListener added in v0.27.0

func NewWSSListener(base net.Listener, path string, cert tls.Certificate) net.Listener

func SetUdpSession

func SetUdpSession(sess *kcp.UDPSession)

udp connection setting

Types

type Conn

type Conn struct {
	Conn net.Conn
	Rb   []byte
}

func NewConn

func NewConn(conn net.Conn) *Conn

new conn

func (*Conn) Close

func (s *Conn) Close() error

close

func (*Conn) GetAddStatus

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

get task or host result of add

func (*Conn) GetConfigInfo

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

get task info

func (*Conn) GetHealthInfo

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)

get host 、connection type、method...from connection

func (*Conn) GetHostInfo

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

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

func (*Conn) GetShortLenContent

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

func (s *Conn) LocalAddr() net.Addr

func (*Conn) Read

func (s *Conn) Read(b []byte) (n int, err 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) RemoteAddr

func (s *Conn) RemoteAddr() net.Addr

func (*Conn) SendHealthInfo

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

send info for link

func (*Conn) SendInfo

func (s *Conn) SendInfo(t interface{}, flag string) (int, error)

send info

func (*Conn) SetAlive

func (s *Conn) SetAlive()

set alive

func (*Conn) SetDeadline

func (s *Conn) SetDeadline(t time.Time) error

func (*Conn) SetReadDeadline

func (s *Conn) SetReadDeadline(t time.Time) error

func (*Conn) SetReadDeadlineBySecond

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

set read deadline

func (*Conn) SetWriteDeadline

func (s *Conn) SetWriteDeadline(t time.Time) error

func (*Conn) Write

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

write

func (*Conn) WriteAddFail

func (s *Conn) WriteAddFail() error

func (*Conn) WriteAddOk

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

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

write main

func (*Conn) WriteLenContent

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

func (*Conn) WriteMain

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

write main

type LenConn

type LenConn struct {
	Len int
	// contains filtered or unexported fields
}

func NewLenConn

func NewLenConn(conn io.Writer) *LenConn

func (*LenConn) Write

func (c *LenConn) Write(p []byte) (n int, err error)
type Link struct {
	ConnType   string //连接类型
	Host       string //目标
	Crypt      bool   //加密
	Compress   bool
	LocalProxy bool
	RemoteAddr string
	Option     Options
}
func NewLink(connType string, host string, crypt bool, compress bool, remoteAddr string, localProxy bool, opts ...Option) *Link

type Option

type Option func(*Options)

func LinkTimeout

func LinkTimeout(t time.Duration) Option

type Options

type Options struct {
	Timeout time.Duration
}

type Secret

type Secret struct {
	Password string
	Conn     *Conn
}

func NewSecret

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

type SnappyConn

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

func NewSnappyConn

func NewSnappyConn(conn io.ReadWriteCloser) *SnappyConn

func (*SnappyConn) Close

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压缩写

type TlsConn added in v0.26.48

type TlsConn struct {
	*tls.Conn
	// contains filtered or unexported fields
}

func NewTlsConn added in v0.26.48

func NewTlsConn(rawConn net.Conn, timeout time.Duration, tlsConfig *tls.Config) (*TlsConn, error)

func (*TlsConn) Close added in v0.26.48

func (c *TlsConn) Close() error

func (*TlsConn) GetRawConn added in v0.26.48

func (c *TlsConn) GetRawConn() net.Conn

func (*TlsConn) LocalAddr added in v0.26.48

func (c *TlsConn) LocalAddr() net.Addr

func (*TlsConn) Read added in v0.26.48

func (c *TlsConn) Read(b []byte) (n int, err error)

func (*TlsConn) RemoteAddr added in v0.26.48

func (c *TlsConn) RemoteAddr() net.Addr

func (*TlsConn) SetDeadline added in v0.26.48

func (c *TlsConn) SetDeadline(t time.Time) error

func (*TlsConn) SetReadDeadline added in v0.26.48

func (c *TlsConn) SetReadDeadline(t time.Time) error

func (*TlsConn) SetWriteDeadline added in v0.26.48

func (c *TlsConn) SetWriteDeadline(t time.Time) error

func (*TlsConn) Write added in v0.26.48

func (c *TlsConn) Write(b []byte) (n int, err error)

type WSConn added in v0.27.0

type WSConn struct {
	*websocket.Conn
	// contains filtered or unexported fields
}

func NewWSConn added in v0.27.0

func NewWSConn(ws *websocket.Conn) *WSConn

func (*WSConn) Close added in v0.27.0

func (c *WSConn) Close() error

func (*WSConn) LocalAddr added in v0.27.0

func (c *WSConn) LocalAddr() net.Addr

func (*WSConn) Read added in v0.27.0

func (c *WSConn) Read(p []byte) (int, error)

func (*WSConn) RemoteAddr added in v0.27.0

func (c *WSConn) RemoteAddr() net.Addr

func (*WSConn) SetDeadline added in v0.27.0

func (c *WSConn) SetDeadline(t time.Time) error

func (*WSConn) SetReadDeadline added in v0.27.0

func (c *WSConn) SetReadDeadline(t time.Time) error

func (*WSConn) SetWriteDeadline added in v0.27.0

func (c *WSConn) SetWriteDeadline(t time.Time) error

func (*WSConn) Write added in v0.27.0

func (c *WSConn) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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