transporter

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

nolint: errcheck

nolint: errcheck

nolint: errcheck

nolint: errcheck

nolint: errcheck

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSmuxTransporter added in v1.1.2

func NewSmuxTransporter(l *zap.SugaredLogger,
	initSessionF func(ctx context.Context, addr string) (*smux.Session, error),
) *smuxTransporter

Types

type BufferCh

type BufferCh struct {
	Ch      chan []byte
	Handled atomic.Bool
	UDPAddr *net.UDPAddr
}

type BytePool added in v1.0.7

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

BytePool implements a leaky pool of []byte in the form of a bounded channel

var BufferPool *BytePool

全局pool

func NewBytePool added in v1.0.7

func NewBytePool(maxSize int, size int) (bp *BytePool)

NewBytePool creates a new BytePool bounded to the given maxSize, with new byte arrays sized based on width.

func (*BytePool) Get added in v1.0.7

func (bp *BytePool) Get() (b []byte)

Get gets a []byte from the BytePool, or creates a new one if none are available in the pool.

func (*BytePool) Put added in v1.0.7

func (bp *BytePool) Put(b []byte)

Put returns the given Buffer to the BytePool.

type MTCP added in v1.1.2

type MTCP struct {
	*Raw
	// contains filtered or unexported fields
}

func (*MTCP) HandleTCPConn added in v1.1.2

func (s *MTCP) HandleTCPConn(c net.Conn, remote *lb.Node) error

type MTCPClient added in v1.1.2

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

func NewMTCPClient added in v1.1.2

func NewMTCPClient(l *zap.SugaredLogger) *MTCPClient

func (*MTCPClient) InitNewSession added in v1.1.2

func (c *MTCPClient) InitNewSession(ctx context.Context, addr string) (*smux.Session, error)

type MTCPServer added in v1.1.2

type MTCPServer struct {
	L *zap.SugaredLogger
	// contains filtered or unexported fields
}

func NewMTCPServer added in v1.1.2

func NewMTCPServer(listenAddr string, raw *Raw, l *zap.SugaredLogger) *MTCPServer

func (*MTCPServer) Accept added in v1.1.2

func (s *MTCPServer) Accept() (conn net.Conn, err error)

func (*MTCPServer) Close added in v1.1.2

func (s *MTCPServer) Close() error

func (*MTCPServer) ListenAndServe added in v1.1.2

func (s *MTCPServer) ListenAndServe() error

type MWSSClient added in v1.1.2

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

func NewMWSSClient added in v1.1.2

func NewMWSSClient(l *zap.SugaredLogger) *MWSSClient

func (*MWSSClient) InitNewSession added in v1.1.2

func (c *MWSSClient) InitNewSession(ctx context.Context, addr string) (*smux.Session, error)

type MWSSServer

type MWSSServer struct {
	L *zap.SugaredLogger
	// contains filtered or unexported fields
}

func NewMWSSServer added in v1.0.6

func NewMWSSServer(listenAddr string, raw *Raw, l *zap.SugaredLogger) *MWSSServer

func (*MWSSServer) Accept

func (s *MWSSServer) Accept() (conn net.Conn, err error)

func (*MWSSServer) Close

func (s *MWSSServer) Close() error

func (*MWSSServer) HandleRequest added in v1.1.2

func (s *MWSSServer) HandleRequest(w http.ResponseWriter, r *http.Request)

func (*MWSSServer) ListenAndServe added in v1.1.2

func (s *MWSSServer) ListenAndServe() error

type Mwss

type Mwss struct {
	*Raw
	// contains filtered or unexported fields
}

func (*Mwss) HandleTCPConn

func (s *Mwss) HandleTCPConn(c net.Conn, remote *lb.Node) error

type Raw

type Raw struct {
	TCPRemotes     lb.RoundRobin
	UDPRemotes     lb.RoundRobin
	UDPBufferChMap map[string]*BufferCh

	L *zap.SugaredLogger
	// contains filtered or unexported fields
}

func (*Raw) GetOrCreateBufferCh

func (raw *Raw) GetOrCreateBufferCh(uaddr *net.UDPAddr) *BufferCh

func (*Raw) GetRemote added in v1.1.2

func (raw *Raw) GetRemote() *lb.Node

func (*Raw) HandleTCPConn

func (raw *Raw) HandleTCPConn(c net.Conn, remote *lb.Node) error

func (*Raw) HandleUDPConn

func (raw *Raw) HandleUDPConn(uaddr *net.UDPAddr, local *net.UDPConn)

type ReadOnlyMetricsReader added in v1.1.3

type ReadOnlyMetricsReader struct {
	io.Reader
	// contains filtered or unexported fields
}

func (ReadOnlyMetricsReader) Read added in v1.1.3

func (r ReadOnlyMetricsReader) Read(p []byte) (n int, err error)

type RelayTransporter

type RelayTransporter interface {
	// UDP相关
	GetOrCreateBufferCh(uaddr *net.UDPAddr) *BufferCh
	HandleUDPConn(uaddr *net.UDPAddr, local *net.UDPConn)

	HandleTCPConn(c net.Conn, remote *lb.Node) error
	GetRemote() *lb.Node
	// contains filtered or unexported methods
}

RelayTransporter

func PickTransporter

func PickTransporter(transType string, tcpRemotes, udpRemotes lb.RoundRobin) RelayTransporter

type SessionWithMetrics added in v1.1.2

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

func (*SessionWithMetrics) CanNotServe added in v1.1.2

func (sm *SessionWithMetrics) CanNotServe() bool

type WSSServer added in v1.1.2

type WSSServer struct {
	L *zap.SugaredLogger
	// contains filtered or unexported fields
}

func NewWSSServer added in v1.1.2

func NewWSSServer(listenAddr string, raw *Raw, l *zap.SugaredLogger) *WSSServer

func (*WSSServer) Close added in v1.1.2

func (s *WSSServer) Close() error

func (*WSSServer) HandleRequest added in v1.1.2

func (s *WSSServer) HandleRequest(w http.ResponseWriter, req *http.Request)

func (*WSSServer) ListenAndServe added in v1.1.2

func (s *WSSServer) ListenAndServe() error

type WSServer added in v1.1.2

type WSServer struct {
	L *zap.SugaredLogger
	// contains filtered or unexported fields
}

func NewWSServer added in v1.1.2

func NewWSServer(listenAddr string, raw *Raw, l *zap.SugaredLogger) *WSServer

func (*WSServer) Close added in v1.1.2

func (s *WSServer) Close() error

func (*WSServer) HandleRequest added in v1.1.2

func (s *WSServer) HandleRequest(w http.ResponseWriter, req *http.Request)

func (*WSServer) ListenAndServe added in v1.1.2

func (s *WSServer) ListenAndServe() error

type WriteOnlyMetricsWriter added in v1.1.3

type WriteOnlyMetricsWriter struct {
	io.Writer
	// contains filtered or unexported fields
}

func (WriteOnlyMetricsWriter) Write added in v1.1.3

func (w WriteOnlyMetricsWriter) Write(p []byte) (n int, err error)

type Ws

type Ws struct {
	*Raw
}

func (*Ws) HandleTCPConn

func (s *Ws) HandleTCPConn(c net.Conn, remote *lb.Node) error

type Wss

type Wss struct {
	*Raw
}

func (*Wss) HandleTCPConn

func (s *Wss) HandleTCPConn(c net.Conn, remote *lb.Node) error

Jump to

Keyboard shortcuts

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