mux

package
v3.0.0-noreneg2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package mux multiplexes packets on a single socket (RFC7983)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchAll

func MatchAll(b []byte) bool

MatchAll always returns true

func MatchDTLS

func MatchDTLS(b []byte) bool

MatchDTLS is a MatchFunc that accepts packets with the first byte in [20..63] as defied in RFC7983

func MatchNone

func MatchNone(b []byte) bool

MatchNone always returns false

func MatchSRTCP

func MatchSRTCP(buf []byte) bool

MatchSRTCP is a MatchFunc that only matches SRTCP and not SRTP

func MatchSRTP

func MatchSRTP(buf []byte) bool

MatchSRTP is a MatchFunc that only matches SRTP and not SRTCP

func MatchSRTPOrSRTCP

func MatchSRTPOrSRTCP(b []byte) bool

MatchSRTPOrSRTCP is a MatchFunc that accepts packets with the first byte in [128..191] as defied in RFC7983

func MatchSTUN

func MatchSTUN(b []byte) bool

MatchSTUN is a MatchFunc that accepts packets with the first byte in [0..3] as defied in RFC7983

func MatchTURN

func MatchTURN(b []byte) bool

MatchTURN is a MatchFunc that accepts packets with the first byte in [64..79] as defied in RFC7983

func MatchZRTP

func MatchZRTP(b []byte) bool

MatchZRTP is a MatchFunc that accepts packets with the first byte in [16..19] as defied in RFC7983

Types

type Config

type Config struct {
	Conn          net.Conn
	BufferSize    int
	LoggerFactory logging.LoggerFactory
}

Config collects the arguments to mux.Mux construction into a single structure

type Endpoint

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

Endpoint implements net.Conn. It is used to read muxed packets.

func (*Endpoint) Close

func (e *Endpoint) Close() (err error)

Close unregisters the endpoint from the Mux

func (*Endpoint) LocalAddr

func (e *Endpoint) LocalAddr() net.Addr

LocalAddr is a stub

func (*Endpoint) Read

func (e *Endpoint) Read(p []byte) (int, error)

Read reads a packet of len(p) bytes from the underlying conn that are matched by the associated MuxFunc

func (*Endpoint) RemoteAddr

func (e *Endpoint) RemoteAddr() net.Addr

RemoteAddr is a stub

func (*Endpoint) SetDeadline

func (e *Endpoint) SetDeadline(t time.Time) error

SetDeadline is a stub

func (*Endpoint) SetReadDeadline

func (e *Endpoint) SetReadDeadline(t time.Time) error

SetReadDeadline is a stub

func (*Endpoint) SetWriteDeadline

func (e *Endpoint) SetWriteDeadline(t time.Time) error

SetWriteDeadline is a stub

func (*Endpoint) Write

func (e *Endpoint) Write(p []byte) (int, error)

Write writes len(p) bytes to the underlying conn

type MatchFunc

type MatchFunc func([]byte) bool

MatchFunc allows custom logic for mapping packets to an Endpoint

func MatchRange

func MatchRange(lower, upper byte) MatchFunc

MatchRange is a MatchFunc that accepts packets with the first byte in [lower..upper]

type Mux

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

Mux allows multiplexing

func NewMux

func NewMux(config Config) *Mux

NewMux creates a new Mux

func (*Mux) Close

func (m *Mux) Close() error

Close closes the Mux and all associated Endpoints.

func (*Mux) NewEndpoint

func (m *Mux) NewEndpoint(f MatchFunc) *Endpoint

NewEndpoint creates a new Endpoint

func (*Mux) RemoveEndpoint

func (m *Mux) RemoveEndpoint(e *Endpoint)

RemoveEndpoint removes an endpoint from the Mux

Jump to

Keyboard shortcuts

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