mux

package
v0.0.0-...-3fdcba8 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMuxCipherMethod         = "chacha20poly1305"
	DefaultMuxInitialCipherCounter = uint64(47816489)
	AuthOK                         = 1

	HTTPMuxSessionIDHeader    = "X-Session-ID"
	HTTPMuxSessionACKIDHeader = "X-Session-ACK-ID"
	HTTPMuxPullPeriodHeader   = "X-PullPeriod"
)
View Source
const (
	SnappyCompressor = "snappy"
	NoneCompressor   = "none"
)

Variables

View Source
var (
	ErrToolargeMessage = errors.New("too large message length")
	ErrAuthFailed      = errors.New("auth failed")
	ErrDataReadMissing = errors.New("auth failed")
)

Functions

func GetCompressStreamReaderWriter

func GetCompressStreamReaderWriter(stream io.ReadWriteCloser, method string) (io.Reader, io.Writer)

func IsValidCompressor

func IsValidCompressor(method string) bool

func ReadMessage

func ReadMessage(stream io.Reader, res interface{}) error

func WriteMessage

func WriteMessage(stream io.Writer, req interface{}) error

Types

type AuthRequest

type AuthRequest struct {
	Rand           string
	User           string
	CipherCounter  uint64
	CipherMethod   string
	CompressMethod string

	P2PToken   string
	P2PConnID  string
	P2PPriAddr string
	P2PPubAddr string
}

func ReadAuthRequest

func ReadAuthRequest(stream io.Reader) (*AuthRequest, error)

type AuthResponse

type AuthResponse struct {
	Code        int
	PeerPriAddr string
	PeerPubAddr string
	PubAddr     string
}

func (*AuthResponse) Error

func (res *AuthResponse) Error() error

type ConnAddr

type ConnAddr interface {
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
}

type ConnectRequest

type ConnectRequest struct {
	//ProxySID uint32
	Network     string
	Addr        string
	DialTimeout int
	ReadTimeout int
	Hops        []string
}

func ReadConnectRequest

func ReadConnectRequest(stream io.Reader) (*ConnectRequest, error)

type HTTP2MuxSession

type HTTP2MuxSession struct {
	net.Conn

	ServerHost string
	//Client     *http.Client
	//Client        *http2.Transport
	AcceptCh chan MuxStream
	// contains filtered or unexported fields
}

func NewHTTP2ServerMuxSession

func NewHTTP2ServerMuxSession(conn net.Conn) *HTTP2MuxSession

func (*HTTP2MuxSession) AcceptStream

func (q *HTTP2MuxSession) AcceptStream() (MuxStream, error)

func (*HTTP2MuxSession) Close

func (q *HTTP2MuxSession) Close() error

func (*HTTP2MuxSession) CloseStream

func (q *HTTP2MuxSession) CloseStream(stream MuxStream) error

func (*HTTP2MuxSession) LocalAddr

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

func (*HTTP2MuxSession) NumStreams

func (q *HTTP2MuxSession) NumStreams() int

func (*HTTP2MuxSession) OfferStream

func (q *HTTP2MuxSession) OfferStream(stream TimeoutReadWriteCloser) error

func (*HTTP2MuxSession) OpenStream

func (q *HTTP2MuxSession) OpenStream() (MuxStream, error)

func (*HTTP2MuxSession) Ping

func (q *HTTP2MuxSession) Ping() (time.Duration, error)

func (*HTTP2MuxSession) RemoteAddr

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

type MuxSession

type MuxSession interface {
	OpenStream() (MuxStream, error)
	CloseStream(stream MuxStream) error
	AcceptStream() (MuxStream, error)
	Ping() (time.Duration, error)
	NumStreams() int
	Close() error
	RemoteAddr() net.Addr
	LocalAddr() net.Addr
}

func NewHTTP2ClientMuxSession

func NewHTTP2ClientMuxSession(conn net.Conn, host string) (MuxSession, error)

type MuxStream

type MuxStream interface {
	io.ReadWriteCloser
	Connect(network string, addr string, opt StreamOptions) error
	Auth(req *AuthRequest) *AuthResponse
	StreamID() uint32
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
	LatestIOTime() time.Time
}

type MuxStreamConn

type MuxStreamConn struct {
	MuxStream
}

func (*MuxStreamConn) LocalAddr

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

func (*MuxStreamConn) RemoteAddr

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

func (*MuxStreamConn) SetDeadline

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

type ProxyMuxSession

type ProxyMuxSession struct {
	*pmux.Session
	NetConn ConnAddr
}

func (*ProxyMuxSession) AcceptStream

func (s *ProxyMuxSession) AcceptStream() (MuxStream, error)

func (*ProxyMuxSession) CloseStream

func (s *ProxyMuxSession) CloseStream(stream MuxStream) error

func (*ProxyMuxSession) LocalAddr

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

func (*ProxyMuxSession) OpenStream

func (s *ProxyMuxSession) OpenStream() (MuxStream, error)

func (*ProxyMuxSession) RemoteAddr

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

type ProxyMuxStream

type ProxyMuxStream struct {
	TimeoutReadWriteCloser
	// contains filtered or unexported fields
}

func (*ProxyMuxStream) Auth

func (s *ProxyMuxStream) Auth(req *AuthRequest) *AuthResponse

func (*ProxyMuxStream) Close

func (s *ProxyMuxStream) Close() error

func (*ProxyMuxStream) Connect

func (s *ProxyMuxStream) Connect(network string, addr string, opt StreamOptions) error

func (*ProxyMuxStream) LatestIOTime

func (s *ProxyMuxStream) LatestIOTime() time.Time

func (*ProxyMuxStream) OnIO

func (s *ProxyMuxStream) OnIO(read bool)

func (*ProxyMuxStream) Read

func (s *ProxyMuxStream) Read(p []byte) (int, error)

func (*ProxyMuxStream) ReadFrom

func (s *ProxyMuxStream) ReadFrom(r io.Reader) (n int64, err error)

func (*ProxyMuxStream) StreamID

func (s *ProxyMuxStream) StreamID() uint32

func (*ProxyMuxStream) Write

func (s *ProxyMuxStream) Write(p []byte) (int, error)

func (*ProxyMuxStream) WriteTo

func (s *ProxyMuxStream) WriteTo(w io.Writer) (n int64, err error)

type QUICMuxSession

type QUICMuxSession struct {
	quic.Connection
	// contains filtered or unexported fields
}

func (*QUICMuxSession) AcceptStream

func (q *QUICMuxSession) AcceptStream() (MuxStream, error)

func (*QUICMuxSession) Close

func (q *QUICMuxSession) Close() error

func (*QUICMuxSession) CloseStream

func (q *QUICMuxSession) CloseStream(stream MuxStream) error

func (*QUICMuxSession) LocalAddr

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

func (*QUICMuxSession) NumStreams

func (q *QUICMuxSession) NumStreams() int

func (*QUICMuxSession) OpenStream

func (q *QUICMuxSession) OpenStream() (MuxStream, error)

func (*QUICMuxSession) Ping

func (q *QUICMuxSession) Ping() (time.Duration, error)

func (*QUICMuxSession) RemoteAddr

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

type StreamOptions

type StreamOptions struct {
	DialTimeout int
	ReadTimeout int
	Hops        []string
}

type SyncCloser

type SyncCloser interface {
	SyncClose() error
}

type TimeoutReadWriteCloser

type TimeoutReadWriteCloser interface {
	io.ReadWriteCloser
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
}

type WsConn

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

func (*WsConn) Read

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

func (*WsConn) Write

func (ws *WsConn) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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