Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateTLSConfig() *tls.Config
- func NewClientTracer(logger *zerolog.Logger, index uint8) ...
- func NewServerTracer(logger *zerolog.Logger) logging.Tracer
- func SuffixSessionID(sessionID uuid.UUID, b []byte) ([]byte, error)
- func SuffixType(b []byte, datagramType DatagramV2Type) ([]byte, error)
- type BaseDatagramMuxer
- type ConnectRequest
- type ConnectResponse
- type ConnectionType
- type DatagramMuxer
- type DatagramMuxerV2
- type DatagramV2Type
- type Metadata
- type MetricsCollector
- type Packet
- type ProtocolSignature
- type RPCClientStream
- func (rcs *RPCClientStream) Close()
- func (rcs *RPCClientStream) RegisterUdpSession(ctx context.Context, sessionID uuid.UUID, dstIP net.IP, dstPort uint16, ...) (*tunnelpogs.RegisterUdpSessionResponse, error)
- func (rcs *RPCClientStream) UnregisterUdpSession(ctx context.Context, sessionID uuid.UUID, message string) error
- func (rcs *RPCClientStream) UpdateConfiguration(ctx context.Context, version int32, config []byte) (*tunnelpogs.UpdateConfigurationResponse, error)
- type RPCServerStream
- type RawPacket
- type RequestClientStream
- type RequestServerStream
- type SafeStreamCloser
- type TracedPacket
- type TracingSpanPacket
Constants ¶
const ( HandshakeIdleTimeout = 5 * time.Second MaxIdleTimeout = 5 * time.Second MaxIdlePingPeriod = 1 * time.Second // MaxIncomingStreams is 2^60, which is the maximum supported value by Quic-Go MaxIncomingStreams = 1 << 60 )
const (
MaxDatagramFrameSize = 1350
)
Variables ¶
var ( // DataStreamProtocolSignature is a custom protocol signature for data stream DataStreamProtocolSignature = ProtocolSignature{0x0A, 0x36, 0xCD, 0x12, 0xA1, 0x3E} // RPCStreamProtocolSignature is a custom protocol signature for RPC stream RPCStreamProtocolSignature = ProtocolSignature{0x52, 0xBB, 0x82, 0x5C, 0xDB, 0x65} )
Functions ¶
func GenerateTLSConfig ¶
GenerateTLSConfig sets up a bare-bones TLS config for a QUIC server
func NewClientTracer ¶
func NewClientTracer(logger *zerolog.Logger, index uint8) func(context.Context, logging.Perspective, logging.ConnectionID) logging.ConnectionTracer
func SuffixSessionID ¶
SuffixSessionID appends the session ID at the end of the payload. Suffix is more performant than prefix because the payload slice might already have enough capacity to append the session ID at the end
func SuffixType ¶
func SuffixType(b []byte, datagramType DatagramV2Type) ([]byte, error)
Types ¶
type BaseDatagramMuxer ¶
type BaseDatagramMuxer interface { // SendToSession suffix the session ID to the payload so the other end of the QUIC connection can demultiplex the // payload from multiple datagram sessions. SendToSession(session *packet.Session) error // ServeReceive starts a loop to receive datagrams from the QUIC connection ServeReceive(ctx context.Context) error }
type ConnectRequest ¶
type ConnectRequest struct { Dest string `capnp:"dest"` Type ConnectionType `capnp:"type"` Metadata []Metadata `capnp:"metadata"` }
ConnectRequest is the representation of metadata sent at the start of a QUIC application handshake.
func (*ConnectRequest) MetadataMap ¶
func (r *ConnectRequest) MetadataMap() map[string]string
MetadataMap returns a map format of []Metadata.
type ConnectResponse ¶
ConnectResponse is a representation of metadata sent as a response to a QUIC application handshake.
type ConnectionType ¶
type ConnectionType uint16
ConnectionType indicates the type of underlying connection proxied within the QUIC stream.
const ( ConnectionTypeHTTP ConnectionType = iota ConnectionTypeWebsocket ConnectionTypeTCP )
func (ConnectionType) String ¶
func (c ConnectionType) String() string
type DatagramMuxer ¶
type DatagramMuxer struct {
// contains filtered or unexported fields
}
func NewDatagramMuxer ¶
func NewDatagramMuxer(quicSession quic.Connection, log *zerolog.Logger, demuxChan chan<- *packet.Session) *DatagramMuxer
func (*DatagramMuxer) SendToSession ¶
func (dm *DatagramMuxer) SendToSession(session *packet.Session) error
func (*DatagramMuxer) ServeReceive ¶
func (dm *DatagramMuxer) ServeReceive(ctx context.Context) error
type DatagramMuxerV2 ¶
type DatagramMuxerV2 struct {
// contains filtered or unexported fields
}
func NewDatagramMuxerV2 ¶
func NewDatagramMuxerV2( quicSession quic.Connection, log *zerolog.Logger, sessionDemuxChan chan<- *packet.Session, ) *DatagramMuxerV2
func (*DatagramMuxerV2) ReceivePacket ¶
func (dm *DatagramMuxerV2) ReceivePacket(ctx context.Context) (pk Packet, err error)
func (*DatagramMuxerV2) SendPacket ¶
func (dm *DatagramMuxerV2) SendPacket(pk Packet) error
SendPacket sends a packet with datagram version in the suffix. If ctx is a TracedContext, it adds the tracing context between payload and datagram version. The other end of the QUIC connection can demultiplex by parsing the payload as IP and look at the source and destination.
func (*DatagramMuxerV2) SendToSession ¶
func (dm *DatagramMuxerV2) SendToSession(session *packet.Session) error
SendToSession suffix the session ID and datagram version to the payload so the other end of the QUIC connection can demultiplex the payload from multiple datagram sessions
func (*DatagramMuxerV2) ServeReceive ¶
func (dm *DatagramMuxerV2) ServeReceive(ctx context.Context) error
Demux reads datagrams from the QUIC connection and demuxes depending on whether it's a session or packet
type DatagramV2Type ¶
type DatagramV2Type byte
const ( // UDP payload DatagramTypeUDP DatagramV2Type = iota // Full IP packet DatagramTypeIP // DatagramTypeIP + tracing ID DatagramTypeIPWithTrace // Tracing spans in protobuf format DatagramTypeTracingSpan )
type MetricsCollector ¶
type MetricsCollector interface {
// contains filtered or unexported methods
}
MetricsCollector abstracts the difference between client and server metrics from connTracer
type Packet ¶
type Packet interface { Type() DatagramV2Type Payload() []byte Metadata() []byte }
type ProtocolSignature ¶
type ProtocolSignature [6]byte
ProtocolSignature defines the first 6 bytes of the stream, which is used to distinguish the type of stream. It ensures whoever performs a handshake does not write data before writing the metadata.
func DetermineProtocol ¶
func DetermineProtocol(stream io.Reader) (ProtocolSignature, error)
type RPCClientStream ¶
type RPCClientStream struct {
// contains filtered or unexported fields
}
RPCClientStream is a stream to call methods of SessionManager
func NewRPCClientStream ¶
func NewRPCClientStream(ctx context.Context, stream io.ReadWriteCloser, rpcUnregisterUDPSessionDeadline time.Duration, logger *zerolog.Logger) (*RPCClientStream, error)
func (*RPCClientStream) Close ¶
func (rcs *RPCClientStream) Close()
func (*RPCClientStream) RegisterUdpSession ¶
func (rcs *RPCClientStream) RegisterUdpSession(ctx context.Context, sessionID uuid.UUID, dstIP net.IP, dstPort uint16, closeIdleAfterHint time.Duration, traceContext string) (*tunnelpogs.RegisterUdpSessionResponse, error)
func (*RPCClientStream) UnregisterUdpSession ¶
func (*RPCClientStream) UpdateConfiguration ¶
func (rcs *RPCClientStream) UpdateConfiguration(ctx context.Context, version int32, config []byte) (*tunnelpogs.UpdateConfigurationResponse, error)
type RPCServerStream ¶
type RPCServerStream struct {
io.ReadWriteCloser
}
RPCServerStream is a stream to serve RPCs. It is closed when the RPC client is done
func NewRPCServerStream ¶
func NewRPCServerStream(stream io.ReadWriteCloser, protocol ProtocolSignature) (*RPCServerStream, error)
func (*RPCServerStream) Serve ¶
func (s *RPCServerStream) Serve(sessionManager tunnelpogs.SessionManager, configManager tunnelpogs.ConfigurationManager, logger *zerolog.Logger) error
type RequestClientStream ¶
type RequestClientStream struct {
io.ReadWriteCloser
}
func (*RequestClientStream) ReadConnectResponseData ¶
func (rcs *RequestClientStream) ReadConnectResponseData() (*ConnectResponse, error)
ReadConnectResponseData reads the response to a RequestMeta in a stream.
func (*RequestClientStream) WriteConnectRequestData ¶
func (rcs *RequestClientStream) WriteConnectRequestData(dest string, connectionType ConnectionType, metadata ...Metadata) error
WriteConnectRequestData writes requestMeta to a stream.
type RequestServerStream ¶
type RequestServerStream struct {
io.ReadWriteCloser
}
RequestServerStream is a stream to serve requests
func NewRequestServerStream ¶
func NewRequestServerStream(stream io.ReadWriteCloser, signature ProtocolSignature) (*RequestServerStream, error)
func (*RequestServerStream) ReadConnectRequestData ¶
func (rss *RequestServerStream) ReadConnectRequestData() (*ConnectRequest, error)
ReadConnectRequestData reads the handshake data from a QUIC stream.
func (*RequestServerStream) WriteConnectResponseData ¶
func (rss *RequestServerStream) WriteConnectResponseData(respErr error, metadata ...Metadata) error
WriteConnectResponseData writes response to a QUIC stream.
type SafeStreamCloser ¶
type SafeStreamCloser struct {
// contains filtered or unexported fields
}
func NewSafeStreamCloser ¶
func NewSafeStreamCloser(stream quic.Stream) *SafeStreamCloser
func (*SafeStreamCloser) Close ¶
func (s *SafeStreamCloser) Close() error
func (*SafeStreamCloser) CloseWrite ¶
func (s *SafeStreamCloser) CloseWrite() error
func (*SafeStreamCloser) SetDeadline ¶
func (s *SafeStreamCloser) SetDeadline(deadline time.Time) error
type TracedPacket ¶
func (*TracedPacket) Metadata ¶
func (tp *TracedPacket) Metadata() []byte
func (*TracedPacket) Payload ¶
func (tp *TracedPacket) Payload() []byte
func (*TracedPacket) Type ¶
func (tp *TracedPacket) Type() DatagramV2Type
type TracingSpanPacket ¶
func (*TracingSpanPacket) Metadata ¶
func (tsp *TracingSpanPacket) Metadata() []byte
func (*TracingSpanPacket) Payload ¶
func (tsp *TracingSpanPacket) Payload() []byte
func (*TracingSpanPacket) Type ¶
func (tsp *TracingSpanPacket) Type() DatagramV2Type