Documentation ¶
Overview ¶
Package netw is a wrapper around network connections that stores annotations and records metrics.
Index ¶
- func Listen(network, laddr string) (net.Listener, error)
- func SetAnnotation(conn net.Conn, key string, value any)
- type Conn
- func (c *Conn) Annotation(key string, defaultValue any) any
- func (c *Conn) ByteRateReceived() float64
- func (c *Conn) ByteRateSent() float64
- func (c *Conn) BytesReceived() int64
- func (c *Conn) BytesSent() int64
- func (c *Conn) Close() error
- func (c *Conn) OnClose(f func())
- func (c *Conn) Peek(b []byte) (int, error)
- func (c *Conn) Read(b []byte) (int, error)
- func (c *Conn) SetAnnotation(key string, value any)
- func (c *Conn) SetCounters(sent, received *counter.Counter)
- func (c *Conn) SetLimiters(ingress, egress *rate.Limiter)
- func (c *Conn) StreamID() int64
- func (c *Conn) Write(b []byte) (int, error)
- type QUICConn
- func (c *QUICConn) AcceptStream(ctx context.Context) (quic.Stream, error)
- func (c *QUICConn) AcceptUniStream(ctx context.Context) (quic.ReceiveStream, error)
- func (c *QUICConn) Annotation(key string, defaultValue any) any
- func (c *QUICConn) ByteRateReceived() float64
- func (c *QUICConn) ByteRateSent() float64
- func (c *QUICConn) BytesReceived() int64
- func (c *QUICConn) BytesSent() int64
- func (c *QUICConn) Close() error
- func (c *QUICConn) CloseWithError(code quic.ApplicationErrorCode, msg string) error
- func (c *QUICConn) ConnectionState() quic.ConnectionState
- func (c *QUICConn) Context() context.Context
- func (c *QUICConn) HandshakeComplete() <-chan struct{}
- func (c *QUICConn) LocalAddr() net.Addr
- func (c *QUICConn) NextConnection() quic.Connection
- func (c *QUICConn) OnClose(f func())
- func (c *QUICConn) OpenStream() (quic.Stream, error)
- func (c *QUICConn) OpenStreamSync(ctx context.Context) (quic.Stream, error)
- func (c *QUICConn) OpenUniStream() (quic.SendStream, error)
- func (c *QUICConn) OpenUniStreamSync(ctx context.Context) (quic.SendStream, error)
- func (c *QUICConn) Read([]byte) (int, error)
- func (c *QUICConn) ReceiveDatagram(ctx context.Context) ([]byte, error)
- func (c *QUICConn) RemoteAddr() net.Addr
- func (c *QUICConn) SendDatagram(b []byte) error
- func (c *QUICConn) SetAnnotation(key string, value any)
- func (c *QUICConn) SetCounters(sent, received *counter.Counter)
- func (c *QUICConn) SetDeadline(t time.Time) error
- func (c *QUICConn) SetLimiters(ingress, egress *rate.Limiter)
- func (c *QUICConn) SetReadDeadline(t time.Time) error
- func (c *QUICConn) SetWriteDeadline(t time.Time) error
- func (c *QUICConn) Streams() []*QUICStream
- func (c *QUICConn) TLSConnectionState() tls.ConnectionState
- func (c *QUICConn) WrapConn(s any) *Conn
- func (c *QUICConn) Write([]byte) (int, error)
- type QUICListener
- type QUICStream
- func (s *QUICStream) BridgeAddr() string
- func (s *QUICStream) CancelRead(e quic.StreamErrorCode)
- func (s *QUICStream) CancelWrite(e quic.StreamErrorCode)
- func (s *QUICStream) Close() error
- func (s *QUICStream) CloseRead() error
- func (s *QUICStream) CloseWrite() error
- func (s *QUICStream) LocalAddr() net.Addr
- func (s *QUICStream) Read(b []byte) (int, error)
- func (s *QUICStream) RemoteAddr() net.Addr
- func (s *QUICStream) SetBridgeAddr(v string)
- func (s *QUICStream) Write(b []byte) (int, error)
- type QUICTransport
- func (t *QUICTransport) Addr() net.Addr
- func (t *QUICTransport) Close() error
- func (t *QUICTransport) Dial(ctx context.Context, addr net.Addr, tc *tls.Config) (*QUICConn, error)
- func (t *QUICTransport) DialEarly(ctx context.Context, addr net.Addr, tc *tls.Config, enableDatagrams bool) (*QUICConn, error)
- func (t *QUICTransport) Listen(tc *tls.Config) (*QUICListener, error)
- type ReceiveOnlyStream
- func (s *ReceiveOnlyStream) CancelWrite(quic.StreamErrorCode)
- func (s *ReceiveOnlyStream) Close() error
- func (s *ReceiveOnlyStream) Context() context.Context
- func (s *ReceiveOnlyStream) SetDeadline(t time.Time) error
- func (s *ReceiveOnlyStream) SetWriteDeadline(time.Time) error
- func (s *ReceiveOnlyStream) Write([]byte) (int, error)
- type SendOnlyStream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Conn ¶
Conn is a wrapper around net.Conn that stores annotations and metrics.
func NewConnForTest ¶ added in v0.4.3
func (*Conn) Annotation ¶
Annotation retrieves an annotation that was previously set on the connection. The defaultValue is returned if the annotation was never set.
func (*Conn) ByteRateReceived ¶ added in v0.4.1
ByteRateReceived returns the rate of bytes received on this connection in the last minute.
func (*Conn) ByteRateSent ¶ added in v0.4.1
ByteRateSent returns the rate of bytes sent on this connection in the last minute.
func (*Conn) BytesReceived ¶
BytesReceived returns the number of bytes received on this connection so far.
func (*Conn) OnClose ¶
func (c *Conn) OnClose(f func())
OnClose sets a callback function that will be called when the connection is closed.
func (*Conn) SetAnnotation ¶
SetAnnotation sets an annotation. The value can be any go value.
func (*Conn) SetCounters ¶ added in v0.4.1
func (*Conn) SetLimiters ¶ added in v0.0.34
SetLimiter sets the rate limiters for this connection. It must be called before the first Read() or Write(). Peek() is OK.
type QUICConn ¶ added in v0.3.0
type QUICConn struct {
// contains filtered or unexported fields
}
QUICConn is a wrapper around quic.Connection.
func (*QUICConn) AcceptStream ¶ added in v0.6.0
func (*QUICConn) AcceptUniStream ¶ added in v0.6.0
func (*QUICConn) Annotation ¶ added in v0.4.3
Annotation retrieves an annotation that was previously set on the connection. The defaultValue is returned if the annotation was never set.
func (*QUICConn) ByteRateReceived ¶ added in v0.4.3
ByteRateReceived returns the rate of bytes received on this connection in the last minute.
func (*QUICConn) ByteRateSent ¶ added in v0.4.3
ByteRateSent returns the rate of bytes sent on this connection in the last minute.
func (*QUICConn) BytesReceived ¶ added in v0.4.3
BytesReceived returns the number of bytes received on this connection so far.
func (*QUICConn) BytesSent ¶ added in v0.4.3
BytesSent returns the number of bytes sent on this connection so far.
func (*QUICConn) CloseWithError ¶ added in v0.6.0
func (*QUICConn) ConnectionState ¶ added in v0.6.0
func (c *QUICConn) ConnectionState() quic.ConnectionState
func (*QUICConn) HandshakeComplete ¶ added in v0.6.0
func (c *QUICConn) HandshakeComplete() <-chan struct{}
func (*QUICConn) NextConnection ¶ added in v0.6.0
func (c *QUICConn) NextConnection() quic.Connection
func (*QUICConn) OnClose ¶ added in v0.6.0
func (c *QUICConn) OnClose(f func())
OnClose sets a callback function that will be called when the connection is closed.
func (*QUICConn) OpenStream ¶ added in v0.6.0
func (*QUICConn) OpenStreamSync ¶ added in v0.6.0
func (*QUICConn) OpenUniStream ¶ added in v0.6.0
func (*QUICConn) OpenUniStreamSync ¶ added in v0.6.0
func (*QUICConn) ReceiveDatagram ¶ added in v0.6.0
func (*QUICConn) RemoteAddr ¶ added in v0.6.0
func (*QUICConn) SendDatagram ¶ added in v0.6.0
func (*QUICConn) SetAnnotation ¶ added in v0.4.3
SetAnnotation sets an annotation. The value can be any go value.
func (*QUICConn) SetCounters ¶ added in v0.6.0
SetCounters sets the byte counters to use for this connection.
func (*QUICConn) SetLimiters ¶ added in v0.6.0
SetLimiter sets the rate limiters for this connection. It must be called before the first Read() or Write(). Peek() is OK.
func (*QUICConn) SetReadDeadline ¶ added in v0.6.0
func (*QUICConn) SetWriteDeadline ¶ added in v0.6.0
func (*QUICConn) Streams ¶ added in v0.3.0
func (c *QUICConn) Streams() []*QUICStream
func (*QUICConn) TLSConnectionState ¶ added in v0.6.0
func (c *QUICConn) TLSConnectionState() tls.ConnectionState
type QUICListener ¶ added in v0.6.0
type QUICListener struct {
// contains filtered or unexported fields
}
QUICListener is a wrapper around quic.Listener.
func (*QUICListener) Accept ¶ added in v0.6.0
func (l *QUICListener) Accept(ctx context.Context) (*QUICConn, error)
func (*QUICListener) Addr ¶ added in v0.6.0
func (l *QUICListener) Addr() net.Addr
func (*QUICListener) Close ¶ added in v0.6.0
func (l *QUICListener) Close() error
type QUICStream ¶ added in v0.3.0
type QUICStream struct { quic.Stream // contains filtered or unexported fields }
QUICStream is a wrapper around quic.Stream that implements the net.Conn interface.
func (*QUICStream) BridgeAddr ¶ added in v0.3.0
func (s *QUICStream) BridgeAddr() string
func (*QUICStream) CancelRead ¶ added in v0.6.0
func (s *QUICStream) CancelRead(e quic.StreamErrorCode)
func (*QUICStream) CancelWrite ¶ added in v0.6.0
func (s *QUICStream) CancelWrite(e quic.StreamErrorCode)
func (*QUICStream) Close ¶ added in v0.6.0
func (s *QUICStream) Close() error
func (*QUICStream) CloseRead ¶ added in v0.6.0
func (s *QUICStream) CloseRead() error
func (*QUICStream) CloseWrite ¶ added in v0.6.0
func (s *QUICStream) CloseWrite() error
func (*QUICStream) LocalAddr ¶ added in v0.6.0
func (s *QUICStream) LocalAddr() net.Addr
func (*QUICStream) RemoteAddr ¶ added in v0.6.0
func (s *QUICStream) RemoteAddr() net.Addr
func (*QUICStream) SetBridgeAddr ¶ added in v0.6.0
func (s *QUICStream) SetBridgeAddr(v string)
type QUICTransport ¶ added in v0.6.0
type QUICTransport struct {
// contains filtered or unexported fields
}
QUICTransport is a wrapper around quic.Transport.
func NewQUIC ¶ added in v0.6.0
func NewQUIC(addr string, statelessResetKey quic.StatelessResetKey) (*QUICTransport, error)
NewQUIC returns a wrapper around a quic.Transport to keep track of metrics and annotations.
func (*QUICTransport) Addr ¶ added in v0.6.0
func (t *QUICTransport) Addr() net.Addr
func (*QUICTransport) Close ¶ added in v0.6.0
func (t *QUICTransport) Close() error
func (*QUICTransport) Listen ¶ added in v0.6.0
func (t *QUICTransport) Listen(tc *tls.Config) (*QUICListener, error)
type ReceiveOnlyStream ¶ added in v0.6.0
type ReceiveOnlyStream struct { quic.ReceiveStream // contains filtered or unexported fields }
func (*ReceiveOnlyStream) CancelWrite ¶ added in v0.6.0
func (s *ReceiveOnlyStream) CancelWrite(quic.StreamErrorCode)
func (*ReceiveOnlyStream) Close ¶ added in v0.6.0
func (s *ReceiveOnlyStream) Close() error
func (*ReceiveOnlyStream) Context ¶ added in v0.6.0
func (s *ReceiveOnlyStream) Context() context.Context
func (*ReceiveOnlyStream) SetDeadline ¶ added in v0.6.0
func (s *ReceiveOnlyStream) SetDeadline(t time.Time) error
func (*ReceiveOnlyStream) SetWriteDeadline ¶ added in v0.6.0
func (s *ReceiveOnlyStream) SetWriteDeadline(time.Time) error
type SendOnlyStream ¶ added in v0.6.0
type SendOnlyStream struct { quic.SendStream // contains filtered or unexported fields }
func (*SendOnlyStream) CancelRead ¶ added in v0.6.0
func (s *SendOnlyStream) CancelRead(quic.StreamErrorCode)
func (*SendOnlyStream) SetDeadline ¶ added in v0.6.0
func (s *SendOnlyStream) SetDeadline(t time.Time) error
func (*SendOnlyStream) SetReadDeadline ¶ added in v0.6.0
func (s *SendOnlyStream) SetReadDeadline(time.Time) error