The mesh's one resolver, what every node asks, and a node's hosts file (hq ADR 0194, 0196, 0199)
- dnsmasq holds mesh-dns-resolver: provides wildcard-resolution mesh-wide, forwards every declared zone (zones fact), listens on the private address and loopback only, reads no hosts file and no operator's files, and no longer writes the container runtime's dns. - resolv-conf names the mesh's resolver by address, then 1.1.1.1, timeout 1, one attempt; it now holds the runtime's live-restore, which dnsmasq held and every node needs. - resolved-split-dns routes the suffix to the mesh's resolver by address, not 127.0.0.1. - hosts: new module holding node-hosts-file — the machine's own lines in its block of /etc/hosts, the operator's lines kept, changed by entries/add/remove through sudo -n.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
// The hosts file's tools: the node-hosts-file seat's three verbs (novox/hq ADR 0199) — the file's lines
|
||||
// with whose each is, add an operator's line, remove one. They change the machine's file and nothing
|
||||
// else; the controller holds none of it.
|
||||
|
||||
import { registerModuleTools, type ToolDefinition } from "@novox/mesh-sdk/tools";
|
||||
import { HostsFile } from "../client.js";
|
||||
|
||||
export function getSeatVerbs(hosts: HostsFile): ToolDefinition[] {
|
||||
return [
|
||||
{
|
||||
name: "entries",
|
||||
description:
|
||||
"Every line of this machine's /etc/hosts, each marked whose it is: the operator's, or the block of the module or tool that writes it.",
|
||||
input: {},
|
||||
run: async () => hosts.entries(),
|
||||
},
|
||||
{
|
||||
name: "add",
|
||||
description:
|
||||
"Add one address and its names to the operator's lines of this machine's /etc/hosts — a name for this machine's own programs, not the mesh's. Nothing changes when they are already there.",
|
||||
input: {
|
||||
address: { type: "string", description: "the IPv4 or IPv6 address" },
|
||||
names: { type: "string", description: "the names for it, separated by spaces" },
|
||||
},
|
||||
run: async (args) =>
|
||||
hosts.add(String(args.address ?? ""), String(args.names ?? "").split(/[\s,]+/).filter(Boolean)),
|
||||
},
|
||||
{
|
||||
name: "remove",
|
||||
description:
|
||||
"Remove one name, or every line of one address, from the operator's lines of this machine's /etc/hosts. A line a module writes is refused, naming the module.",
|
||||
input: { name: { type: "string", description: "a host name, or an address to remove every line of" } },
|
||||
run: async (args) => hosts.remove(String(args.name ?? "")),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
const hosts = HostsFile.onThisMachine();
|
||||
// The seat's verbs under the seat's name: the runtime serves them as <node>/node-hosts-file.<verb>.
|
||||
registerModuleTools("node-hosts-file", () => getSeatVerbs(hosts));
|
||||
Reference in New Issue
Block a user