listener

package
Version: v2.0.437+incompatible Latest Latest
Warning

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

Go to latest
Published: May 5, 2018 License: AGPL-3.0 Imports: 7 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrListenerClosed = errListenerClosed("mux: listener closed")

ErrListenerClosed is returned from muxListener.Accept when the underlying listener is closed.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

Conn wraps a net.Conn and provides transparent sniffing of connection data.

func (*Conn) Read

func (m *Conn) Read(p []byte) (int, error)

Read reads the block of data from the underlying buffer.

type ErrNotMatched

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

ErrNotMatched is returned whenever a connection is not matched by any of the matchers registered in the multiplexer.

func (ErrNotMatched) Error

func (e ErrNotMatched) Error() string

func (ErrNotMatched) Temporary

func (e ErrNotMatched) Temporary() bool

Temporary implements the net.Error interface.

func (ErrNotMatched) Timeout

func (e ErrNotMatched) Timeout() bool

Timeout implements the net.Error interface.

type ErrorHandler

type ErrorHandler func(error) bool

ErrorHandler handles an error and notifies the listener on whether it should continue serving.

type Listener

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

Listener represents a listener used for multiplexing protocols.

func New

func New(address string, config *tls.Config) (*Listener, error)

New announces on the local network address laddr. The syntax of laddr is "host:port", like "127.0.0.1:8080". If host is omitted, as in ":8080", New listens on all available interfaces instead of just the interface with the given host address. Listening on a hostname is not recommended because this creates a socket for at most one of its IP addresses.

func (*Listener) Accept

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

Accept waits for and returns the next connection to the listener.

func (*Listener) Addr

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

Addr returns the listener's network address.

func (*Listener) Close

func (m *Listener) Close() error

Close closes the listener

func (*Listener) HandleError

func (m *Listener) HandleError(h ErrorHandler)

HandleError registers an error handler that handles listener errors.

func (*Listener) Match

func (m *Listener) Match(matchers ...Matcher) net.Listener

Match returns a net.Listener that sees (i.e., accepts) only the connections matched by at least one of the matcher.

func (*Listener) Serve

func (m *Listener) Serve() error

Serve starts multiplexing the listener.

func (*Listener) ServeAsync

func (m *Listener) ServeAsync(matcher Matcher, serve func(l net.Listener) error)

ServeAsync adds a protocol based on the matcher and serves it.

func (*Listener) SetReadTimeout

func (m *Listener) SetReadTimeout(t time.Duration)

SetReadTimeout sets a timeout for the read of matchers.

type Matcher

type Matcher func(io.Reader) bool

Matcher matches a connection based on its content.

func MatchAny

func MatchAny() Matcher

MatchAny matches any connection.

func MatchHTTP

func MatchHTTP(extMethods ...string) Matcher

MatchHTTP only matches the methods in the HTTP request.

func MatchPrefix

func MatchPrefix(strs ...string) Matcher

MatchPrefix returns a matcher that matches a connection if it starts with any of the strings in strs.

type Server

type Server interface {
	Serve(listener net.Listener)
}

Server represents a server which can serve requests.

Jump to

Keyboard shortcuts

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