netmux

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2019 License: MIT Imports: 6 Imported by: 0

README

About

netmux provides a network connection muxer.

Documentation

Overview

Package netmux provides a simple way to multiplex (mux) network connections based on content.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error string

Error is a network connection mux error.

const (
	// ErrListenerClosed is the listener closed error.
	ErrListenerClosed Error = "listener closed"
)

Error values.

func (Error) Error

func (err Error) Error() string

Error satisfies the error interface.

type Listener

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

Listener

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

Accept satisfies the net.Listener interface.

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

Addr satisfies the net.Listener interface.

func (*Listener) Close

func (l *Listener) Close() error

Close satisfies the net.Listener interface.

type MatchFunc

type MatchFunc func(io.Writer, io.Reader) bool

MatchFunc wraps a func as a Matcher.

func Any

func Any() MatchFunc

Any matches any network connection.

func HTTP1Fast

func HTTP1Fast() MatchFunc

HTTP1Fast creates a fast matcher for HTTP1.

func TLS

func TLS() MatchFunc

TLS creates a matcher for the specified TLS versions.

func (MatchFunc) Match

func (f MatchFunc) Match(w io.Writer, r io.Reader) bool

Match applies f to w, r.

type Matcher

type Matcher interface {
	Match(io.Writer, io.Reader) bool
}

Matcher is the common connection matching interface.

type Netmux

type Netmux struct {

	// Default is the default listener.
	Default *Listener
	// contains filtered or unexported fields
}

Netmux is a network connection multiplexor.

func Listen

func Listen(network, address string, opts ...Option) (*Netmux, error)

Listen is a utility func wrapping a call to net.Listen and passing the returned net.Listener and provided options to New.

func ListenTLS

func ListenTLS(network, laddr string, config *tls.Config, opts ...Option) (*Netmux, error)

ListenTLS is a utility func wrapping a call to tls.Listen and passing the returned net.Listener and provided options to New.

func New

func New(l net.Listener, opts ...Option) (*Netmux, error)

New creates a connection multiplexor for the supplied listener.

func (*Netmux) Listen

func (nm *Netmux) Listen(matchers ...Matcher) *Listener

Listen creates a listener matching any supplied matchers.

type Option

type Option func(*Netmux) error

Option is a network connection multiplexor option.

func Proxy

func Proxy(networkAddresses ...string) Option

Proxy is a netmux option that sets the upstream networks or IP addresses allowed to send the PROXY protocol header.

The provided network addresses can be any IP or CIDR accepted by net.ParseIP or net.ParseCIDR.

When set on a Netmux, any Listener.RemoteAddr() call will return the address sent via the PROXY header.

See: http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt

Jump to

Keyboard shortcuts

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