Skip to content

Milestone 3a: Service discovery (host + Incus)#28

Merged
vxfemboy merged 8 commits into
mainfrom
milestone-3a-discovery
Jun 25, 2026
Merged

Milestone 3a: Service discovery (host + Incus)#28
vxfemboy merged 8 commits into
mainfrom
milestone-3a-discovery

Conversation

@vxfemboy

@vxfemboy vxfemboy commented Jun 25, 2026

Copy link
Copy Markdown
Member

Milestone 3a — Discovery (host sockets + Incus)

Automatically discovers services the operator runs and reconciles them into the effective firewall policy, so ports open (and close) without editing the config file. First slice of epic #3 (shaping → M3b, flux/DNS → M3c).

New blackwall-discovery crate

  • reconcile(base, &[DiscoveredService]) -> Policy — merges discovered services into the effective policy by appending an allow rule to the owning tenant (or a synthetic discovered tenant for unowned-but-in-prefix addresses); skips out-of-prefix and duplicate services; the result always stays resolve()-valid.
  • Host-socket scanner — a pure, endianness-correct /proc/net/{tcp,tcp6,udp,udp6} parser (listening sockets only) + a thin reader.
  • Incus parsing — instance state (name, addresses, the user.blackwall.ports opt-in key) and lifecycle events (started/stopped/shutdown/updated), all pure + fixture-tested.
  • IncusClient trait + a tested mock + a thin UnixIncusClient speaking HTTP/1.1 (with chunked transfer-decoding) over the Incus unix socket.

blackwalld run wiring

  • Builds an initial discovered set (host scan behind --discover-host; Incus via --incus-socket, default /var/lib/incus/unix.socket), applies the effective policy (apply_policy + nft::apply), and a detached Incus event task that rebuilds the full set and re-applies on each lifecycle event — so a stopped instance's ports disappear. The Incus task is detached so an Incus disconnect can never take down the deception engine; Incus is optional (warn + continue).

Quality

  • 115 tests; coverage 97.30% (the two root/daemon-bound I/O adapters and the daemon glue are excluded via the documented gate filter); clippy --deny warnings + rustfmt clean.
  • Per-task spec+quality reviews and a whole-branch review (verdict: ready to merge; core firewall-control invariants verified). Its fixes (skip-not-abort on a malformed event line, unused-dep removal, tenant-wide-allow doc) are in this branch.

Tracked follow-ups

Part of #3.

Closes #29.

vxfemboy added 8 commits June 25, 2026 07:46
Decode HTTP/1.1 chunked transfer-encoding for both the one-shot
instances response and the long-lived event stream. Preserve IO error
kind by using the #[from] impl directly instead of wrapping errors.
Expand blackwall-discovery::host unit tests to cover IPv4/IPv6
parse paths, UDP UNCONN filtering, short-line skipping, and all
error branches (bad port, bad local address format, bad hex,
bad IPv6 length/word). host.rs coverage rises from 67% to 100%.

Document M3a service-discovery additions in CHANGELOG.md:
host-socket scanner, Incus instance/event/client modules, and
policy reconciler auto-opening Incus-opted ports via blackwalld run.
Remove unused serde direct dep from blackwall-discovery. Parse errors
from the Incus event stream now emit a warning and continue rather than
terminating discovery; I/O errors still break the loop. Document that
AllowRule is not address-scoped so audit-log readers understand
tenant-wide port effects.
@vxfemboy vxfemboy moved this to In review in blackwall Jun 25, 2026
@vxfemboy vxfemboy merged commit 5709d4f into main Jun 25, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In review to Done in blackwall Jun 25, 2026
@vxfemboy vxfemboy deleted the milestone-3a-discovery branch June 25, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[A·M3a] Discovery — host sockets + Incus

1 participant