transport

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2026 License: GPL-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	H2EdgeSNI                 = "h2.cftunnel.com"
	H2ResponseMetaCloudflared = `{"src":"cloudflared"}`
)
View Source
const (
	QuicEdgeSNI  = "quic.cftunnel.com"
	QuicEdgeALPN = "argotunnel"
)
View Source
const (
	X25519MLKEM768PQKex = tls.CurveID(0x11ec)
	FeaturePostQuantum  = "postquantum"
)
View Source
const (
	ProtocolQUIC         = "quic"
	ProtocolHTTP2        = "http2"
	ProtocolH2MUX        = "h2mux"
	DefaultProtocolRetry = 5
)

Variables

View Source
var CloudflareRootCertPool = LoadCloudflareRootCertPool
View Source
var DialQUIC = func(ctx context.Context, packetConn net.PacketConn, addr net.Addr, tlsConfig *tls.Config, quicConfig *quic.Config) (*quic.Conn, error) {
	return quic.Dial(ctx, packetConn, addr, tlsConfig, quicConfig)
}
View Source
var FlushableContentTypes = []string{sseContentType, grpcContentType, ndjsonContentType}
View Source
var LookupCloudflaredFeatures = func(ctx context.Context) ([]byte, error) {
	lookupCtx, cancel := context.WithTimeout(ctx, featureLookupTimeout)
	defer cancel()

	records, err := net.DefaultResolver.LookupTXT(lookupCtx, featureSelectorHostname)
	if err != nil || len(records) == 0 {
		return nil, err
	}
	return []byte(records[0]), nil
}

Functions

func AccountEnabled

func AccountEnabled(accountTag string, percentage uint32) bool

func ApplyPostQuantumCurvePreferences

func ApplyPostQuantumCurvePreferences(config *tls.Config, features []string)

func HasFeature

func HasFeature(features []string, target string) bool

func IsQUICBroken

func IsQUICBroken(err error) bool

func IsRetryableReadError

func IsRetryableReadError(err error) bool

func LoadCloudflareRootCertPool

func LoadCloudflareRootCertPool() (*x509.CertPool, error)

func NewEdgeTLSConfig

func NewEdgeTLSConfig(rootCAs *x509.CertPool, serverName string, nextProtos []string) *tls.Config

func NewStreamReadWriteCloser

func NewStreamReadWriteCloser(stream QuicStreamHandle) *streamReadWriteCloser

func NormalizeProtocol

func NormalizeProtocol(protocol string) (string, error)

func QuicInitialPacketSize

func QuicInitialPacketSize(ipVersion int) uint16

func ResolveRemoteDatagramVersion

func ResolveRemoteDatagramVersion(accountTag string, record []byte) (string, error)

func ShouldFlushHTTPHeaders

func ShouldFlushHTTPHeaders(headers http.Header) bool

func WrapWebsocketError

func WrapWebsocketError(err error) error

Types

type FeatureSelector

type FeatureSelector struct {
	// contains filtered or unexported fields
}

func NewFeatureSelector

func NewFeatureSelector(ctx context.Context, accountTag string, configured string) *FeatureSelector

func (*FeatureSelector) Snapshot

func (s *FeatureSelector) Snapshot() (string, []string)

type HTTP2Connection

type HTTP2Connection struct {
	// contains filtered or unexported fields
}

func NewHTTP2Connection

func NewHTTP2Connection(
	ctx context.Context,
	edgeAddr *discovery.EdgeAddr,
	connIndex uint8,
	credentials protocol.Credentials,
	connectorID uuid.UUID,
	features []string,
	numPreviousAttempts uint8,
	gracePeriod time.Duration,
	tunnelDialer N.Dialer,
	handler HTTP2Handler,
	log logger.ContextLogger,
) (*HTTP2Connection, error)

func (*HTTP2Connection) Close

func (c *HTTP2Connection) Close() error

func (*HTTP2Connection) Serve

func (c *HTTP2Connection) Serve(ctx context.Context) error

func (*HTTP2Connection) ServeHTTP

func (c *HTTP2Connection) ServeHTTP(w http.ResponseWriter, r *http.Request)

type HTTP2DataStream

type HTTP2DataStream struct {
	// contains filtered or unexported fields
}

func (*HTTP2DataStream) Close

func (s *HTTP2DataStream) Close() error

func (*HTTP2DataStream) Read

