Documentation
¶
Overview ¶
Package relayclient carries a sensor's platform requests through a sensor relay (api docs/rfcs/RFC-116-sensor-relay.md in openctemio/openctem; openctem research 194 §4).
Transport is an http.RoundTripper. Put it under the request signer (sensorsig.Transport's Base): each signed v2 request is sealed to the platform's ingest key (pkg/sealedmsg) and posted to the relay; the answer arrives on the sensor's relay mailbox, sealed to the sensor's encryption key and signed by the platform's response key, and is handed back as the request's http.Response. The relay can delay or drop traffic; it cannot read it, change it or answer in the platform's name.
Connection: TLS 1.3 to the relay, the relay's certificate checked by its SPKI pin from the pairing bundle (or by RootCAs when no pin is set), the sensor's identity key as the client certificate, and the platform-signed ticket on every request (Config.Ticket returns the current one; the sensor renews it through the relay itself).
Stability: Experimental (docs/STABILITY.md).
Index ¶
Constants ¶
const (
DefaultResponseTimeout = 60 * time.Second
)
Defaults.
Variables ¶
var ( // ErrNoResponse: the platform's answer did not arrive in time (the // request may or may not have been processed; callers retry // idempotently, as for any lost response). ErrNoResponse = errors.New("relayclient: no response through the relay in time") // ErrTicket: the relay refused the ticket (expired, revoked, another // relay): renew it. ErrTicket = errors.New("relayclient: relay refused the ticket") // ErrPin: the relay's certificate does not match the pinned key. ErrPin = errors.New("relayclient: relay certificate does not match the pin") )
Errors.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// RelayURL is the relay's base URL (https).
RelayURL string
// RelayPin is the SHA-256 of the relay certificate's
// SubjectPublicKeyInfo (from the pairing bundle). When set, the
// certificate chain is not used: the pin is the trust anchor.
RelayPin []byte
// RootCAs verifies the relay's certificate when no pin is set (nil:
// the system roots).
RootCAs *x509.CertPool
// Identity is the sensor's Ed25519 identity key: the TLS client key the
// ticket names.
Identity ed25519.PrivateKey
// Ticket returns the current relay ticket.
Ticket func() string
// Route is the sensor's realm and id (from its pairing).
Route sealedmsg.Route
// IngestKey is the platform's current ingest key.
IngestKey *sealedmsg.PublicKey
// ResponseKeys are the pinned platform response keys.
ResponseKeys []ed25519.PublicKey
// EncryptionKey is the sensor's own encryption key.
EncryptionKey *sealedmsg.PrivateKey
// Proxy is the control path's proxy (nil: none).
Proxy func(*http.Request) (*url.URL, error)
// ResponseTimeout bounds the wait for one answer (default 60 s).
ResponseTimeout time.Duration
// OnTicketRefused is called when the relay refuses the ticket.
OnTicketRefused func()
// Logf receives state changes (default: none).
Logf func(format string, args ...any)
// contains filtered or unexported fields
}
Config configures a Transport.
type Stats ¶
type Stats struct {
Sent int64 `json:"sent"`
Answered int64 `json:"answered"`
TimedOut int64 `json:"timed_out"`
DroppedForeign int64 `json:"dropped_foreign"` // responses that answered no outstanding request
DroppedRefused int64 `json:"dropped_refused"` // envelopes that did not open or verify
RelayThrottled int64 `json:"relay_throttled"` // 429 from the relay
TicketRefusals int64 `json:"ticket_refusals"` // 401 from the relay
PollErrors int64 `json:"poll_errors"` // failed mailbox polls
PendingRequests int64 `json:"pending_requests"` // waiting for an answer now
}
Stats are the transport's counters.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is the relay round tripper.
func New ¶
New checks the configuration and builds a Transport. Call Run to start receiving answers.
func (*Transport) RoundTrip ¶
RoundTrip seals the request, posts it to the relay and waits for the platform's answer.