From f11be5d529e590797672513264ce0a478ed13922 Mon Sep 17 00:00:00 2001 From: jochen Date: Sat, 21 Nov 2026 21:16:52 +0100 Subject: [PATCH] Answer the node's links in the node-engine seat's converged MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The holder of node-packet-filter says when an allowance opens an outward link and reads no shape of the loaded table to know one, so converged answers the tunnel's interface and the outward links from the one classification the filter render uses; links it cannot read refuse it. Builds: design 33 control-verbs §10, §14; design 08 control-verbs §2; design 47 H H-A-325 --- cmd/mesh-host/main.go | 4 +++- cmd/mesh-host/ownname_test.go | 22 ++++++++++++++++++---- cmd/mesh-host/seatlist.go | 14 +++++++++++--- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/cmd/mesh-host/main.go b/cmd/mesh-host/main.go index b04587d4..0651e1e5 100644 --- a/cmd/mesh-host/main.go +++ b/cmd/mesh-host/main.go @@ -1045,7 +1045,9 @@ func runLink(ctx context.Context, opts options) error { defer cancel() return processbuilds.Reader{Node: mine.Node, Run: processbuilds.Runner(opts.run())}.Read(ctx, d, module), nil } - queue.Acts.Converged = func() (any, error) { return convergedOf(opts.state) } + queue.Acts.Converged = func() (any, error) { + return convergedOf(opts.state, func() ([]string, error) { return outward.Links("", "") }) + } queue.Acts.ComposeCandidate = composeCandidateFrom(mine.Node, &shadowNow) setRunsHere(runsFromAgent(current)) factsOfNow := func(ctx context.Context, ag *agent.Agent) { diff --git a/cmd/mesh-host/ownname_test.go b/cmd/mesh-host/ownname_test.go index bbbfd5a0..7f64d064 100644 --- a/cmd/mesh-host/ownname_test.go +++ b/cmd/mesh-host/ownname_test.go @@ -2,14 +2,17 @@ package main import ( "context" + "errors" "os" "path/filepath" + "reflect" "strings" "testing" "time" "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" condseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" + "git.novox.be/novox/mesh-networking/modules/mesh-wireguard/go/overlay" "github.com/novox/mesh-host/internal/link" "github.com/novox/mesh-host/internal/store" ) @@ -59,14 +62,17 @@ func TestTheEnginesOwnNameIsReadFromItsAppliedRecordOrItsFirstComposing(t *testi // Design 33 control-verbs §10, §14: the seat's verb converged answers the node's convergence state as the record keeps // it, adopted with its found firewall's kind or converged, since its mode last changed; a record with no mode is refused. + // H-A-325: it answers too the tunnel and the outward links as the engine classifies them for its render; links it cannot + // read refuse it. t.Run("converged answers the record's convergence state", func(t *testing.T) { + links := func() ([]string, error) { return []string{"eth1"}, nil } path := filepath.Join(t.TempDir(), "state.json") found := time.Date(2026, 10, 2, 9, 0, 0, 0, time.UTC) st := store.State{Firewall: &store.FoundFirewall{Kind: "ufw", FoundAt: found}} if err := store.Save(path, st); err != nil { t.Fatal(err) } - if got, err := convergedOf(path); err == nil { + if got, err := convergedOf(path, links); err == nil { t.Errorf("a record with no mode answers %+v, want refused", got) } st.SetMode(store.ModeAdopted, found) @@ -74,18 +80,26 @@ func TestTheEnginesOwnNameIsReadFromItsAppliedRecordOrItsFirstComposing(t *testi if err := store.Save(path, st); err != nil { t.Fatal(err) } - acts := &link.HandActs{Converged: func() (any, error) { return convergedOf(path) }} + acts := &link.HandActs{Converged: func() (any, error) { return convergedOf(path, links) }} if got, err := acts.Call(link.EngineCall{Verb: link.ActConverged}); err != nil || - got != (nodeengine.ConvergedAnswer{State: "adopted", Since: "2026-10-02T09:00:00Z", Found: "ufw"}) { + !reflect.DeepEqual(got, nodeengine.ConvergedAnswer{State: "adopted", Since: "2026-10-02T09:00:00Z", Found: "ufw", + Tunnel: overlay.Interface, Outward: []string{"eth1"}}) { t.Errorf("an adopted node answers %+v, %v; want adopted since its adoption, found ufw", got, err) } st.SetMode(store.ModeConverged, found.Add(48*time.Hour)) if err := store.Save(path, st); err != nil { t.Fatal(err) } - if got, err := convergedOf(path); err != nil || got != (nodeengine.ConvergedAnswer{State: "converged", Since: "2026-10-04T09:00:00Z"}) { + if got, err := convergedOf(path, links); err != nil || !reflect.DeepEqual(got, nodeengine.ConvergedAnswer{State: "converged", + Since: "2026-10-04T09:00:00Z", Tunnel: overlay.Interface, Outward: []string{"eth1"}}) { t.Errorf("a converged node answers %+v, %v; want converged since it converged, no found firewall", got, err) } + if got, err := convergedOf(path, func() ([]string, error) { return nil, nil }); err != nil || got.Outward == nil { + t.Errorf("a node with no outward link answers %+v, %v; want an empty list, never null", got, err) + } + if got, err := convergedOf(path, func() ([]string, error) { return nil, errors.New("no /proc") }); err == nil { + t.Errorf("links that cannot be read answer %+v, want refused", got) + } }) } diff --git a/cmd/mesh-host/seatlist.go b/cmd/mesh-host/seatlist.go index 136aa5c6..761ffb30 100644 --- a/cmd/mesh-host/seatlist.go +++ b/cmd/mesh-host/seatlist.go @@ -15,6 +15,7 @@ import ( "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" condseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" + "git.novox.be/novox/mesh-networking/modules/mesh-wireguard/go/overlay" "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/seatdef" "git.novox.be/novox/mesh-sdk/go/seatlist" @@ -340,8 +341,11 @@ func entryAsks() int { // convergedOf is the node's convergence state as this engine keeps it in its record at path (ADR 0168): the answer of the // seat node-engine's verb converged (design 33 control-verbs §10). A record that says no mode yet is refused, so its asker -// never takes it for converged. -func convergedOf(path string) (nodeengine.ConvergedAnswer, error) { +// never takes it for converged. It answers too the node's links as this engine classifies them for its filter render +// (design 08 control-verbs §2, H-A-325): the private network's tunnel interface and the outward links that links reads, the +// same reading the engine reports for the render (outward.Links); a machine that cannot read them is refused, never +// answered with none. +func convergedOf(path string, links func() ([]string, error)) (nodeengine.ConvergedAnswer, error) { st, err := store.Load(path) if err != nil { return nodeengine.ConvergedAnswer{}, err @@ -349,7 +353,11 @@ func convergedOf(path string) (nodeengine.ConvergedAnswer, error) { if st.Mode != store.ModeAdopted && st.Mode != store.ModeConverged { return nodeengine.ConvergedAnswer{}, errors.New("this node's record says no mode yet: no declaration has said it adopted or converged") } - out := nodeengine.ConvergedAnswer{State: st.Mode} + outward, err := links() + if err != nil { + return nodeengine.ConvergedAnswer{}, fmt.Errorf("could not read which links face outside: %w", err) + } + out := nodeengine.ConvergedAnswer{State: st.Mode, Tunnel: overlay.Interface, Outward: append([]string{}, outward...)} if st.ModeSince != nil { out.Since = st.ModeSince.UTC().Format(time.RFC3339) }