Documentation ¶
Index ¶
- type BadRequest
- type ClientHelloMsg
- type Closed
- type Config
- type Conn
- type ErrorCode
- type HTTPConn
- type HTTPMuxer
- type Heartbeat
- type HeartbeatConfig
- type Listener
- type NotFound
- type Session
- type Stream
- type StreamType
- type TLSConn
- type TLSMuxer
- type TypedStream
- type TypedStreamSession
- type VirtualHostMuxer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BadRequest ¶
type BadRequest struct {
// contains filtered or unexported fields
}
BadRequest is returned when extraction of the virtual host name fails
type ClientHelloMsg ¶
type Closed ¶
type Closed struct {
// contains filtered or unexported fields
}
Closed is returned when the underlying connection is closed
type Config ¶
type Config struct { // Maximum size of unread data to receive and buffer (per-stream). Default 256KB. MaxWindowSize uint32 // Maximum number of inbound streams to queue for Accept(). Default 128. AcceptBacklog uint32 // Function creating the Session's framer. Deafult frame.NewFramer() NewFramer func(io.Reader, io.Writer) frame.Framer // contains filtered or unexported fields }
type ErrorCode ¶
type ErrorCode uint32
ErrorCode is a 32-bit integer indicating the type of an error condition
type HTTPConn ¶
func HTTP ¶
HTTP parses the header of the first HTTP request on conn and returns a new, unread connection with metadata for virtual host multiplexing
type HTTPMuxer ¶
type HTTPMuxer struct {
*VirtualHostMuxer
}
func NewHTTPMuxer ¶
NewHTTPMuxer begins multiplexing HTTP connections on the given listener by inspecting the HTTP Host header in new connections.
func (*HTTPMuxer) HandleErrors ¶
func (m *HTTPMuxer) HandleErrors()
HandleErrors handles muxing errors by calling .NextError(). You must invoke this function, if you do not want to handle the errors yourself.
type Heartbeat ¶
type Heartbeat struct { TypedStreamSession // contains filtered or unexported fields }
func NewHeartbeat ¶
func NewHeartbeat(sess TypedStreamSession, cb func(time.Duration), config *HeartbeatConfig) *Heartbeat
func (*Heartbeat) AcceptStream ¶
func (*Heartbeat) AcceptTypedStream ¶
func (h *Heartbeat) AcceptTypedStream() (TypedStream, error)
type HeartbeatConfig ¶
type HeartbeatConfig struct { Interval time.Duration Tolerance time.Duration Type StreamType }
func NewHeartbeatConfig ¶
func NewHeartbeatConfig() *HeartbeatConfig
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener is returned by a call to Listen() on a multiplexer. A Listener only receives connections that were made to the name passed into the muxer's Listen call.
Listener implements the net.Listener interface, so you can Accept() new connections and Close() it when finished. When you Close() a Listener, the parent muxer will stop listening for connections to the Listener's name.
func (*Listener) Accept ¶
Accept returns the next multiplexed connection for this listener and blocks until one is available.
type NotFound ¶
type NotFound struct {
// contains filtered or unexported fields
}
NotFound is returned when a virtual host is not found
type Session ¶
type Session interface { // Open initiates a new stream on the session. It is equivalent to // OpenStream(0, false) Open() (net.Conn, error) // OpenStream initiates a new stream on the session. A caller can specify an // opaque stream type. Setting fin to true will cause the stream to be // half-closed from the local side immediately upon creation. OpenStream() (Stream, error) // Accept returns the next stream initiated by the remote side Accept() (net.Conn, error) // Accept returns the next stream initiated by the remote side AcceptStream() (Stream, error) // Attempts to close the Session cleanly. Closes the underlying stream transport. Close() error // LocalAddr returns the local address of the transport stream over which the session is running. LocalAddr() net.Addr // RemoteAddr returns the address of the remote side of the transport stream over which the session is running. RemoteAddr() net.Addr // Addr returns the session transport's local address Addr() net.Addr // Wait blocks until the session has shutdown and returns an error // explaining the session termination. Wait() (error, error, []byte) }
Session multiplexes many Streams over a single underlying stream transport. Both sides of the Bhojpur Web multiplexer session can open new Streams. The Sessions can also accept new streams from the remote side.
A Session implements the net.Listener interface, returning new Streams from the remote side.
func StreamClient ¶
func StreamClient(trans io.ReadWriteCloser, config *Config) Session
StreamClient returns a new client-side connection using trans as the transport.
func StreamServer ¶
func StreamServer(trans io.ReadWriteCloser, config *Config) Session
StreamServer returns a server session using trans as the transport.
type Stream ¶
type Stream interface { // Write writes the bytes in the given buffer to the stream Write([]byte) (int, error) // Read reads the next bytes on the stream into the given buffer Read([]byte) (int, error) // Closes the stream. Close() error // Half-closes the stream. Calls to Write will fail after this is invoked. CloseWrite() error // SetDeadline sets a time after which future Read and Write operations will // fail. // // Some implementation may not support this. SetDeadline(time.Time) error // SetReadDeadline sets a time after which future Read operations will fail. // // Some implementation may not support this. SetReadDeadline(time.Time) error // SetWriteDeadline sets a time after which future Write operations will // fail. // // Some implementation may not support this. SetWriteDeadline(time.Time) error // Id returns the stream's unique identifier. Id() uint32 // Session returns the session object this stream is running on. Session() Session // RemoteAddr returns the session transport's remote address. RemoteAddr() net.Addr // LocalAddr returns the session transport's local address. LocalAddr() net.Addr }
Stream is a full duplex stream-oriented connection that is multiplexed over a Session. Stream implements the net.Conn inteface.
type StreamType ¶
type StreamType uint32
type TLSConn ¶
type TLSConn struct { ClientHelloMsg *ClientHelloMsg // contains filtered or unexported fields }
A Conn represents a secured connection. It implements the net.Conn interface.
type TLSMuxer ¶
type TLSMuxer struct {
*VirtualHostMuxer
}
func NewTLSMuxer ¶
NewTLSMuxer begins muxing TLS connections by inspecting the SNI extension.
func (*TLSMuxer) HandleErrors ¶
func (m *TLSMuxer) HandleErrors()
HandleErrors is the default error handler for TLS muxers. At the moment, it simply closes connections which are invalid or destined for virtual host names that it is not listening for. You must invoke this function, if you do not want to handle the errors yourself.
type TypedStream ¶
type TypedStream interface { Stream StreamType() StreamType }
type TypedStreamSession ¶
type TypedStreamSession interface { Session OpenTypedStream(stype StreamType) (Stream, error) AcceptTypedStream() (TypedStream, error) }
func NewTypedStreamSession ¶
func NewTypedStreamSession(s Session) TypedStreamSession
type VirtualHostMuxer ¶
type VirtualHostMuxer struct { sync.RWMutex // protects the registry // contains filtered or unexported fields }
func NewVirtualHostMuxer ¶
func (*VirtualHostMuxer) Close ¶
func (m *VirtualHostMuxer) Close()
Close closes the underlying listener