summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/meshbay-node/src/meshbay_node/daemon.py37
1 files changed, 35 insertions, 2 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/daemon.py b/packages/meshbay-node/src/meshbay_node/daemon.py
index 1fe68b1..848fc9f 100644
--- a/packages/meshbay-node/src/meshbay_node/daemon.py
+++ b/packages/meshbay-node/src/meshbay_node/daemon.py
@@ -619,9 +619,34 @@ def _daemon_api(cfg: Config, path: str, method: str = "GET",
def _resolve_group(cfg: Config, group: str | None) -> str:
- """The group argument, or the only configured one."""
+ """
+ The group argument as an id, or the only configured one.
+
+ Accepts a name as well, because node.toml already gives every group one and
+ nobody remembers a UUID. A name that matches nothing configured says so, and
+ lists what is — silently passing it through produced a 404 from the daemon
+ that read like the group did not exist on the hub.
+ """
if group:
- return group
+ by_id = [g for g in cfg.groups if g.id == group]
+ if by_id:
+ return by_id[0].id
+ by_name = [g for g in cfg.groups if g.name == group and g.id]
+ if len(by_name) == 1:
+ return by_name[0].id
+ if len(by_name) > 1:
+ print(f"several groups in node.toml are named {group!r} — use the id")
+ sys.exit(1)
+ # An id this node does not host is still worth passing on: the daemon
+ # gives the better error, naming the group it does host.
+ if "-" in group and len(group) == 36:
+ return group
+ print(f"no group named {group!r} in {DEFAULT_CONFIG_PATH}")
+ if cfg.groups:
+ print("configured groups:")
+ for g in cfg.groups:
+ print(f" {g.name or '(unnamed)':<24} {g.id or '(no id yet)'}")
+ sys.exit(1)
configured = [g.id for g in cfg.groups if g.id]
if len(configured) == 1:
return configured[0]
@@ -847,6 +872,14 @@ def main() -> None:
if args.subcommand != "pair":
print("usage: meshbay-node operator pair")
sys.exit(1)
+ if args.group:
+ # Silently ignoring it invited the reading that a code belongs to a
+ # group, and then that pairing had not worked because the group did
+ # not change.
+ print("operator pair takes no --group: pairing is node-wide.")
+ print("One paired browser can invite to, and delete files in, every")
+ print("group this node hosts.")
+ sys.exit(1)
cfg = load_config(args.config or DEFAULT_CONFIG_PATH)
out = _daemon_api(cfg, "/api/operator/pair", method="POST")