listener

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrListenerClosed = errListenerClosed("listener: 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)

type ErrProtoNotMatched

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

func (ErrProtoNotMatched) Error

func (e ErrProtoNotMatched) Error() string

func (ErrProtoNotMatched) Temporary

func (e ErrProtoNotMatched) Temporary() bool

Temporary implements the net.Error interface.

func (ErrProtoNotMatched) Timeout

func (e ErrProtoNotMatched) Timeout() bool

Timeout implements the net.Error interface.

type ErrorHandler

type ErrorHandler func(error) bool

type Listener

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

func New

func New(address string) (*Listener, error)

func (*Listener) Accept

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

func (*Listener) Addr

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

func (*Listener) Close

func (m *Listener) Close() error

Close closes the listener

func (*Listener) HandleError

func (m *Listener) HandleError(h ErrorHandler)

func (*Listener) Proto

func (m *Listener) Proto(proto ...Proto) net.Listener

func (*Listener) Serve

func (m *Listener) Serve() error

Serve start multiplexing the listener.

func (*Listener) ServeCallback

func (m *Listener) ServeCallback(proto Proto, serve func(l net.Listener) error)

func (*Listener) SetReadTimeout

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

type Proto

type Proto func(io.Reader) bool

Proto gets a connection based on content

func MatchAny

func MatchAny() Proto

MatchAny matches any connection.

func MatchCT

func MatchCT(strs string) Proto

MatchCT only matches the content-type of the request.

func MatchWS

func MatchWS(strs ...string) Proto

MatchWS only matches the HTTP GET request.

Jump to

Keyboard shortcuts

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