Documentation
¶
Index ¶
- Constants
- Variables
- func Accept(l net.Listener, f func(c net.Conn))
- func CheckFlowLimits(f *file.Flow, label string) error
- func CopyWaitGroup(conn1, conn2 net.Conn, crypt bool, snappy bool, rate *rate.Rate, ...)
- func DescribeNetError(err error, c net.Conn) string
- func DialKCPWithLocalIP(raddr string, localIP string) (*kcp.UDPSession, error)
- func DialQuicWithLocalIP(ctx context.Context, server string, tlsCfg *tls.Config, quicCfg *quic.Config, ...) (*quic.Conn, error)
- func DialVirtual(ctx context.Context, l *netx.ChanListener, remote string) (net.Conn, error)
- func DialWS(rawConn net.Conn, urlStr, host string, timeout time.Duration) (*websocket.Conn, *http.Response, error)
- func DialWSS(rawConn net.Conn, urlStr, host, sni string, timeout time.Duration) (*websocket.Conn, *http.Response, error)
- func GetConn(conn net.Conn, cpt, snappy bool, rt *rate.Rate, isServer, isLocal bool) io.ReadWriteCloser
- func GetLenBytes(buf []byte) (b []byte, err error)
- func GetRealIP(r *http.Request, header string) string
- func GetTlsConn(c net.Conn, sni string) (net.Conn, error)
- func HandleUdp5(ctx context.Context, serverConn net.Conn, timeout time.Duration, ...)
- func IsBrokenPipe(err error) bool
- func IsConnAborted(err error) bool
- func IsConnReset(err error) bool
- func IsTimeout(err error) bool
- func Join(c1, c2 net.Conn, flows []*file.Flow, task *file.Tunnel, remote string)
- func NetErrorKind(err error) string
- func NewKCPSessionWithConn(raddr *net.UDPAddr, pc net.PacketConn) (*kcp.UDPSession, error)
- func NewKcpListenerAndProcess(addr string, f func(c net.Conn)) error
- func NewQuicListenerAndProcess(addr string, tlsConfig *tls.Config, quicConfig *quic.Config, ...) error
- func NewUdpConnByAddr(addr string) (net.PacketConn, error)
- func NewVirtualListener(addr net.Addr) *netx.ChanListener
- func NewWSListener(base net.Listener, path, trustedIps, realIpHeader string) net.Listener
- func NewWSSListener(base net.Listener, path string, cert tls.Certificate, ...) net.Listener
- func ParseAddr(addr string) net.Addr
- func ParseTCPAddr(s string) (net.Addr, error)
- func ProxyProtocolHeader(version int, client, target net.Addr) *proxyproto.Header
- func ReadACK(c net.Conn, timeout time.Duration) error
- func ServeVirtual(l *netx.ChanListener, c net.Conn)
- func SetUdpSession(sess *kcp.UDPSession)
- func WriteACK(c net.Conn, timeout time.Duration) error
- type Conn
- func (s *Conn) BufferWrite(b []byte) (int, error)
- func (s *Conn) Close() error
- func (s *Conn) FlushBuf() error
- func (s *Conn) GetAddStatus() (b bool)
- func (s *Conn) GetConfigInfo() (*file.Client, error)
- func (s *Conn) GetHealthInfo() (info string, status bool, err error)
- func (s *Conn) GetHost() (address string, r *http.Request, head, rest []byte, err error)
- func (s *Conn) GetHostInfo() (*file.Host, error)
- func (s *Conn) GetLen() (int, error)
- func (s *Conn) GetLinkInfo() (lk *Link, err error)
- func (s *Conn) GetShortContent(l int) (b []byte, err error)
- func (s *Conn) GetShortLenContent() (b []byte, err error)
- func (s *Conn) GetTaskInfo() (*file.Tunnel, error)
- func (s *Conn) IsClosed() bool
- func (s *Conn) LocalAddr() net.Addr
- func (s *Conn) OnClose(fn func(*Conn)) *Conn
- func (s *Conn) Read(b []byte) (n int, err error)
- func (s *Conn) ReadFlag() (string, error)
- func (s *Conn) ReadLen(cLen int, buf []byte) (int, error)
- func (s *Conn) RemoteAddr() net.Addr
- func (s *Conn) SendHealthInfo(info, status string) (int, error)
- func (s *Conn) SendInfo(t interface{}, flag string) (int, error)
- func (s *Conn) SetAlive()
- func (s *Conn) SetDeadline(t time.Time) error
- func (s *Conn) SetRb(rbs ...[]byte) *Conn
- func (s *Conn) SetReadDeadline(t time.Time) error
- func (s *Conn) SetReadDeadlineBySecond(t time.Duration)
- func (s *Conn) SetWriteDeadline(t time.Time) error
- func (s *Conn) Write(b []byte) (n int, err error)
- func (s *Conn) WriteAddFail() error
- func (s *Conn) WriteAddOk() error
- func (s *Conn) WriteChan() (int, error)
- func (s *Conn) WriteClose() (int, error)
- func (s *Conn) WriteConfig() (int, error)
- func (s *Conn) WriteLenContent(buf []byte) (err error)
- func (s *Conn) WriteMain() (int, error)
- type FlowConn
- type Link
- type Option
- type Options
- type QuicAutoCloseConn
- type QuicStreamConn
- func (q *QuicStreamConn) Close() error
- func (q *QuicStreamConn) GetSession() *quic.Conn
- func (q *QuicStreamConn) LocalAddr() net.Addr
- func (q *QuicStreamConn) Read(p []byte) (int, error)
- func (q *QuicStreamConn) RemoteAddr() net.Addr
- func (q *QuicStreamConn) SetDeadline(t time.Time) error
- func (q *QuicStreamConn) SetReadDeadline(t time.Time) error
- func (q *QuicStreamConn) SetWriteDeadline(t time.Time) error
- func (q *QuicStreamConn) Write(p []byte) (int, error)
- type RWConn
- type Secret
- type SmartUdpConn
- func (s *SmartUdpConn) Close() error
- func (s *SmartUdpConn) LocalAddr() net.Addr
- func (s *SmartUdpConn) ReadFrom(p []byte) (int, net.Addr, error)
- func (s *SmartUdpConn) SetDeadline(t time.Time) error
- func (s *SmartUdpConn) SetReadDeadline(t time.Time) error
- func (s *SmartUdpConn) SetWriteDeadline(t time.Time) error
- func (s *SmartUdpConn) UDPConns() []*net.UDPConn
- func (s *SmartUdpConn) WriteTo(p []byte, addr net.Addr) (int, error)
- type SnappyConn
- type TeeConn
- func (t *TeeConn) Buffered() []byte
- func (t *TeeConn) Close() error
- func (t *TeeConn) ExtractAndReset() []byte
- func (t *TeeConn) LocalAddr() net.Addr
- func (t *TeeConn) Read(p []byte) (n int, err error)
- func (t *TeeConn) Release() (net.Conn, []byte)
- func (t *TeeConn) RemoteAddr() net.Addr
- func (t *TeeConn) ResetBuffer()
- func (t *TeeConn) SetDeadline(deadline time.Time) error
- func (t *TeeConn) SetReadDeadline(deadline time.Time) error
- func (t *TeeConn) SetWriteDeadline(deadline time.Time) error
- func (t *TeeConn) StopAndClean()
- func (t *TeeConn) StopBuffering()
- func (t *TeeConn) Write(p []byte) (n int, err error)
- type TlsConn
- func (c *TlsConn) Close() error
- func (c *TlsConn) GetRawConn() net.Conn
- func (c *TlsConn) LocalAddr() net.Addr
- func (c *TlsConn) Read(b []byte) (n int, err error)
- func (c *TlsConn) RemoteAddr() net.Addr
- func (c *TlsConn) SetDeadline(t time.Time) error
- func (c *TlsConn) SetReadDeadline(t time.Time) error
- func (c *TlsConn) SetWriteDeadline(t time.Time) error
- func (c *TlsConn) Write(b []byte) (n int, err error)
- type WsConn
- func (c *WsConn) Close() error
- func (c *WsConn) LocalAddr() net.Addr
- func (c *WsConn) Read(p []byte) (int, error)
- func (c *WsConn) RemoteAddr() net.Addr
- func (c *WsConn) SetDeadline(t time.Time) error
- func (c *WsConn) SetReadDeadline(t time.Time) error
- func (c *WsConn) SetWriteDeadline(t time.Time) error
- func (c *WsConn) Write(p []byte) (int, error)
Constants ¶
const HandshakeTimeout = 10 * time.Second
HandshakeTimeout bounds how long an accepted transport may take to present its first stream or protocol upgrade before it is dropped.
Variables ¶
var LocalTCPAddr = &net.TCPAddr{IP: net.ParseIP("127.0.0.1")}
Functions ¶
func CheckFlowLimits ¶ added in v0.29.25
CheckFlowLimits returns an error naming label if f is over its traffic limit or past its time limit.
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, isLocal, isFramed bool)
CopyWaitGroup conn1 mux conn
func DialKCPWithLocalIP ¶ added in v0.34.6
func DialKCPWithLocalIP(raddr string, localIP string) (*kcp.UDPSession, error)
DialKCPWithLocalIP creates a KCP connection with optional local IP binding.
func DialQuicWithLocalIP ¶ added in v0.34.7
func DialVirtual ¶ added in v0.34.8
DialVirtual connects to l through an in-memory pipe, with remote, a host:port address, as the address of the dialing side. It waits for queue space until ctx is done or l is closed.
func GetConn ¶
func GetConn(conn net.Conn, cpt, snappy bool, rt *rate.Rate, isServer, isLocal bool) io.ReadWriteCloser
GetConn get crypt or snappy conn
func GetLenBytes ¶
GetLenBytes get the assembled amount data(len 4 and content)
func HandleUdp5 ¶ added in v0.30.6
HandleUdp5 relays the SOCKS5 UDP datagrams of serverConn, one per frame, through a local UDP socket: each datagram's payload goes to its destination, and each datagram received goes back with its source as the address.
func IsBrokenPipe ¶ added in v0.34.8
func IsConnAborted ¶ added in v0.34.8
func IsConnReset ¶ added in v0.34.8
func Join ¶ added in v0.34.8
Join relays between c1 and c2 until either direction ends, then closes both. Every byte written either way is added as both inlet and export traffic to each of flows, and the relay stops once one of them is over its limits; the first bytes of each direction set task.IsHttp.
func NetErrorKind ¶ added in v0.34.8
func NewKCPSessionWithConn ¶ added in v0.34.6
func NewKCPSessionWithConn(raddr *net.UDPAddr, pc net.PacketConn) (*kcp.UDPSession, error)
NewKCPSessionWithConn creates a KCP session based on an existing PacketConn.
func NewQuicListenerAndProcess ¶ added in v0.29.26
func NewUdpConnByAddr ¶ added in v0.30.4
func NewUdpConnByAddr(addr string) (net.PacketConn, error)
func NewVirtualListener ¶ added in v0.30.6
func NewVirtualListener(addr net.Addr) *netx.ChanListener
NewVirtualListener returns an in-memory listener that reports addr, or LocalTCPAddr when addr is nil.
func NewWSListener ¶ added in v0.27.0
func NewWSSListener ¶ added in v0.27.0
func ParseTCPAddr ¶ added in v0.34.8
ParseTCPAddr resolves s, a host:port address. An empty s yields a nil address and no error.
func ProxyProtocolHeader ¶ added in v0.34.8
func ProxyProtocolHeader(version int, client, target net.Addr) *proxyproto.Header
ProxyProtocolHeader returns the PROXY protocol header of version 1 or 2 for a connection from client to target, or nil for any other version. The addresses are taken as proxyproto.NewHeader takes them: an unknown or unspecified target becomes the zero address of the client's family, and an IPv4 and an IPv6 address are both sent as IPv6. A pair that it rejects, such as a nil client, an address without an IP or addresses of other types, gives a header without addresses ("PROXY UNKNOWN" for version 1, a PROXY command of the AF_UNSPEC family for version 2), so that the backend uses the connection's own addresses.
func ServeVirtual ¶ added in v0.34.8
func ServeVirtual(l *netx.ChanListener, c net.Conn)
ServeVirtual hands c to l, closing c if l is closed or its queue is full.
Types ¶
type Conn ¶
func (*Conn) GetAddStatus ¶
GetAddStatus get task or host result of add
func (*Conn) GetConfigInfo ¶
GetConfigInfo get client config info
func (*Conn) GetHealthInfo ¶
GetHealthInfo get health info from conn
func (*Conn) GetHost ¶
GetHost reads one HTTP proxy request header from the connection and resolves the target address. head holds the raw header bytes and rest holds everything read past the header (request body, pipelined requests or early tunnel data) followed by any data still queued on the connection, so nothing stays queued on return. On error head holds every byte consumed so far.
func (*Conn) GetHostInfo ¶
GetHostInfo get host info
func (*Conn) GetLinkInfo ¶
GetLinkInfo get link info from conn
func (*Conn) GetShortLenContent ¶
func (*Conn) GetTaskInfo ¶
GetTaskInfo get task info
func (*Conn) RemoteAddr ¶
func (*Conn) SendHealthInfo ¶
SendHealthInfo send info for link
func (*Conn) SetReadDeadlineBySecond ¶
SetReadDeadlineBySecond set read deadline
func (*Conn) WriteAddFail ¶
func (*Conn) WriteAddOk ¶
func (*Conn) WriteLenContent ¶
type FlowConn ¶ added in v0.28.3
type FlowConn struct {
*RWConn
// contains filtered or unexported fields
}
func NewFlowConn ¶ added in v0.28.3
func NewFlowConn(conn io.ReadWriteCloser, task, client *file.Flow) *FlowConn
type Link ¶
type QuicAutoCloseConn ¶ added in v0.30.4
type QuicAutoCloseConn struct{ *QuicStreamConn }
func NewQuicAutoCloseConn ¶ added in v0.30.4
func NewQuicAutoCloseConn(stream *quic.Stream, sess *quic.Conn) *QuicAutoCloseConn
func (*QuicAutoCloseConn) Close ¶ added in v0.30.4
func (q *QuicAutoCloseConn) Close() error
type QuicStreamConn ¶ added in v0.30.4
type QuicStreamConn struct {
// contains filtered or unexported fields
}
func NewQuicStreamConn ¶ added in v0.30.4
func NewQuicStreamConn(stream *quic.Stream, sess *quic.Conn) *QuicStreamConn
func (*QuicStreamConn) Close ¶ added in v0.30.4
func (q *QuicStreamConn) Close() error
func (*QuicStreamConn) GetSession ¶ added in v0.31.0
func (q *QuicStreamConn) GetSession() *quic.Conn
func (*QuicStreamConn) LocalAddr ¶ added in v0.30.4
func (q *QuicStreamConn) LocalAddr() net.Addr
func (*QuicStreamConn) RemoteAddr ¶ added in v0.30.4
func (q *QuicStreamConn) RemoteAddr() net.Addr
func (*QuicStreamConn) SetDeadline ¶ added in v0.30.4
func (q *QuicStreamConn) SetDeadline(t time.Time) error
func (*QuicStreamConn) SetReadDeadline ¶ added in v0.30.4
func (q *QuicStreamConn) SetReadDeadline(t time.Time) error
func (*QuicStreamConn) SetWriteDeadline ¶ added in v0.30.4
func (q *QuicStreamConn) SetWriteDeadline(t time.Time) error
type RWConn ¶ added in v0.28.3
type RWConn struct {
io.ReadWriteCloser
FakeAddr net.Addr
}
func NewRWConn ¶ added in v0.28.3
func NewRWConn(conn io.ReadWriteCloser) *RWConn
func (*RWConn) RemoteAddr ¶ added in v0.28.3
func (*RWConn) SetReadDeadline ¶ added in v0.28.3
type SmartUdpConn ¶ added in v0.30.4
type SmartUdpConn struct {
// contains filtered or unexported fields
}
func NewSmartUdpConn ¶ added in v0.30.4
func NewSmartUdpConn(conns []net.PacketConn, addr *net.UDPAddr) *SmartUdpConn
func (*SmartUdpConn) Close ¶ added in v0.30.4
func (s *SmartUdpConn) Close() error
func (*SmartUdpConn) LocalAddr ¶ added in v0.30.4
func (s *SmartUdpConn) LocalAddr() net.Addr
func (*SmartUdpConn) SetDeadline ¶ added in v0.30.4
func (s *SmartUdpConn) SetDeadline(t time.Time) error
func (*SmartUdpConn) SetReadDeadline ¶ added in v0.30.4
func (s *SmartUdpConn) SetReadDeadline(t time.Time) error
func (*SmartUdpConn) SetWriteDeadline ¶ added in v0.30.4
func (s *SmartUdpConn) SetWriteDeadline(t time.Time) error
func (*SmartUdpConn) UDPConns ¶ added in v0.34.8
func (s *SmartUdpConn) UDPConns() []*net.UDPConn
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
type TeeConn ¶ added in v0.30.4
type TeeConn struct {
// contains filtered or unexported fields
}
func (*TeeConn) ExtractAndReset ¶ added in v0.30.4
func (*TeeConn) RemoteAddr ¶ added in v0.30.4
func (*TeeConn) ResetBuffer ¶ added in v0.30.4
func (t *TeeConn) ResetBuffer()
func (*TeeConn) SetDeadline ¶ added in v0.30.4
func (*TeeConn) SetReadDeadline ¶ added in v0.30.4
func (*TeeConn) SetWriteDeadline ¶ added in v0.30.4
func (*TeeConn) StopAndClean ¶ added in v0.30.4
func (t *TeeConn) StopAndClean()
func (*TeeConn) StopBuffering ¶ added in v0.30.4
func (t *TeeConn) StopBuffering()