mcl_core_lan_secrets (mcl_core v1.0.0)

View Source

The cluster's two secrets, in a node's LAN data dir (docs/DESIGN.md §2.1, DECIDED 2026-12-02 "Shared cookie + secret (Recommended)").

.erlang.cookie is the Erlang cookie: distribution lets in only a node that holds it. gossip.secret keys the HMAC on every gossip packet: a node with another secret hears the cluster and is never dialled. A device that holds both owns the cluster, since distributed Erlang runs any code on any node; the secrets, not the LAN, are the guard.

The cluster's FIRST node generates both, once. Every other node gets the two files copied into its own data dir at install, and refuses to start without them. Nothing here ever overwrites a secret: a data dir holding one of the two and not the other is refused, first node or not.

Summary

Functions

The secrets in Dir; on the first node (First), generated first when neither exists yet.

Both secrets from Dir, each refused when group or others may read it or when it is shorter than 32 bytes.

Types

secrets/0

-type secrets() :: #{cookie := binary(), secret := binary()}.

Functions

ensure(Dir, First)

-spec ensure(file:filename_all(), boolean()) -> {ok, secrets()} | {error, term()}.

The secrets in Dir; on the first node (First), generated first when neither exists yet.

load(Dir)

-spec load(file:filename_all()) -> {ok, secrets()} | {error, term()}.

Both secrets from Dir, each refused when group or others may read it or when it is shorter than 32 bytes.

secret_file(Dir)

-spec secret_file(file:filename_all()) -> file:filename_all().