- Go 84%
- Python 6.7%
- Shell 5.8%
- PowerShell 3.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .github/workflows | ||
| architecture | ||
| assets | ||
| cmd/macula-cli | ||
| guides | ||
| internal | ||
| scripts | ||
| .gitignore | ||
| .golangci.yml | ||
| .goreleaser.yml | ||
| .tool-versions | ||
| CHANGELOG.md | ||
| go.mod | ||
| go.sum | ||
| install.ps1 | ||
| install.sh | ||
| LICENSE-APACHE | ||
| LICENSE-MIT | ||
| README.md | ||
| SECURITY.md | ||
| uninstall.ps1 | ||
| uninstall.sh | ||
macula-cli
Test, monitor and use the macula mesh from the command line
What is macula-cli?
A scriptable client of the macula mesh: one Go binary, built on
macula-go, that links to real
stations and reports exactly what happened. It has no interactive mode by
design. Its consumers are scripts and agents that parse -json output, and
every command prints the same data either way.
Wire 1.0 is the post-quantum wire: ML-DSA-87 identities (the ML-DSA-87 +
RSA-PSS-4096 composite in pq_hybrid, the fleet's profile), key exchange on
SecP384r1MLKEM1024 alone (ML-KEM-1024 with P-384, which meets CNSA 2.0 and BSI
TR-02102), signed requests, seeds pinned by the node_id each station must
prove, and end-to-end sealing of calls to a provider that advertises a KEM
key. Links speak handshake version 5 alone, the versions and profiles both ends
support negotiated and a downgrade refused. Releases before 0.9.0 spoke the
retired 10.x wire and releases before 0.16.0 the one before wire 1.0: each
reaches only the stations of its own wire, never the current fleet.
Install
Linux / macOS:
curl -fsSL https://raw.githubusercontent.com/macula-io/macula-cli/master/install.sh | bash
Windows (PowerShell):
irm https://raw.githubusercontent.com/macula-io/macula-cli/master/install.ps1 | iex
Both download the release archive for your OS and architecture from
GitHub Releases, check it
against the release's checksums.txt, and install macula-cli
($HOME/.local/bin on Linux and macOS, %LOCALAPPDATA%\macula-cli on Windows).
MACULA_CLI_INSTALL_DIR moves the directory and MACULA_CLI_VERSION (a tag,
such as v0.16.0) installs that release instead of the latest. With Go 1.27:
go install github.com/macula-io/macula-cli/cmd/macula-cli@latest.
The public stations have IPv6 addresses only: macula-cli needs a working IPv6 route and outbound UDP to port 4433.
To uninstall, remove the binary and leave the config directory alone:
curl -fsSL https://raw.githubusercontent.com/macula-io/macula-cli/master/uninstall.sh | bash
--purge / -Purge removes the config directory too. The flag reaches the
script either as its first argument (bash -s --) or, on Windows, as an
argument to a script block — a script file would be refused by the default
Restricted execution policy, and a script block is never read from disk:
curl -fsSL https://raw.githubusercontent.com/macula-io/macula-cli/master/uninstall.sh | bash -s -- --purge
& ([scriptblock]::Create((irm https://raw.githubusercontent.com/macula-io/macula-cli/master/uninstall.ps1))) -Purge
That directory holds more than the node key: identity.key, the person key
person.key — which signs person bind and person unbind for every client
you bound — and the memberships person join kept under
person/<person id>/<realm>.ucan. A purged person key cannot be recovered: a
realm admits the person once more, and every client is bound to it again.
Quick start
Every station is pinned: -seed host[:port]@<station node_id hex>. A realm is
-realm (its name, io.macula, or its 64-hex id, which is the name's sha256),
trusted with -realm-key (the realm key as carried, in hex, or @file).
io.macula publishes its realm key, with the realm's name and id and the key's
id, at https://realm.macula.io/.well-known/macula-realm.json. -realm-key
takes hex, so convert the public_key field once:
curl -fsSL https://realm.macula.io/.well-known/macula-realm.json \
| python3 -c 'import base64,json,sys; print(base64.b64decode(json.load(sys.stdin)["public_key"]).hex())' \
> io.macula.key
SEED='station-fi-helsinki.macula.io:4433@004d1f470097ccf8826ce291900e882fdb1f20375e53901facaec0f23eb4efd8'
macula-cli connect -seed "$SEED"
macula-cli dht find-records-by-type -seed "$SEED" node_record
macula-cli call -seed "$SEED" -realm io.macula -realm-key @io.macula.key -payload '"hello"' mcl-echo/echo
The first command that needs a key creates one (identity.key in the user
config directory's macula-cli/; it solves the admission puzzle, which takes
a few seconds). -ephemeral uses a key made for the run and never saved;
-identity <file> uses another file.
Commands
| Command | What it does |
|---|---|
connect |
Resolve the seed, then link to its station over the wire 1.0 post-quantum handshake (version 5, versions and profiles negotiated, a downgrade refused), refusing a station that does not prove the pinned node_id |
call <procedure> |
Call a procedure by direct dial: to any trusted provider, or -provider <node_id>. Sealed end to end when the provider advertises a KEM key; the seal report (sealed, provider, seal_key_id) says which. -ucan-file presents a UCAN (a membership, or a chain: the token, then its proofs) to a gated procedure |
serve <procedure> |
Serve a procedure, echoing each payload or answering -reply, until stopped (-once, -for). -confidential preferred (default) advertises a KEM key and answers sealed calls sealed, required also refuses clear calls, off serves in the clear; each call reports sealed. -require-member <can> serves only realm members: a caller whose UCAN chain, rooted at -realm-key, grants that can (an <org>/<name> procedure only) |
pubsub publish <topic> |
Publish one payload |
pubsub watch <topic> |
Print each verified event (-count, -for) |
stream probe |
A bidirectional streaming round trip between two fresh nodes, through their stations |
content share <file> |
Serve a file from this node and print its content id, while it runs |
content get <mcid> |
Fetch content from the nodes that share it, checked against its id |
content probe |
Share and fetch between two fresh nodes |
dht find-record, find-records <key> |
Verified records under a storage key |
dht find-records-by-type <type> |
Verified records of a type: node_record, station_endpoint, org_directory, ... |
identity |
This node's key: node_id, key id, profile |
identity prove-ownership |
A payload with an ownership proof v2 (asserted_by, mcl-om#7) by which this node authorises every field, for one procedure and realm, once |
realm join |
Ask a realm to admit this device: a human admits it at the printed join URL (-wait polls) |
realm status <session> |
A join session's state, and what the realm granted once confirmed |
realm membership |
This node's membership UCAN, over the mesh; the node must be admitted |
person init |
Your person key (person.key, beside the node key): it signs your requests to bind your clients and never connects |
person join |
Join a realm once, as yourself: confirm at the join URL signed in as you; keeps the membership the realm issues to your person key, asking it to last -membership-ttl (default 720h, the realm's 30-day cap) |
person bind -to <node_id> |
The realm admits that node as your client, on its own membership sponsored by you: it renews its own token at your tier and ends with your membership |
person unbind -to <node_id> |
The realm ends that client's membership; you can bind it again later |
version |
This binary's version, commit and build time (-v and --version too) |
One person, many clients
A realm-gated procedure (realm_member_required) serves a caller whose UCAN
is rooted at the realm's key. With a person key you join once, verified by
email, and bind each of your clients once instead of joining every device:
macula-cli person init # once: prints your person id
macula-cli person join -realm io.macula # once: confirm at the join URL, signed in by email
macula-cli identity # this client's node_id
macula-cli person bind -seed ... -realm io.macula -realm-key @io.macula.key -to <client node_id>
macula-cli realm membership -seed ... -realm io.macula -realm-key @io.macula.key # on the client: its own token
The client asks for its own membership token (realm membership; macula-mcp
renews its own) and presents it to a gated procedure with call -ucan-file.
person join asks for a membership of -membership-ttl (default 720h); the
realm clamps it to its cap, the join page shows the lifetime before you
confirm, and a realm older than this ignores the ask and keeps its own default
(4 hours). The printed expiry is what was minted.
person bind signs the request with your person key; the connection can be
any node's. The realm admits the client on its own membership with you as its
sponsor (at most 16 clients per person, one person per node), so the client
renews its own token at your tier for as long as you are a member. Revoking or
resigning your membership ends every client you bound, at its next renewal;
person unbind ends one. A node the realm revoked, or whose dated membership
ended, cannot be bound back in. Every refusal says what to do next.
A procedure '~/<name>' is <name> in the node's own namespace, which needs no
org and no realm key: serve '~/echo' on one node and call '~<its node_id>/echo'
on another. An <org>/<name> procedure is served only by a node the org has
delegated it to, and called only with the realm's key pinned.
Every request to a realm (realm join, realm membership) carries a realm
proof v2 (macula-realm#29): the key signs the whole request, the realm, the
procedure, a timestamp and a nonce, so a relay cannot change what the
admitter reads. macula-cli never admits anything: a person does, at the join
URL.
Payloads are JSON on the command line and in the output. macula's wire has no
boolean (send 0 and 1) and carries integers within int64; bytes are
{"$bytes": "<base64>"} both ways, so a value received can be sent back
unchanged.
See the HOW-TO guide for every flag, and for scripting
against -json.
Output and failures
With -json every command prints one envelope (pubsub watch one per event):
{"ok": true, "data": ...}
{"ok": false, "error": {"kind": "provider_error", "code": "handler_error", "detail": "...", "message": "..."}}
kind is one of provider_error, relay_error, stream_error,
identity_mismatch, refused (the station refused the registration, with its
reason in code), unacknowledged (the station did not answer the
registration), realm_refusal, timeout, no_link (no station link is up),
no_provider, no_station_endpoint (no usable endpoint record for the
station, with the reason in code), no_realm_key, not_found, not_shared,
content_unavailable, invalid_argument and failed, taken from macula-go's
typed errors and the realm's own error codes, never from a message. A malformed
invocation (a -json one included) prints an invalid_argument envelope and
exits 2, a failure exits 1, -h exits 0.
Build and test
go build ./cmd/macula-cli
go test ./...
Every command's core is tested against macula-go's in-process teststation (two
stations speaking wire 1.0, sharing a DHT, and a test realm with one org), and
realm join against an HTTP realm that verifies the proof as macula-realm
does. No test touches the network. scripts/live_check.sh runs one check
against a fleet station with keys made for the run: connect, node records,
mcl-echo/echo, and a watch hearing one publication. It takes io.macula's
realm key in hex from MACULA_CLI_LIVE_REALM_KEY — the Quick start's
io.macula.key, or its contents as the value — or, where that is unset, from
the Erlang header of a local service checkout named by MCL_ECHO_REALM_HRL,
which a public clone does not have. Its station and realm come from
MACULA_CLI_LIVE_SEED and MACULA_CLI_LIVE_REALM.
Releases: a v* tag builds Linux, macOS and Windows binaries for amd64 and
arm64 with goreleaser and attaches them, with checksums.txt, to the GitHub
release.
Architecture
What macula-cli talks to and what it is made of, as a C4 model: architecture/README.md.
Relationship to other repos
- macula-go: the wire 1.0 node this CLI drives, and its teststation.
- macula-station: the stations it links to. The repository is private; a
station is reached by
-seed host:port@<node_id>, as above. - macula-realm: the realm that admits devices and issues membership, serving
realm.macula.io. The repository is private; the realm's public key and ids are what.well-known/macula-realm.jsonpublishes.
License
Apache-2.0 OR MIT, at your option. See LICENSE-APACHE and LICENSE-MIT.