The hosts-file writing moved to the node-names fact; what stays is the suffix (configurable, MESH_INTERNAL_SUFFIX, defaulting to .internal which IANA reserved for exactly this), a node's internal name, and the rule for what a node may be called. Several things compose an internal name, and one of them writing the suffix differently would be a name nothing answers to. First attempt at this rewrote the file from memory and silently dropped the configurable suffix. Restored from the original instead — deleting most of a file is git surgery, not paraphrase. Claude-Session: https://claude.ai/code/session_01D6qtiYU3P9jk3pnAXyAFyx
54 lines
2.3 KiB
Go
54 lines
2.3 KiB
Go
package overlay
|
|
|
|
import (
|
|
"os"
|
|
"regexp"
|
|
"strings"
|
|
)
|
|
|
|
// Names are how one node reaches another by name rather than by address.
|
|
//
|
|
// novox/hq 08-connectivity: what the host receives is the resolver's configuration, as files,
|
|
// listing every peer's internal name and overlay address. Computed centrally for the same reason
|
|
// the peer graph is — it needs every node at once.
|
|
|
|
// SuffixVar lets a mesh choose what its internal names end in.
|
|
const SuffixVar = "MESH_INTERNAL_SUFFIX"
|
|
|
|
// DefaultSuffix is `.internal`, which IANA reserved for exactly this in 2024. A name under it can
|
|
// never collide with a public one, so an internal name that leaks into a public resolver fails
|
|
// rather than reaching a stranger's machine.
|
|
const DefaultSuffix = "internal"
|
|
|
|
// HostsPath is where the names go.
|
|
//
|
|
// This is not the `/etc/hosts` floor the design removes. That floor existed because a node had to
|
|
// reach the mesh's database before its own DNS worked — a fallback for a circularity, and the
|
|
// circularity is gone. This is the mechanism itself: the complete set of names in this mesh,
|
|
// generated whole and owned by the mesh (novox/hq ADR 0011), rather than a patch written
|
|
// underneath something else.
|
|
//
|
|
// A file rather than a resolver daemon, deliberately, for now: it works on every Linux, needs no
|
|
// package, and has no failure mode of its own. A daemon becomes necessary when names are wanted
|
|
// that are not one-per-node — service names, wildcards — and that is not yet true.
|
|
const HostsPath = "/etc/hosts"
|
|
|
|
// Suffix is what internal names end in.
|
|
func Suffix() string {
|
|
if v := strings.TrimSpace(os.Getenv(SuffixVar)); v != "" {
|
|
return strings.TrimPrefix(v, ".")
|
|
}
|
|
return DefaultSuffix
|
|
}
|
|
|
|
// nodeName is what a node may be called, so that it can also be a hostname.
|
|
var nodeName = regexp.MustCompile(`^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$`)
|
|
|
|
// InternalName is a node's name inside the mesh.
|
|
func InternalName(node string) string { return node + "." + Suffix() }
|
|
|
|
// **What remains of a larger file.** The rest wrote /etc/hosts — that is the `node-names` fact now
|
|
// (catalogue.FactsInto), computed where the graph lives instead of by a module that ran nothing.
|
|
// The naming stays here, because several things compose a node's internal name and one of them
|
|
// writing the suffix differently would be a name nothing answers to.
|