conn

package
v0.29.16 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LocalTCPAddr = &net.TCPAddr{IP: net.ParseIP("127.0.0.1")}

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

func DialWS(rawConn net.Conn, urlStr string, timeout time.Duration) (*websocket.Conn, *http.Response, error)

func DialWSS

func DialWSS(rawConn net.Conn, urlStr string, timeout time.Duration) (*websocket.Conn, *http.Response, 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

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

func NewWSSListener

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 FlowConn

type FlowConn struct {
	*RWConn
	// contains filtered or unexported fields
}

func NewFlowConn

func NewFlowConn(conn io.ReadWriteCloser, task, client *file.Flow) *FlowConn

func (*FlowConn) Read

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

func (*FlowConn) Write

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

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 OneConnListener

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

func NewOneConnListener

func NewOneConnListener(c net.Conn) *OneConnListener

func (*OneConnListener) Accept

func (l *OneConnListener) Accept() (net.Conn, error)

func (*OneConnListener) Addr

func (l *OneConnListener) Addr() net.Addr

func (*OneConnListener) Close

func (l *OneConnListener) Close() error

type Option

type Option func(*Options)

func LinkTimeout

func LinkTimeout(t time.Duration) Option

type Options

type Options struct {
	Timeout time.Duration
}

type RWConn

type RWConn struct {
	io.ReadWriteCloser
	FakeAddr net.Addr
}

func NewRWConn

func NewRWConn(conn io.ReadWriteCloser) *RWConn

func (*RWConn) LocalAddr

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

func (*RWConn) RemoteAddr

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

func (*RWConn) SetDeadline

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

func (*RWConn) SetReadDeadline

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

func (*RWConn) SetWriteDeadline

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

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

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

func NewTlsConn

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

func (*TlsConn) Close

func (c *TlsConn) Close() error

func (*TlsConn) GetRawConn

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

func (*TlsConn) LocalAddr

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

func (*TlsConn) Read

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

func (*TlsConn) RemoteAddr

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

func (*TlsConn) SetDeadline

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

func (*TlsConn) SetReadDeadline

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

func (*TlsConn) SetWriteDeadline

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

func (*TlsConn) Write

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

type WsConn

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

func NewWsConn

func NewWsConn(ws *websocket.Conn) *WsConn

func (*WsConn) Close

func (c *WsConn) Close() error

func (*WsConn) LocalAddr

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

func (*WsConn) Read

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

func (*WsConn) RemoteAddr

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

func (*WsConn) SetDeadline

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

func (*WsConn) SetReadDeadline

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

func (*WsConn) SetWriteDeadline

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

func (*WsConn) Write

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