Documentation ¶
Overview ¶
Package queuepacketconn is facilities for embedding packet-based reliability protocols inside other protocols.
Index ¶
- Constants
- type ClientID
- type DummyAddr
- type QueuePacketConn
- func (c *QueuePacketConn) Close() error
- func (c *QueuePacketConn) LocalAddr() net.Addr
- func (c *QueuePacketConn) OutgoingQueue(addr net.Addr) <-chan []byte
- func (c *QueuePacketConn) QueueIncoming(p []byte, addr net.Addr)
- func (c *QueuePacketConn) Read(b []byte) (int, error)
- func (c *QueuePacketConn) ReadFrom(p []byte) (int, net.Addr, error)
- func (c *QueuePacketConn) RemoteAddr() net.Addr
- func (c *QueuePacketConn) SetDeadline(t time.Time) error
- func (c *QueuePacketConn) SetReadDeadline(t time.Time) error
- func (c *QueuePacketConn) SetWriteDeadline(t time.Time) error
- func (c *QueuePacketConn) Write(b []byte) (int, error)
- func (c *QueuePacketConn) WriteTo(p []byte, addr net.Addr) (int, error)
Constants ¶
const QueueSize = 128
QueueSize is the size of send and receive queues in QueuePacketConn and RemoteMap.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientID ¶
type ClientID [8]byte
ClientID is an abstract identifier that binds together all the communications belonging to a single client session, even though those communications may arrive from multiple IP addresses or over multiple lower-level connections. It plays the same role that an (IP address, port number) tuple plays in a net.UDPConn: it's the return address pertaining to a long-lived abstract client session. The client attaches its ClientID to each of its communications, enabling the server to disambiguate requests among its many clients. ClientID implements the net.Addr interface.
func NewClientID ¶
func NewClientID() ClientID
type DummyAddr ¶
type DummyAddr struct{}
DummyAddr is a placeholder net.Addr, for when a programming interface requires a net.Addr but there is none relevant. All DummyAddrs compare equal to each other.
type QueuePacketConn ¶
type QueuePacketConn struct {
// contains filtered or unexported fields
}
QueuePacketConn implements net.PacketConn by storing queues of packets. There is one incoming queue (where packets are additionally tagged by the source address of the peer that sent them). There are many outgoing queues, one for each remote peer address that has been recently seen. The QueueIncoming method inserts a packet into the incoming queue, to eventually be returned by ReadFrom. WriteTo inserts a packet into an address-specific outgoing queue, which can later by accessed through the OutgoingQueue method.
func NewQueuePacketConn ¶
func NewQueuePacketConn(localAddr net.Addr, timeout time.Duration) *QueuePacketConn
NewQueuePacketConn makes a new QueuePacketConn, set to track recent peers for at least a duration of timeout.
func (*QueuePacketConn) Close ¶
func (c *QueuePacketConn) Close() error
Close unblocks pending operations and makes future operations fail with a "closed connection" error.
func (*QueuePacketConn) LocalAddr ¶
func (c *QueuePacketConn) LocalAddr() net.Addr
LocalAddr returns the localAddr value that was passed to NewQueuePacketConn.
func (*QueuePacketConn) OutgoingQueue ¶
func (c *QueuePacketConn) OutgoingQueue(addr net.Addr) <-chan []byte
OutgoingQueue returns the queue of outgoing packets corresponding to addr, creating it if necessary. The contents of the queue will be packets that are written to the address in question using WriteTo.
func (*QueuePacketConn) QueueIncoming ¶
func (c *QueuePacketConn) QueueIncoming(p []byte, addr net.Addr)
QueueIncoming queues and incoming packet and its source address, to be returned in a future call to ReadFrom.
func (*QueuePacketConn) Read ¶
func (c *QueuePacketConn) Read(b []byte) (int, error)
Read calls ReadFrom to read a packet. Created to implement net.Conn interface. Should be only used by stream-oriented transports (DoH, DoT), will return error if this is not the case.
func (*QueuePacketConn) ReadFrom ¶
ReadFrom returns a packet and address previously stored by QueueIncoming.
func (*QueuePacketConn) RemoteAddr ¶
func (c *QueuePacketConn) RemoteAddr() net.Addr
RemoteAddr returns a stub addr. Created to implement net.Conn interface. This should be only used by stream-oriented transports (DoH, DoT).
func (*QueuePacketConn) SetDeadline ¶
func (c *QueuePacketConn) SetDeadline(t time.Time) error
func (*QueuePacketConn) SetReadDeadline ¶
func (c *QueuePacketConn) SetReadDeadline(t time.Time) error
func (*QueuePacketConn) SetWriteDeadline ¶
func (c *QueuePacketConn) SetWriteDeadline(t time.Time) error