Rename the binary to allmende, add a Makefile with Bonn as default region
- cmd/node -> cmd/allmende; usage, messages and docs use the new name - Makefile: build, init, run (REGION defaults to u1j, Bonn), vet, test, web, web-test, check, clean Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
BIN := bin/allmende
|
||||||
|
REGION ?= u1j# Bonn; several are allowed: make run REGION="u1j u1h" (u1h is Cologne)
|
||||||
|
DATA ?=
|
||||||
|
FLAGS := $(if $(DATA),--data $(DATA))
|
||||||
|
|
||||||
|
.PHONY: help build run init test vet web web-test check clean
|
||||||
|
|
||||||
|
help: ## list the targets
|
||||||
|
@grep -E '^[a-z-]+:.*## ' $(MAKEFILE_LIST) | awk -F':.*## ' '{printf " %-10s %s\n", $$1, $$2}'
|
||||||
|
|
||||||
|
build: ## build the node into bin/allmende (the UI is already embedded)
|
||||||
|
go build -o $(BIN) ./cmd/allmende
|
||||||
|
|
||||||
|
init: build ## create your identity (once): make init [DATA=dir]
|
||||||
|
$(BIN) init $(FLAGS)
|
||||||
|
|
||||||
|
run: build ## run a node (default region Bonn): make run [REGION=u1j] [DATA=dir]
|
||||||
|
$(BIN) run $(FLAGS) $(foreach r,$(REGION),--region $(r))
|
||||||
|
|
||||||
|
vet: ## go vet
|
||||||
|
go vet ./...
|
||||||
|
|
||||||
|
test: ## Go tests with the race detector
|
||||||
|
go test -race ./...
|
||||||
|
|
||||||
|
web: ## rebuild web/dist after changing web/src (needs Node.js)
|
||||||
|
cd web && npm ci && npm run build
|
||||||
|
|
||||||
|
web-test: ## type-check and test the web UI (needs Node.js)
|
||||||
|
cd web && npm ci && npm run typecheck && npm test
|
||||||
|
|
||||||
|
check: vet test web-test ## everything: vet, Go tests, web checks
|
||||||
|
|
||||||
|
clean: ## remove built binaries
|
||||||
|
rm -rf bin
|
||||||
@@ -7,9 +7,9 @@ server and no cost. See [docs/PROTOCOL.md](docs/PROTOCOL.md).
|
|||||||
## Try it
|
## Try it
|
||||||
|
|
||||||
```
|
```
|
||||||
go build -o bin/node ./cmd/node
|
go build -o bin/allmende ./cmd/allmende
|
||||||
bin/node init # shows your 12-word recovery phrase once
|
bin/allmende init # shows your 12-word recovery phrase once
|
||||||
bin/node run --region u1x # u1x = Hamburg area; UI and API on http://127.0.0.1:8080
|
bin/allmende run --region u1x # u1x = Hamburg area; UI and API on http://127.0.0.1:8080
|
||||||
```
|
```
|
||||||
|
|
||||||
Open http://127.0.0.1:8080 to search. Your browser checks every listing's
|
Open http://127.0.0.1:8080 to search. Your browser checks every listing's
|
||||||
@@ -20,7 +20,7 @@ pre-built and embedded; Node.js is only needed to change it
|
|||||||
Buyers can write to an owner straight from a listing, without an account.
|
Buyers can write to an owner straight from a listing, without an account.
|
||||||
Messages are end-to-end encrypted in the browser and relayed through the
|
Messages are end-to-end encrypted in the browser and relayed through the
|
||||||
network, so a node only ever sees ciphertext. The owner reads and answers
|
network, so a node only ever sees ciphertext. The owner reads and answers
|
||||||
in the browser (`node run` prints a sign-in link; open it to get "My listings")
|
in the browser (`allmende run` prints a sign-in link; open it to get "My listings")
|
||||||
and can release the exact address as a signed message.
|
and can release the exact address as a signed message.
|
||||||
|
|
||||||
Owners publish from the same screen: "New listing" takes a title, price and
|
Owners publish from the same screen: "New listing" takes a title, price and
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ func cmdInit(args []string) error {
|
|||||||
fs.Parse(args)
|
fs.Parse(args)
|
||||||
|
|
||||||
if _, err := os.Stat(filepath.Join(*data, "device.key")); err == nil {
|
if _, err := os.Stat(filepath.Join(*data, "device.key")); err == nil {
|
||||||
return fmt.Errorf("%s is already set up. To get access back after losing this machine, use 'node recover'", *data)
|
return fmt.Errorf("%s is already set up. To get access back after losing this machine, use 'allmende recover'", *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
root, phrase, err := identity.NewRoot()
|
root, phrase, err := identity.NewRoot()
|
||||||
@@ -59,7 +59,7 @@ func cmdInit(args []string) error {
|
|||||||
|
|
||||||
fmt.Printf("\nDone. This machine is set up as a device of identity %s…\n", dev.Cert.Author[:12])
|
fmt.Printf("\nDone. This machine is set up as a device of identity %s…\n", dev.Cert.Author[:12])
|
||||||
fmt.Printf("Your device certificate is valid until %s.\n\n", time.Unix(dev.Cert.ExpiresAt, 0).Format("2006-01-02"))
|
fmt.Printf("Your device certificate is valid until %s.\n\n", time.Unix(dev.Cert.ExpiresAt, 0).Format("2006-01-02"))
|
||||||
fmt.Printf("Next: node run --region <region> --data %s\n", *data)
|
fmt.Printf("Next: allmende run --region <region> --data %s\n", *data)
|
||||||
fmt.Printf("The admin token for publishing is in %s\n", filepath.Join(*data, tokenFile))
|
fmt.Printf("The admin token for publishing is in %s\n", filepath.Join(*data, tokenFile))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ func confirmPhrase(in *bufio.Reader, words []string) error {
|
|||||||
fmt.Printf("Word number %d: ", i+1)
|
fmt.Printf("Word number %d: ", i+1)
|
||||||
line, err := in.ReadString('\n')
|
line, err := in.ReadString('\n')
|
||||||
if err != nil && (!errors.Is(err, io.EOF) || line == "") {
|
if err != nil && (!errors.Is(err, io.EOF) || line == "") {
|
||||||
return errors.New("no input; run 'node init' again in a terminal")
|
return errors.New("no input; run 'allmende init' again in a terminal")
|
||||||
}
|
}
|
||||||
if strings.EqualFold(strings.TrimSpace(line), words[i]) {
|
if strings.EqualFold(strings.TrimSpace(line), words[i]) {
|
||||||
break
|
break
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
// Command node runs an Allmende node.
|
// Command allmende runs an Allmende node.
|
||||||
//
|
//
|
||||||
// node init first-time setup: creates your identity and shows your recovery phrase
|
// allmende init first-time setup: creates your identity and shows your recovery phrase
|
||||||
// node run run the node (replicates listings, serves the HTTP API)
|
// allmende run run the node (replicates listings, serves the HTTP API)
|
||||||
// node recover restore from the recovery phrase after a lost or compromised machine
|
// allmende recover restore from the recovery phrase after a lost or compromised machine
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -26,11 +26,11 @@ const (
|
|||||||
const usage = `Allmende: a free, distributed marketplace for homes.
|
const usage = `Allmende: a free, distributed marketplace for homes.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
node init [--data DIR] create your identity (first run)
|
allmende init [--data DIR] create your identity (first run)
|
||||||
node run [--data DIR] --region u1x run the node
|
allmende run [--data DIR] --region u1x run the node
|
||||||
node recover [--data DIR] restore access using your recovery phrase
|
allmende recover [--data DIR] restore access using your recovery phrase
|
||||||
|
|
||||||
Run "node <command> -h" for the options of a command.
|
Run "allmende <command> -h" for the options of a command.
|
||||||
`
|
`
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -103,7 +103,7 @@ func cmdRecover(args []string) error {
|
|||||||
time.Unix(dev.Cert.ExpiresAt, 0).Format("2006-01-02"))
|
time.Unix(dev.Cert.ExpiresAt, 0).Format("2006-01-02"))
|
||||||
fmt.Printf(" - %d of your listings were re-signed from this device.\n", republished)
|
fmt.Printf(" - %d of your listings were re-signed from this device.\n", republished)
|
||||||
fmt.Println(" - A new admin token was written; the old one no longer works.")
|
fmt.Println(" - A new admin token was written; the old one no longer works.")
|
||||||
fmt.Println("\nStart the node with 'node run' so the revocation spreads through the network.")
|
fmt.Println("\nStart the node with 'allmende run' so the revocation spreads through the network.")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,17 +53,17 @@ func cmdRun(args []string) error {
|
|||||||
dev, err := identity.LoadDevice(*data)
|
dev, err := identity.LoadDevice(*data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, os.ErrNotExist) {
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
return fmt.Errorf("%s is not set up yet: run 'node init' first", *data)
|
return fmt.Errorf("%s is not set up yet: run 'allmende init' first", *data)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
until := time.Until(time.Unix(dev.Cert.ExpiresAt, 0))
|
until := time.Until(time.Unix(dev.Cert.ExpiresAt, 0))
|
||||||
if until <= 0 {
|
if until <= 0 {
|
||||||
return errors.New("this device's certificate has expired; run 'node recover' to renew it")
|
return errors.New("this device's certificate has expired; run 'allmende recover' to renew it")
|
||||||
}
|
}
|
||||||
log := slog.New(slog.NewTextHandler(os.Stderr, nil))
|
log := slog.New(slog.NewTextHandler(os.Stderr, nil))
|
||||||
if until < certWarnBefore {
|
if until < certWarnBefore {
|
||||||
log.Warn("device certificate expires soon; run 'node recover' to renew it",
|
log.Warn("device certificate expires soon; run 'allmende recover' to renew it",
|
||||||
"expires", time.Unix(dev.Cert.ExpiresAt, 0).Format("2006-01-02"))
|
"expires", time.Unix(dev.Cert.ExpiresAt, 0).Format("2006-01-02"))
|
||||||
}
|
}
|
||||||
|
|
||||||
+6
-6
@@ -44,7 +44,7 @@ revoked. There are no accounts.
|
|||||||
because on a new machine the owner has only the phrase and does not know
|
because on a new machine the owner has only the phrase and does not know
|
||||||
the old device's key. The replacement device is enrolled at the same
|
the old device's key. The replacement device is enrolled at the same
|
||||||
instant (`issued_at == revoked_at`), which stays valid.
|
instant (`issued_at == revoked_at`), which stays valid.
|
||||||
- **Recovery** (`node recover`): phrase in, all-devices revocation out, fresh
|
- **Recovery** (`allmende recover`): phrase in, all-devices revocation out, fresh
|
||||||
device enrolled, the node's own listings re-signed (`seq + 1`) from the new
|
device enrolled, the node's own listings re-signed (`seq + 1`) from the new
|
||||||
device. The same command renews the yearly certificate.
|
device. The same command renews the yearly certificate.
|
||||||
- **Peer IDs change on recovery** because the device key is the libp2p
|
- **Peer IDs change on recovery** because the device key is the libp2p
|
||||||
@@ -321,7 +321,7 @@ text rules below are enforced by endpoints.
|
|||||||
carry `last_dir`, `needs_reply`, a text `preview` (empty for hidden messages),
|
carry `last_dir`, `needs_reply`, a text `preview` (empty for hidden messages),
|
||||||
`effort` (proof-of-work bits of the first message) and `grant_until`.
|
`effort` (proof-of-work bits of the first message) and `grant_until`.
|
||||||
- **Owner login.** The page itself never contains the admin token (every node
|
- **Owner login.** The page itself never contains the admin token (every node
|
||||||
serves the same page, including public gateways). `node run` prints a link
|
serves the same page, including public gateways). `allmende run` prints a link
|
||||||
`http://127.0.0.1:8080/#/login/<token>` to the terminal, not to its log. The
|
`http://127.0.0.1:8080/#/login/<token>` to the terminal, not to its log. The
|
||||||
token is in the URL fragment, which a browser never sends to a server; the
|
token is in the URL fragment, which a browser never sends to a server; the
|
||||||
page moves it into `sessionStorage` (so closing the tab signs out), removes it
|
page moves it into `sessionStorage` (so closing the tab signs out), removes it
|
||||||
@@ -404,12 +404,12 @@ needed to change the UI (`cd web && npm ci && npm run build`).
|
|||||||
- The node mines the proof-of-work while the request is open, so the form
|
- The node mines the proof-of-work while the request is open, so the form
|
||||||
shows a "publishing" state for a few seconds.
|
shows a "publishing" state for a few seconds.
|
||||||
|
|
||||||
## Running a node (`cmd/node`)
|
## Running a node (`cmd/allmende`)
|
||||||
|
|
||||||
```
|
```
|
||||||
node init # create identity, show the 12-word phrase (once)
|
allmende init # create identity, show the 12-word phrase (once)
|
||||||
node run --region u1x [--bootstrap <addr>] # replicate a region, serve the API on 127.0.0.1:8080
|
allmende run --region u1x [--bootstrap <addr>] # replicate a region, serve the API on 127.0.0.1:8080
|
||||||
node recover # restore from the phrase; also yearly cert renewal
|
allmende recover # restore from the phrase; also yearly cert renewal
|
||||||
```
|
```
|
||||||
|
|
||||||
## Spam
|
## Spam
|
||||||
|
|||||||
Reference in New Issue
Block a user