mux

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClosedConn       = errors.New("underlying connection was closed")
	ErrClosedStream     = errors.New("stream was gracefully closed")
	ErrPeerClosedStream = errors.New("peer closed stream gracefully")
	ErrPeerClosedConn   = errors.New("peer closed underlying connection")
)

Errors relating to stream or mux shutdown.

Functions

This section is empty.

Types

type Mux

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

A Mux multiplexes multiple duplex Streams onto a single net.Conn.

func Accept

func Accept(conn net.Conn, ourKey ed25519.PrivateKey) (*Mux, error)

Accept reciprocates a mux protocol handshake on the provided conn.

func AcceptAnonymous

func AcceptAnonymous(conn net.Conn) (*Mux, error)

AcceptAnonymous reciprocates a mux protocol handshake without a pre-established identity. The counterparty must initiate the handshake with DialAnonymous.

func Dial

func Dial(conn net.Conn, theirKey ed25519.PublicKey) (*Mux, error)

Dial initiates a mux protocol handshake on the provided conn.

func DialAnonymous

func DialAnonymous(conn net.Conn) (*Mux, error)

DialAnonymous initiates a mux protocol handshake to a party without a pre-established identity. The counterparty must reciprocate the handshake with AcceptAnonymous.

func (*Mux) AcceptStream

func (m *Mux) AcceptStream() (*Stream, error)

AcceptStream waits for and returns the next peer-initiated Stream.

func (*Mux) Close

func (m *Mux) Close() error

Close closes the underlying net.Conn.

func (*Mux) DialCovertStream

func (m *Mux) DialCovertStream() *Stream

DialCovertStream creates a new covert Stream. Covert Streams hide their payloads within the padding of other Streams, making them effectively invisible to traffic analysis.

Unlike e.g. net.Dial, this does not perform any I/O; the peer will not be aware of the new Stream until Write is called.

func (*Mux) DialStream

func (m *Mux) DialStream() *Stream

DialStream creates a new Stream.

Unlike e.g. net.Dial, this does not perform any I/O; the peer will not be aware of the new Stream until Write is called.

func (*Mux) DialStreamContext

func (m *Mux) DialStreamContext(ctx context.Context) *Stream

DialStreamContext creates a new Stream with the provided context. When the context expires, the Stream will be closed and any pending calls will return ctx.Err(). DialStreamContext spawns a goroutine whose lifetime matches that of the context.

Unlike e.g. net.Dial, this does not perform any I/O; the peer will not be aware of the new Stream until Write is called.

type Stream

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

A Stream is a duplex connection multiplexed over a net.Conn. It implements the net.Conn interface.

func (*Stream) Close

func (s *Stream) Close() error

Close closes the Stream. The underlying connection is not closed.

func (*Stream) LocalAddr

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

LocalAddr returns the underlying connection's LocalAddr.

func (*Stream) Read

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

Read reads data from the Stream.

func (*Stream) RemoteAddr

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

RemoteAddr returns the underlying connection's RemoteAddr.

func (*Stream) SetDeadline

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

SetDeadline sets the read and write deadlines associated with the Stream. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.

This implementation does not entirely conform to the net.Conn interface: setting a new deadline does not affect pending Read or Write calls, only future calls.

func (*Stream) SetReadDeadline

func (s *Stream) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline associated with the Stream.

This implementation does not entirely conform to the net.Conn interface: setting a new deadline does not affect pending Read calls, only future calls.

func (*Stream) SetWriteDeadline

func (s *Stream) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the write deadline associated with the Stream.

This implementation does not entirely conform to the net.Conn interface: setting a new deadline does not affect pending Write calls, only future calls.

func (*Stream) Write

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

Write writes data to the Stream.

Jump to

Keyboard shortcuts

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