Documentation
¶
Index ¶
- Constants
- func DecodeEarlyNoise(buf []byte) (n *tailcfg.EarlyNoise, consumed int, ok bool, err error)
- func DecodeMapResponseFrame(buf []byte) (jsonPayload []byte, compressed bool, consumed int, ok bool, err error)
- func EncodeEarlyNoise(n *tailcfg.EarlyNoise) ([]byte, error)
- func EncodeMapResponseFrame(jsonPayload []byte, compress bool) []byte
- func InitiationVersion(init []byte) (uint16, error)
- func ReadEarlyNoise(br *bufio.Reader) (raw []byte, n *tailcfg.EarlyNoise, ok bool, err error)
- func Responder(ctx context.Context, conn net.Conn, controlKey key.MachinePrivate, init []byte) (*controlbase.Conn, error)
- type CapabilityVersion
- type CaptureFunc
- type EarlyNoise
- type H2Bridge
- type Initiation
- type MapRequest
- type MapResponse
- type RegisterRequest
- type RegisterResponse
Constants ¶
const ( // UpgradeProtocol is the Upgrade / Connection header token. UpgradeProtocol = controlhttpcommon.UpgradeHeaderValue // HandshakeHeaderName carries the base64 Noise initiation on the upgrade request. HandshakeHeaderName = controlhttpcommon.HandshakeHeaderName )
ts2021 control-protocol HTTP upgrade constants, re-exported so the tunnel and capture layers don't import controlhttpcommon directly.
const CurrentCapabilityVersion = tailcfg.CurrentCapabilityVersion
CurrentCapabilityVersion is the capability version of the pinned Tailscale upstream.
const MaxMapFrameBytes = 10 << 20
MaxMapFrameBytes bounds a single MapResponse frame (resource limit, not a protocol check).
Variables ¶
This section is empty.
Functions ¶
func DecodeEarlyNoise ¶
DecodeEarlyNoise parses an EarlyNoise frame and returns the message plus the number of bytes consumed. It returns ok=false with no error when buf does not yet hold a complete frame, so a caller can accumulate more bytes and retry. TODO - review if useful for Encode/Decode symmetry, or remove
func DecodeMapResponseFrame ¶
func DecodeMapResponseFrame(buf []byte) (jsonPayload []byte, compressed bool, consumed int, ok bool, err error)
DecodeMapResponseFrame parses one MapResponse frame from buf, returning the JSON payload, whether the frame body was zstd-compressed, and the number of bytes consumed. It returns ok=false with no error when buf does not yet hold a complete frame.
func EncodeEarlyNoise ¶
func EncodeEarlyNoise(n *tailcfg.EarlyNoise) ([]byte, error)
EncodeEarlyNoise frames an EarlyNoise message as the magic prefix, a 4-byte big-endian length, and the JSON payload.
func EncodeMapResponseFrame ¶
EncodeMapResponseFrame encodes a MapResponse JSON payload as one wire frame: zstd-compressed when compress is true, else raw JSON, prefixed by its 4-byte little-endian length. Preserve the source frame's mode when re-encoding so a client that did not request zstd still decodes the stream.
func InitiationVersion ¶
InitiationVersion reads the 2-byte big-endian protocol (capability) version from a Noise initiation (msg 1). It is carried through unchanged to the upstream initiation and the /key fetch.
func ReadEarlyNoise ¶
ReadEarlyNoise reads an optional leading EarlyNoise frame from br. When the next bytes are an EarlyNoise frame it returns the raw frame and parsed message with ok=true; otherwise ok=false and br is left unconsumed.
func Responder ¶
func Responder(ctx context.Context, conn net.Conn, controlKey key.MachinePrivate, init []byte) (*controlbase.Conn, error)
Responder runs the client-facing Noise IK responder handshake over conn using controlKey (the sidecar's client-facing responder private key). init is the client's initiation recovered from the X-Tailscale-Handshake header. The returned Conn exposes the decrypted inner byte stream.
Types ¶
type CapabilityVersion ¶
type CapabilityVersion = tailcfg.CapabilityVersion
Inner control-protocol message types, aliased to centralize the tailscale.com/tailcfg coupling.
type CaptureFunc ¶
CaptureFunc handles one inner request from the client-facing side and returns the response to relay back. The response Body is streamed to the client and closed by the bridge.
type EarlyNoise ¶
type EarlyNoise = tailcfg.EarlyNoise
Inner control-protocol message types, aliased to centralize the tailscale.com/tailcfg coupling.
type H2Bridge ¶
type H2Bridge struct {
// contains filtered or unexported fields
}
H2Bridge bridges inner HTTP/2 between a client-facing connection (server side) and an upstream connection (client side), both prior-knowledge HTTP/2 over a plaintext Noise byte stream.
func NewH2Bridge ¶
NewH2Bridge returns a bridge whose upstream client speaks over upstreamConn.
func (*H2Bridge) ServeCapture ¶
func (b *H2Bridge) ServeCapture(clientConn net.Conn, capture CaptureFunc)
ServeCapture serves the client-facing side over clientConn, routing each inner request through capture, until the connection closes
type Initiation ¶
type Initiation struct {
// initiation (msg 1) to place base64-encoded in the X-Tailscale-Handshake header
Header []byte
// contains filtered or unexported fields
}
Initiation is a prepared upstream initiator handshake.
func Initiator ¶
func Initiator(machineKey key.MachinePrivate, controlKey key.MachinePublic, version uint16) (*Initiation, error)
Initiator prepares the upstream (server-facing) initiator handshake: machineKey is the sidecar's upstream machine identity, controlKey the real upstream server pubkey, and version the client's capability version carried through unchanged.
func (*Initiation) Complete ¶
func (i *Initiation) Complete(ctx context.Context, conn net.Conn) (*controlbase.Conn, error)
Complete finishes the initiator handshake over conn. The returned Conn exposes the decrypted inner stream.
type MapRequest ¶
type MapRequest = tailcfg.MapRequest
Inner control-protocol message types, aliased to centralize the tailscale.com/tailcfg coupling.
type MapResponse ¶
type MapResponse = tailcfg.MapResponse
Inner control-protocol message types, aliased to centralize the tailscale.com/tailcfg coupling.
type RegisterRequest ¶
type RegisterRequest = tailcfg.RegisterRequest
Inner control-protocol message types, aliased to centralize the tailscale.com/tailcfg coupling.
type RegisterResponse ¶
type RegisterResponse = tailcfg.RegisterResponse
Inner control-protocol message types, aliased to centralize the tailscale.com/tailcfg coupling.