Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 CMux ¶
type CMux interface { // Match returns a net.Listener that sees (i.e., accepts) only // the connections matched by at least one of the matcher. // // The order used to call Match determines the priority of matchers. Match(...Matcher) net.Listener // Serve starts multiplexing the listener. Serve blocks and perhaps // should be invoked concurrently within a go routine. Serve() error // HandleError registers an error handler that handles listener errors. HandleError(ErrorHandler) }
CMux is a multiplexer for network connections.
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 ¶
ErrorHandler handles an error and returns whether the mux should continue serving the listener.
type Matcher ¶
Matcher matches a connection based on its content.
func HTTP1 ¶
func HTTP1() Matcher
HTTP1 parses the first line or upto 4096 bytes of the request to see if the conection contains an HTTP request.
func HTTP1Fast ¶
HTTP1Fast only matches the methods in the HTTP request.
This matcher is very optimistic: if it returns true, it does not mean that the request is a valid HTTP response. If you want a correct but slower HTTP1 matcher, use HTTP1 instead.
func HTTP1HeaderField ¶
HTTP1HeaderField returns a matcher matching the header fields of the first request of an HTTP 1 connection.
func HTTP2 ¶
func HTTP2() Matcher
HTTP2 parses the frame header of the first frame to detect whether the connection is an HTTP2 connection.
func HTTP2HeaderField ¶
HTTP2HeaderField resturns a matcher matching the header fields of the first headers frame.
func PrefixMatcher ¶
PrefixMatcher returns a matcher that matches a connection if it starts with any of the strings in strs.
type MuxConn ¶
MuxConn wraps a net.Conn and provides transparent sniffing of connection data.
func (*MuxConn) Read ¶
From the io.Reader documentation:
When Read encounters an error or end-of-file condition after successfully reading n > 0 bytes, it returns the number of bytes read. It may return the (non-nil) error from the same call or return the error (and n == 0) from a subsequent call. An instance of this general case is that a Reader returning a non-zero number of bytes at the end of the input stream may return either err == EOF or err == nil. The next Read should return 0, EOF.