func (s *HTTP2DataStream) Read(p []byte) (int, error)

func (*HTTP2DataStream) Write

func (s *HTTP2DataStream) Write(p []byte) (n int, err error)

type HTTP2FlushState

type HTTP2FlushState struct {
	// contains filtered or unexported fields
}

type HTTP2FlushWriter

type HTTP2FlushWriter struct {
	// contains filtered or unexported fields
}

func (*HTTP2FlushWriter) Write

func (w *HTTP2FlushWriter) Write(p []byte) (int, error)

type HTTP2Handler

type HTTP2Handler interface {
	DispatchRequest(ctx context.Context, stream io.ReadWriteCloser, writer protocol.ConnectResponseWriter, request *protocol.ConnectRequest)
	ApplyConfig(version int32, config []byte) config.UpdateResult
	NotifyConnected(connIndex uint8, protocol string)
}

type HTTP2ResponseWriter

type HTTP2ResponseWriter struct {
	// contains filtered or unexported fields
}

func (*HTTP2ResponseWriter) AddTrailer

func (w *HTTP2ResponseWriter) AddTrailer(name, value string)

func (*HTTP2ResponseWriter) WriteResponse

func (w *HTTP2ResponseWriter) WriteResponse(responseError error, metadata []protocol.Metadata) error

type HTTP2Stream

type HTTP2Stream struct {
	// contains filtered or unexported fields
}

func NewHTTP2Stream

func NewHTTP2Stream(reader io.ReadCloser, writer io.Writer) *HTTP2Stream

func (*HTTP2Stream) Close

func (s *HTTP2Stream) Close() error

func (*HTTP2Stream) Read

func (s *HTTP2Stream) Read(p []byte) (int, error)

func (*HTTP2Stream) Write

func (s *HTTP2Stream) Write(p []byte) (int, error)

type ProtocolSelector

type ProtocolSelector interface {
	Current() string
	Fallback() (string, bool)
}

func NewProtocolSelector

func NewProtocolSelector(protocol string, postQuantum bool) (ProtocolSelector, error)

type QUICConnection

type QUICConnection struct {
	// contains filtered or unexported fields
}

func NewQUICConnection

func NewQUICConnection(
	ctx context.Context,
	edgeAddr *discovery.EdgeAddr,
	connIndex uint8,
	credentials protocol.Credentials,
	connectorID uuid.UUID,
	datagramVersion string,
	features []string,
	numPreviousAttempts uint8,
	gracePeriod time.Duration,
	tunnelDialer N.Dialer,
	onConnected func(),
	log logger.ContextLogger,
) (*QUICConnection, error)

func (*QUICConnection) Close

func (q *QUICConnection) Close() error

func (*QUICConnection) DatagramVersion

func (q *QUICConnection) DatagramVersion() string

func (*QUICConnection) OpenRPCStream

func (q *QUICConnection) OpenRPCStream(ctx context.Context) (io.ReadWriteCloser, error)

func (*QUICConnection) SendDatagram

func (q *QUICConnection) SendDatagram(data []byte) error

func (*QUICConnection) Serve

func (q *QUICConnection) Serve(ctx context.Context, handler StreamHandler) error

type QuicStreamHandle

type QuicStreamHandle interface {
	io.Reader
	io.Writer
	io.Closer
	CancelRead(code quic.StreamErrorCode)
	CancelWrite(code quic.StreamErrorCode)
	SetWriteDeadline(t time.Time) error
}

type StreamHandler

type StreamHandler interface {
	HandleDataStream(ctx context.Context, stream io.ReadWriteCloser, request *protocol.ConnectRequest, connIndex uint8)
	HandleRPCStream(ctx context.Context, stream io.ReadWriteCloser, connIndex uint8)
	HandleRPCStreamWithSender(ctx context.Context, stream io.ReadWriteCloser, connIndex uint8, sender protocol.DatagramSender)
	HandleDatagram(ctx context.Context, datagram []byte, sender protocol.DatagramSender)
}

type WebsocketConn

type WebsocketConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewWebsocketConn

func NewWebsocketConn(conn net.Conn, state ws.State) *WebsocketConn

func (*WebsocketConn) Close

func (c *WebsocketConn) Close() error

func (*WebsocketConn) Read

func (c *WebsocketConn) Read(p []byte) (int, error)

func (*WebsocketConn) Write

func (c *WebsocketConn) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL