mcl_core_lan_entry (mcl_core v1.0.0)
View SourceThe LAN entry point for clients that are not BEAM nodes (docs/DESIGN.md §4.2, mcl-core#4): Martha, lazymartha and macula-mcp reach the cluster's capabilities and topics as a named member, with no station.
OFF UNLESS CONFIGURED: the lan map's entry key,
entry => #{address => "192.168.1.20", port => 8471}
address is the LAN address distribution uses, a string or an address tuple; never a wildcard. It must be PRIVATE (10/8, 172.16/12, 192.168/16, 169.254/16, fc00::/7, fe80::/10) or loopback, which exposes nothing beyond the box. Any other address, 0.0.0.0 and :: included, starts no listener, and /health names why: {lan_entry, {not_private, Address}}.
The routes (JSON bodies; node ids as 64 hex characters, bytes as base64url without padding):
POST /lan/v1/challenge{node_id}: a listed node id gets 32 bytes to sign, live 60 s, redeemable once, at this node only. POST /lan/v1/token{node_id, public_key, profile, challenge, signature}: the key must be the node id's (macula_node_keys:node_id/2 under profile, pq_pure or pq_hybrid), the signature over signed_message/2 must verify, the challenge must be live and issued to that id, and the id must still be listed. The answer is a 15-minute token (mcl_core_lan_token). POST /lan/v1/call{org, procedure, args, timeout_ms}, with Authorization: Bearer <token>: the call is made on the LAN as the token's node id (mcl_core_lan:call_as/6), so the serving member writes it as caller, decides auth against it and its guard counts it. GET /lan/v1/events?topic=T, with the bearer token: the topic's LAN events as server-sent events, until the token expires.
Every request that reaches a capability or a topic carries a token, whatever the capability's policy, open included, and every such request (and every event on a stream) reads lan_members again, so a member taken off the list is refused at its next one.
Summary
Functions
The children the LAN tree starts for the entry point: none when Config names no entry, or names an address that is not private (the refusal is kept for verdict/0). Secret is the gossip secret.
Whether Ip is an address the entry point may listen on: private, link-local or loopback.
The listener's cowboy options. An event stream only SENDS, and cowboy closes a connection that RECEIVES nothing for its idle timeout (60 s) unless sending resets it too: without reset_idle_timeout_on_send every stream would end after a minute, whatever its tick does.
What a member signs to redeem Nonce: a label, so the signature means nothing to any other protocol, then the node id and the challenge.
ok, or why a configured entry point did not start.
Functions
-spec child_specs(mcl_core_lan:config(), binary()) -> [supervisor:child_spec()].
The children the LAN tree starts for the entry point: none when Config names no entry, or names an address that is not private (the refusal is kept for verdict/0). Secret is the gossip secret.
-spec private(inet:ip_address()) -> boolean().
Whether Ip is an address the entry point may listen on: private, link-local or loopback.
-spec protocol_opts(cowboy_router:dispatch_rules()) -> cowboy:opts().
The listener's cowboy options. An event stream only SENDS, and cowboy closes a connection that RECEIVES nothing for its idle timeout (60 s) unless sending resets it too: without reset_idle_timeout_on_send every stream would end after a minute, whatever its tick does.
What a member signs to redeem Nonce: a label, so the signature means nothing to any other protocol, then the node id and the challenge.
-spec verdict() -> ok | {degraded, {lan_entry, term()}}.
ok, or why a configured entry point did not start.