Documentation ¶
Overview ¶
Package turbotunnel provides support for overlaying a virtual net.PacketConn on some other network carrier.
Index ¶
- Variables
- type ClientID
- type ClientMap
- 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) ReadFrom(p []byte) (int, net.Addr, error)
- 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) WriteTo(p []byte, addr net.Addr) (int, error)
- type RedialPacketConn
- func (c *RedialPacketConn) Close() error
- func (c *RedialPacketConn) LocalAddr() net.Addr
- func (c *RedialPacketConn) ReadFrom(p []byte) (int, net.Addr, error)
- func (c *RedialPacketConn) SetDeadline(t time.Time) error
- func (c *RedialPacketConn) SetReadDeadline(t time.Time) error
- func (c *RedialPacketConn) SetWriteDeadline(t time.Time) error
- func (c *RedialPacketConn) WriteTo(p []byte, addr net.Addr) (int, error)
Constants ¶
This section is empty.
Variables ¶
var Token = [8]byte{0x12, 0x93, 0x60, 0x5d, 0x27, 0x81, 0x75, 0xf5}
This magic prefix is how a client opts into turbo tunnel mode. It is just a randomly generated byte string.
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.
type ClientMap ¶
type ClientMap struct {
// contains filtered or unexported fields
}
ClientMap manages a mapping of live clients (keyed by address, which will be a ClientID) to their respective send queues. ClientMap's functions are safe to call from multiple goroutines.
func NewClientMap ¶
NewClientMap creates a ClientMap that expires clients after a timeout.
The timeout does not have to be kept in sync with QUIC's internal idle timeout. If a client is removed from the client map while the QUIC session is still live, the worst that can happen is a loss of whatever packets were in the send queue at the time. If QUIC later decides to send more packets to the same client, we'll instantiate a new send queue, and if the client ever connects again with the proper client ID, we'll deliver them.
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 client that sent them). There are many outgoing queues, one for each client 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 clients 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 an incoming packet and its source address, to be returned in a future call to ReadFrom. This function takes ownership of p and the caller must not reuse it.
func (*QueuePacketConn) ReadFrom ¶
ReadFrom returns a packet and address previously stored by QueueIncoming.
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
type RedialPacketConn ¶
type RedialPacketConn struct {
// contains filtered or unexported fields
}
RedialPacketConn implements a long-lived net.PacketConn atop a sequence of other, transient net.PacketConns. RedialPacketConn creates a new net.PacketConn by calling a provided dialContext function. Whenever the net.PacketConn experiences a ReadFrom or WriteTo error, RedialPacketConn calls the dialContext function again and starts sending and receiving packets on the new net.PacketConn. RedialPacketConn's own ReadFrom and WriteTo methods return an error only when the dialContext function returns an error.
RedialPacketConn uses static local and remote addresses that are independent of those of any dialed net.PacketConn.
func NewRedialPacketConn ¶
func NewRedialPacketConn( localAddr, remoteAddr net.Addr, dialContext func(context.Context) (net.PacketConn, error), ) *RedialPacketConn
NewQueuePacketConn makes a new RedialPacketConn, with the given static local and remote addresses, and dialContext function.
func (*RedialPacketConn) Close ¶
func (c *RedialPacketConn) Close() error
Close unblocks pending operations and makes future operations fail with a "closed connection" error.
func (*RedialPacketConn) LocalAddr ¶
func (c *RedialPacketConn) LocalAddr() net.Addr
LocalAddr returns the localAddr value that was passed to NewRedialPacketConn.
func (*RedialPacketConn) ReadFrom ¶
ReadFrom reads a packet from the currently active net.PacketConn. The packet's original remote address is replaced with the RedialPacketConn's own remote address.
func (*RedialPacketConn) SetDeadline ¶
func (c *RedialPacketConn) SetDeadline(t time.Time) error
func (*RedialPacketConn) SetReadDeadline ¶
func (c *RedialPacketConn) SetReadDeadline(t time.Time) error
func (*RedialPacketConn) SetWriteDeadline ¶
func (c *RedialPacketConn) SetWriteDeadline(t time.Time) error