Skip to content

cmd/start.go is ~1.8k lines: split StartCargoWall into phases #108

Description

@matthewdevenny

Tech debt noted while reviewing #95 (which added ~42 lines there for map sizing + starting the step tracker — localized and fail-soft, but on top of an already large file).

StartCargoWall carries the whole daemon bring-up in one function: config/policy load, logging, DNS proxy, iptables redirect, Docker DNS interception, BPF load and attach, firewall programming, existing-connection gating, sudo lockdown, readiness, and teardown defers. The ordering between those stages is genuinely load-bearing (maps must be fully programmed before TC attaches; existing connections are re-scanned just before attach; teardown must unwind in reverse), which is exactly why it deserves named stages rather than one long body.

Suggested direction — extract cohesive phases with explicit inputs/outputs, keeping the current order and defer semantics:

  • BPF load + attach (including the step-map sizing and cgroup/tracepoint attaches)
  • DNS proxy + redirect setup
  • Firewall programming + existing-connection gating
  • Lockdown + readiness + teardown registration

Behavior-preserving refactor; the value is that the attach-ordering invariants become visible in the structure instead of only in comments. Worth doing before the container work in #106 adds another attach path.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions