Choose even the first region in the browser; update Docker and Nix
A node now starts without any region (it only helps others connect, and prints a hint). The owner's sign-in link leads straight to the Regions page when none is followed, visitors get a notice instead of an empty search, and status always lists regions as an array. The Docker image no longer pins Bonn, the NixOS module no longer requires regions, and the VM test now starts without any, chooses the first region over the API and checks it survives a restart. README and the init hint follow. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
+7
-11
@@ -54,9 +54,12 @@ in
|
||||
default = [ ];
|
||||
example = [ "u1j" ];
|
||||
description = ''
|
||||
Regions to replicate: 3-character geohashes, each about 150 km wide.
|
||||
`u1j` is Bonn, `u1h` Cologne, `u1x` Hamburg. May be empty only for a
|
||||
bootstrap node ({option}`public`).
|
||||
Regions to start with: 3-character geohashes, each about 100 to 150 km
|
||||
wide. `u1j` is Bonn, `u1h` Cologne, `u1x` Hamburg. Leave it empty and
|
||||
the owner chooses by place name in the browser instead ("My listings"
|
||||
> "Regions"); that choice is kept in `regions.json` in
|
||||
{option}`dataDir` and wins over this list from then on (delete the file
|
||||
to go back to it).
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -108,7 +111,7 @@ in
|
||||
dataDir = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
default = "/var/lib/allmende";
|
||||
description = "Where keys, the admin token and the database live.";
|
||||
description = "Where keys, the admin token, the chosen regions and the database live.";
|
||||
};
|
||||
|
||||
extraArgs = lib.mkOption {
|
||||
@@ -120,13 +123,6 @@ in
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = cfg.regions != [ ] || cfg.public;
|
||||
message = "services.allmende.regions needs at least one region, for example [ \"u1j\" ] (only a public bootstrap node may have none).";
|
||||
}
|
||||
];
|
||||
|
||||
users.users.allmende = {
|
||||
isSystemUser = true;
|
||||
group = "allmende";
|
||||
|
||||
+15
-2
@@ -7,7 +7,7 @@ pkgs.testers.runNixOSTest {
|
||||
imports = [ module ];
|
||||
services.allmende = {
|
||||
enable = true;
|
||||
regions = [ "u1j" ];
|
||||
# No regions: the owner chooses the first one in the browser (see below).
|
||||
openFirewall = true;
|
||||
};
|
||||
};
|
||||
@@ -33,8 +33,21 @@ pkgs.testers.runNixOSTest {
|
||||
machine.wait_for_open_port(8080)
|
||||
machine.wait_for_open_port(4001)
|
||||
status = machine.succeed("curl -sf http://127.0.0.1:8080/api/v1/status")
|
||||
assert '"regions":["u1j"]' in status, status
|
||||
assert '"regions":[]' in status, status
|
||||
machine.succeed("curl -sf http://127.0.0.1:8080/ | grep -qi '<html'")
|
||||
# (no grep -q here: it would close the pipe early and make curl fail with exit 23)
|
||||
machine.succeed("curl -sf http://127.0.0.1:8080/places.tsv | grep -c '^Bonn'")
|
||||
|
||||
with subtest("the owner chooses the first region, and it survives a restart"):
|
||||
auth = "-H \"Authorization: Bearer $(cat /var/lib/allmende/admin.token)\""
|
||||
machine.succeed("test $(curl -s -o /dev/null -w '%{http_code}' -X PUT http://127.0.0.1:8080/api/v1/regions -d '{\"regions\":[\"u1j\"]}') = 401")
|
||||
machine.succeed(f"curl -sf {auth} -X PUT http://127.0.0.1:8080/api/v1/regions -d '{{\"regions\":[\"u1j\"]}}'")
|
||||
status = machine.succeed("curl -sf http://127.0.0.1:8080/api/v1/status")
|
||||
assert '"regions":["u1j"]' in status, status
|
||||
machine.succeed("systemctl restart allmende")
|
||||
machine.wait_for_open_port(8080)
|
||||
status = machine.succeed("curl -sf http://127.0.0.1:8080/api/v1/status")
|
||||
assert '"regions":["u1j"]' in status, status
|
||||
|
||||
with subtest("the owner API needs the admin token"):
|
||||
machine.succeed("test $(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:8080/api/v1/mine) = 401")
|
||||
|
||||
Reference in New Issue
Block a user