Files
mesh-networking/modules/mesh-wireguard/go/overlay/names.go
T
jschoubben be74c94151 mesh-wireguard: the module that holds the-private-network, with its manifest and peer generator its own package (ADR 0636 §6; issue 1966)
The names and the manifest come from mesh-sdk's overlay, the peer graph, the generator and the declaration from the node-engine's internal/overlay; the value's layout is the seat's contract in mesh-connectivity-contracts.

Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
2026-11-05 14:07:21 +01:00

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.