mux

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2017 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 MuxStream, 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
}

func ReadAuthRequest

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

type AuthResponse

type AuthResponse struct {
	Code int
}

type ConnectRequest

type ConnectRequest struct {
	//ProxySID uint32
	Network string
	Addr    string
}

func ReadConnectRequest

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

type HTTP2MuxSession added in v0.27.2

type HTTP2MuxSession struct {
	net.Conn

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

func NewHTTP2ServerMuxSession added in v0.27.2

func NewHTTP2ServerMuxSession(conn net.Conn) *HTTP2MuxSession

func (*HTTP2MuxSession) AcceptStream added in v0.27.2

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

func (*HTTP2MuxSession) Close added in v0.27.2

func (q *HTTP2MuxSession) Close() error

func (*HTTP2MuxSession) CloseStream added in v0.27.2

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

func (*HTTP2MuxSession) NumStreams added in v0.27.2

func (q *HTTP2MuxSession) NumStreams() int

func (*HTTP2MuxSession) OfferStream added in v0.27.2

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

func (*HTTP2MuxSession) OpenStream added in v0.27.2

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

func (*HTTP2MuxSession) Ping added in v0.27.2

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

type MuxSession

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

func NewHTTP2ClientMuxSession added in v0.27.2

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

type MuxStream

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

type ProxyMuxSession

type ProxyMuxSession struct {
	*pmux.Session
}

func (*ProxyMuxSession) AcceptStream

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

func (*ProxyMuxSession) CloseStream

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

func (*ProxyMuxSession) OpenStream

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

type ProxyMuxStream

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

func (*ProxyMuxStream) Auth

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

func (*ProxyMuxStream) Close

func (s *ProxyMuxStream) Close() error

func (*ProxyMuxStream) Connect

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

func (*ProxyMuxStream) StreamID

func (s *ProxyMuxStream) StreamID() uint32

type QUICMuxSession

type QUICMuxSession struct {
	quic.Session
	// 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) NumStreams

func (q *QUICMuxSession) NumStreams() int

func (*QUICMuxSession) OpenStream

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

func (*QUICMuxSession) Ping added in v0.27.2

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

type TimeoutReadWriteCloser added in v0.29.0

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