/etc/hosts is the file of the node-hosts-file seat's holder; the controller writes into no file another seat's holder owns, and asks that holder if it ever needs a line there. The private network's module stops asking for the node-names fact; every machine already asks the mesh's one resolver for these names, and the host gives the region back at the next push.
40 lines
1.5 KiB
Go
40 lines
1.5 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"
|
|
|
|
// 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, which the controller no longer
|
|
// writes at all (novox/hq ADR 0199): the mesh's resolver answers these names. 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.
|