Documentation
¶
Overview ¶
Package wire declares Racer's HTTPS/JSON contracts. Codecs validate bounded inputs before returning usable protocol state.
Index ¶
- Constants
- func CanonicalSocketPaths(name string) (client, origin string, err error)
- func ContentHashes(v Publication) (content, membership string, err error)
- func EncodeBootstrap(v BootstrapResponse) ([]byte, error)
- func EncodeBootstrapRequest(v BootstrapRequest) ([]byte, error)
- func EncodeBundle(v KeyringBundle) ([]byte, error)
- func EncodeDelta(base, next Publication) ([]byte, error)
- func EncodeError(v ErrorResponse) ([]byte, error)
- func EncodePublication(v Publication) ([]byte, error)
- func ValidUUID(s string) bool
- func ValidateBootstrapRequest(v BootstrapRequest) error
- type BootstrapRequest
- type BootstrapResponse
- type CacheDefinition
- type CacheID
- type CacheKey
- type CacheKeyRef
- type CanonicalCandidate
- type ClusterID
- type Delta
- type EnrollmentID
- type ErrorCode
- type ErrorResponse
- type Generation
- type KeyPurpose
- type KeyState
- type KeyringBundle
- type Member
- type MembershipVersion
- type NodeID
- type Publication
- type RDMANIC
- type Sequence
Constants ¶
const ( SchemaVersion = 1 BootstrapPath = "/v1/bootstrap" SnapshotPath = "/v1/snapshot" KeyringPath = "/v1/keyring" TokenAudience = "racer-control" MaxBootstrapBytes = 64 * 1024 MaxBundleBytes = 512 * 1024 MaxPublicationBytes = 64 * 1024 * 1024 MaxMembers = 100_000 PollWait = 30 * time.Second CertificateLifetime = 24 * time.Hour BlockDevicesAnnotation = "racer.unbounded-cloud.io/block-devices" RDMANICsAnnotation = "racer.unbounded-cloud.io/rdma-nics" MaxRDMANICs = 64 ExclusionLabel = "racer.unbounded-cloud.io/exclude" )
const ( PageKey KeyPurpose = "page" OriginCredentialsKey KeyPurpose = "origin_credentials" PreparedKey KeyState = "prepared" ActiveKey KeyState = "active" )
const ( DeltaHeader = "X-Racer-Delta-Base" MaxDeltaBytes = 4 * 1024 * 1024 )
Variables ¶
This section is empty.
Functions ¶
func CanonicalSocketPaths ¶
CanonicalSocketPaths returns Linux pathname sockets including room for NUL in sockaddr_un.sun_path (108 bytes). Names are ASCII Kubernetes DNS subdomains.
func ContentHashes ¶
func ContentHashes(v Publication) (content, membership string, err error)
ContentHashes returns lowercase SHA-256 hex, suitable for VersionRecord fields.
func EncodeBootstrap ¶
func EncodeBootstrap(v BootstrapResponse) ([]byte, error)
func EncodeBootstrapRequest ¶
func EncodeBootstrapRequest(v BootstrapRequest) ([]byte, error)
func EncodeBundle ¶
func EncodeBundle(v KeyringBundle) ([]byte, error)
func EncodeDelta ¶
func EncodeDelta(base, next Publication) ([]byte, error)
func EncodeError ¶
func EncodeError(v ErrorResponse) ([]byte, error)
func EncodePublication ¶
func EncodePublication(v Publication) ([]byte, error)
EncodePublication sorts copies of the input collections, never caller state.
func ValidateBootstrapRequest ¶
func ValidateBootstrapRequest(v BootstrapRequest) error
ValidateBootstrapRequest checks the wire fields, CSR syntax, and full encoded size without serializing. Proof of possession and identity binding belong to the issuer. Direct callers have the same size bound as EncodeBootstrapRequest.
Types ¶
type BootstrapRequest ¶
type BootstrapRequest struct {
RDMANICs []RDMANIC `json:"rdma_nics"`
SchemaVersion uint32 `json:"schema_version"`
Cluster ClusterID `json:"cluster"`
Enrollment EnrollmentID `json:"enrollment"`
CSRDER []byte `json:"csr_der"`
}
BootstrapRequest contains no bearer token. The transport reads the projected token for each issuance attempt and supplies it in Authorization.
func DecodeBootstrap ¶
func DecodeBootstrap(r io.Reader) (BootstrapRequest, error)
DecodeBootstrap bounds the entire document before allocating decoded state.
type BootstrapResponse ¶
type BootstrapResponse struct {
SchemaVersion uint32 `json:"schema_version"`
Cluster ClusterID `json:"cluster"`
Node NodeID `json:"node"`
Enrollment EnrollmentID `json:"enrollment"`
CertificateChain [][]byte `json:"certificate_chain"`
BlockDevices string `json:"block_devices,omitempty"`
}
func DecodeBootstrapResponse ¶
func DecodeBootstrapResponse(r io.Reader) (BootstrapResponse, error)
type CacheDefinition ¶
type CacheKey ¶
type CacheKey struct {
Key CacheKeyRef
State KeyState
// contains filtered or unexported fields
}
CacheKey intentionally hides material from ordinary formatting and JSON. Only the bounded bundle codec may access and encode the 32-byte material.
func NewCacheKey ¶
func NewCacheKey(ref CacheKeyRef, state KeyState, material [32]byte) (CacheKey, error)
NewCacheKey is the only material ingress besides bounded bundle decoding.
func (CacheKey) EqualMaterial ¶
EqualMaterial compares private key bytes without exposing them to consumers. It is intended for bundle replay validation, not authentication.
type CacheKeyRef ¶
type CacheKeyRef struct {
Cache CacheID `json:"cache"`
ID []byte `json:"id"` // Exactly 16 bytes, padded standard base64 on the wire.
Purpose KeyPurpose `json:"purpose"`
}
type CanonicalCandidate ¶
type CanonicalCandidate struct {
// contains filtered or unexported fields
}
CanonicalCandidate owns validated, sorted publication content, including nested pointers. Its private state can be reused for hashing and encoding after counter assignment without retaining caller-owned mutable state. The zero value is invalid.
func NewCanonicalCandidate ¶
func NewCanonicalCandidate(v Publication) (CanonicalCandidate, error)
NewCanonicalCandidate validates and copies content once. Input counters are ignored; final encoding checks the assigned counters and complete byte bound.
func (CanonicalCandidate) ContentHashes ¶
func (c CanonicalCandidate) ContentHashes() (content, membership string, err error)
ContentHashes returns the same counter-free hashes as ContentHashes without repeating validation, copying, or sorting of the candidate's collections.
func (CanonicalCandidate) EncodePublication ¶
func (c CanonicalCandidate) EncodePublication(sequence Sequence, membership MembershipVersion) ([]byte, error)
EncodePublication encodes the candidate with nonzero counters. It does not mutate the candidate, and each call returns independently owned bytes.
type Delta ¶
type Delta struct {
DeltaVersion uint32 `json:"delta_version"`
Cluster ClusterID `json:"cluster"`
BaseSequence Sequence `json:"base_sequence,string"`
BaseHash string `json:"base_hash"`
Sequence Sequence `json:"sequence,string"`
MembershipVersion MembershipVersion `json:"membership_version,string"`
ContentHash string `json:"content_hash"`
UpsertMembers []Member `json:"upsert_members"`
RemoveMembers []NodeID `json:"remove_members"`
Caches []CacheDefinition `json:"caches"`
}
Delta is transported only on the authenticated snapshot endpoint. Hashes use ContentHashes, not a second canonical representation or placement authority.
type EnrollmentID ¶
type EnrollmentID string
type ErrorResponse ¶
type ErrorResponse struct {
Code ErrorCode `json:"code"`
}
func DecodeError ¶
func DecodeError(r io.Reader) (ErrorResponse, error)
type Generation ¶
type Generation uint64
type KeyPurpose ¶
type KeyPurpose string
type KeyringBundle ¶
type KeyringBundle struct {
SchemaVersion uint32
Cluster ClusterID
Generation Generation
PeerTrustRoots [][]byte
CacheKeys []CacheKey
}
func DecodeBundle ¶
func DecodeBundle(r io.Reader) (KeyringBundle, error)
func (KeyringBundle) MarshalJSON ¶
func (b KeyringBundle) MarshalJSON() ([]byte, error)
MarshalJSON prevents bypassing validation through the standard JSON encoder.
type Member ¶
type MembershipVersion ¶
type MembershipVersion uint64
type Publication ¶
type Publication struct {
SchemaVersion uint32 `json:"schema_version"`
Cluster ClusterID `json:"cluster"`
Sequence Sequence `json:"sequence,string"`
MembershipVersion MembershipVersion `json:"membership_version,string"`
Members []Member `json:"members"`
Caches []CacheDefinition `json:"caches"`
}
func ApplyDelta ¶
func ApplyDelta(base Publication, reader io.Reader) (Publication, error)
func DecodePublication ¶
func DecodePublication(r io.Reader) (Publication, error)
type RDMANIC ¶
type RDMANIC struct {
Device string `json:"device"`
Port uint8 `json:"port"`
Rail uint16 `json:"rail"`
GID string `json:"gid,omitempty"`
NUMANode *uint32 `json:"numa_node,omitempty"`
}
func CanonicalRDMANICs ¶
CanonicalRDMANICs copies NICs, including nested pointers, in rail/device/port order.