client

package
v0.1.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package client is how a mesh component reads from its control plane. Node and router share it, so the body cap, the status handling and the signature check on /keys are a single code path. It depends on api/ only: importing it pulls in none of the control plane server.

Index

Constants

View Source
const MaxBodyBytes = 8 << 20

MaxBodyBytes caps every response body read from a control plane: a misbehaving or impersonated server must not be able to make a client buffer arbitrary amounts of memory. It is sized for the largest legitimate answer, the ban set in /info at roughly 55 bytes per peer ID, so about 150k banned peers fit; the policy is bounded by the control plane's own 1 MiB cap on POST /policies, and /keys is a few hundred bytes.

Variables

View Source
var ErrBodyTooLarge = errors.New("control plane answer exceeds the body cap")

ErrBodyTooLarge marks an answer over MaxBodyBytes. It is an error, never a prefix: a protobuf message cut at a field boundary still decodes, so a truncated ban set or router list would be read as a smaller, valid one.

Functions

func NewHTTPClient

func NewHTTPClient(timeout time.Duration, allowInsecure func() bool) *http.Client

NewHTTPClient is the HTTP client for every request a mesh component makes to its control plane. A nil allowInsecure never allows plaintext.

func ReadBody

func ReadBody(r io.Reader) ([]byte, error)

ReadBody reads a control plane response body of at most MaxBodyBytes and reports ErrBodyTooLarge for anything larger.

Types

type Client

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

Client reads the pull side of the mesh protocol from one control plane.

func New

func New(baseURL string, httpClient *http.Client) *Client

New normalizes baseURL, https:// when no scheme is given and no trailing slash, and speaks through httpClient, which the caller builds with NewHTTPClient so its own transport policy applies.

func (*Client) FetchInfo

func (c *Client) FetchInfo(ctx context.Context) (*api.ControlPlaneInfoResponse, error)

FetchInfo is GET /info: the router addresses, the ban set and the OIDC details a node needs to enroll.

func (*Client) FetchKeys

func (c *Client) FetchKeys(ctx context.Context, trusted []ed25519.PublicKey) ([]ed25519.PublicKey, error)

FetchKeys is GET /keys: the control plane's currently valid signing keys. The set is accepted only if signed by a key in trusted (api.VerifyKeysResponse): whoever answers the URL must already be the control plane, not become it.

func (*Client) FetchPolicy

func (c *Client) FetchPolicy(ctx context.Context, biscuit []byte) (*api.PolicyConfigGetResponse, error)

FetchPolicy is GET /policies, authenticated with the caller's biscuit: the roles and bindings a node compiles into its authorization rules.

Jump to

Keyboard shortcuts

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