mux

package
v0.0.0-...-607911e Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 11 Imported by: 4

Documentation

Overview

Package mux implements a qmux session and channel API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Proxy

func Proxy(dst, src Session) error

Proxy accepts channels on src then opens a channel on dst and performs an io.Copy in both directions in goroutines. Proxy returns non-EOF errors from src.Accept, nil on EOF, and any errors from dst.Open after closing the accepted channel from src.

Types

type Channel

type Channel interface {
	io.ReadWriteCloser
	ID() uint32
	CloseWrite() error
}

type Listener

type Listener interface {
	// Close closes the listener.
	// Any blocked Accept operations will be unblocked and return errors.
	Close() error

	// Accept waits for and returns the next incoming session.
	Accept() (Session, error)

	// Addr returns the listener's network address if available.
	Addr() net.Addr
}

A Listener is similar to a net.Listener but returns connections wrapped as mux sessions.

func ListenIO

func ListenIO(out io.WriteCloser, in io.ReadCloser) (Listener, error)

ListenIO returns an IOListener that gives a mux session based on seperate WriteCloser and ReadClosers.

func ListenStdio

func ListenStdio() (Listener, error)

ListenStdio is a convenience for calling ListenIO with Stdout and Stdin.

func ListenTCP

func ListenTCP(addr string) (Listener, error)

ListenTCP creates a TCP listener at the given address.

func ListenUnix

func ListenUnix(path string) (Listener, error)

ListenTCP creates a Unix domain socket listener at the given path.

func ListenWS

func ListenWS(addr string) (Listener, error)

ListenWS takes a TCP address and returns a Listener for a HTTP+WebSocket server listening on the given address.

func ListenerFrom

func ListenerFrom(l net.Listener) Listener

type Session

type Session interface {
	io.Closer
	Accept() (Channel, error)
	Open(ctx context.Context) (Channel, error)
	Wait() error
}

Session is a bi-directional channel muxing session on a given transport.

func DialIO

func DialIO(out io.WriteCloser, in io.ReadCloser) (Session, error)

DialIO establishes a mux session using a WriterCloser and ReadCloser.

func DialStdio

func DialStdio() (Session, error)

DialIO establishes a mux session using Stdout and Stdin.

func DialTCP

func DialTCP(addr string) (Session, error)

DialTCP establishes a mux session via TCP connection.

func DialUnix

func DialUnix(path string) (Session, error)

DialUnix establishes a mux session via Unix domain socket.

func DialWS

func DialWS(addr string) (Session, error)

DialWS establishes a mux session via WebSocket connection. The address must be a host and port. Opening a WebSocket connection at a particular path is not supported.

func New

func New(t io.ReadWriteCloser) Session

NewSession returns a session that runs over the given transport.

func Pair

func Pair() (a, b Session)

Directories

Path Synopsis
Package frame implements encoding and decoding of qmux message frames.
Package frame implements encoding and decoding of qmux message frames.

Jump to

Keyboard shortcuts

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