52 lines
2.7 KiB
Go
52 lines
2.7 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/novox/mesh-controller/internal/conditions"
|
|
"github.com/novox/mesh-controller/internal/inventory"
|
|
"github.com/novox/mesh-controller/internal/link"
|
|
)
|
|
|
|
// A machine says how its network is (novox/hq ADR 0241, "how it is checked"): the resolver file rewritten
|
|
// by another program is one finding, naming the writer, with the names it costs said in it; what is the
|
|
// machine's own is `machine.<m>.network`; what points at another machine that is down is said once, there;
|
|
// one machine alone failing toward a healthy one is its own; the control node, the hub and the bus are
|
|
// urgent; an engine that says nothing of its network raises nothing; and the gate waits on what is shown to
|
|
// be another's.
|
|
|
|
func netFacts(healths map[string]*inventory.NetworkHealth) networkFacts {
|
|
f := networkFacts{healths: map[string]inventory.NodeHealth{}, hub: "anchor", control: "anchor",
|
|
byAddress: map[string]string{"10.77.0.1": "anchor", "10.77.0.2": "laptop", "10.77.0.3": "spare"},
|
|
silent: map[string]bool{}}
|
|
for m, n := range healths {
|
|
f.healths[m] = inventory.NodeHealth{Node: m, Network: n}
|
|
}
|
|
return f
|
|
}
|
|
|
|
var (
|
|
rewrittenByVPN = inventory.NetworkPart{Part: link.PartResolvConf, Reason: "the resolver file was rewritten by another program",
|
|
Said: "/etc/resolv.conf lists 172.16.5.5 where 10.77.0.1 is declared", Writer: "FortiClient", Owner: "networkmanager"}
|
|
namesThroughVPN = inventory.NetworkPart{Part: link.PartNames, Reason: "mesh names do not resolve",
|
|
Said: "172.16.5.5 — anchor.internal (IPv4): says no such name", Toward: []string{"172.16.5.5"}}
|
|
tunnelDown = inventory.NetworkPart{Part: link.PartTunnel, Reason: "the tunnel to the hub has not handshaken for over five minutes",
|
|
Said: "mesh0's newest handshake with the hub was 9m0s ago", Toward: []string{link.TowardHub}}
|
|
noRoute = inventory.NetworkPart{Part: link.PartRoute, Reason: "the machine has no default route", Said: "no default route"}
|
|
)
|
|
|
|
func keysOf(obs []conditions.Observation) []string {
|
|
var keys []string
|
|
for _, o := range obs {
|
|
keys = append(keys, o.Key())
|
|
}
|
|
return keys
|
|
}
|
|
|
|
// Through the store and the keeper: the statement kept, the rewrite raised from it, cleared when the file
|
|
// is written back, and node show saying it.
|
|
|
|
// TestTheDrillsStatementsRaiseAndClearTheRewrite replays the drill of ADR 0241 (mesh-host
|
|
// internal/network TestDrill…): what a node-engine said in a throwaway container while its resolver file
|
|
// was declared, rewritten as a VPN client rewrites it, and written back — recorded, with the mesh's names
|
|
// and addresses replaced by this test mesh's. Healthy raises nothing; the rewrite, on its second look, is
|
|
// raised as one finding naming the writer; written back, it clears.
|