Simplify configuration: connection defaults + optional queue numbers #62

Merged
danny merged 2 commits from issue20_simplify_config into main 2026-07-05 16:49:13 +01:00
danny commented 2026-07-05 16:39:48 +01:00 (Migrated from gitlab.keyop.co.uk)

Closes #20.

Summary

  • Adds an optional top-level defaults: section to --config YAML files: overall defaults for jump_user/jump_host/forwarded_ports, plus CIDR-scoped overrides via defaults.by_network. An explicit value on a connection always wins over any default.
  • Most-specific-CIDR-wins: when a connection's network matches more than one by_network entry, the entry with the longest/most specific prefix wins, not whichever is listed first (a tie between equally specific matches falls back to list order). Documented explicitly in README.md, docs/README.md, docs/config.example.yaml, and CLAUDE.md.
  • queue_number is now optional: if omitted, a stable number is deterministically auto-assigned from a hash of the connection's name (requires name to be set in that case). This is derived from name specifically so a connection's number stays stable across restarts even if other connections are added/removed/reordered elsewhere in the file - important because the existing crash-recovery iptables cleanup is keyed only by queue number, so an unstable number could orphan stale rules after a crash.
  • internal/config remains at 100% test coverage; new tests cover defaults merging (overall + by_network + explicit-wins + most-specific-CIDR-wins + tie-break), the new jump_user/jump_host validation errors, and queue number auto-assignment (range, determinism, collision-probing, missing-name error).

Not included

  • config.production.yaml (untracked, real prod config) is not touched by this MR - it isn't under version control. Migrating it to use defaults/by_network/optional queue_number is a natural follow-up once this lands.
  • Version tag v1.0.1 will be pushed separately after this MR is reviewed and merged, same as v1.0.0 was for the previous release.

Test plan

  • go build ./...
  • make lint (golangci-lint + yamllint)
  • make test (go test -race -cover ./...)
  • Manually loaded docs/config.example.yaml via config.LoadFromFile and confirmed defaults/CIDR-scoping/queue-number auto-assignment all resolve as documented
Closes #20. ## Summary - Adds an optional top-level `defaults:` section to `--config` YAML files: overall defaults for `jump_user`/`jump_host`/`forwarded_ports`, plus CIDR-scoped overrides via `defaults.by_network`. An explicit value on a connection always wins over any default. - **Most-specific-CIDR-wins**: when a connection's `network` matches more than one `by_network` entry, the entry with the longest/most specific prefix wins, not whichever is listed first (a tie between equally specific matches falls back to list order). Documented explicitly in `README.md`, `docs/README.md`, `docs/config.example.yaml`, and `CLAUDE.md`. - `queue_number` is now optional: if omitted, a stable number is deterministically auto-assigned from a hash of the connection's `name` (requires `name` to be set in that case). This is derived from `name` specifically so a connection's number stays stable across restarts even if other connections are added/removed/reordered elsewhere in the file - important because the existing crash-recovery iptables cleanup is keyed only by queue number, so an unstable number could orphan stale rules after a crash. - `internal/config` remains at 100% test coverage; new tests cover defaults merging (overall + by_network + explicit-wins + most-specific-CIDR-wins + tie-break), the new `jump_user`/`jump_host` validation errors, and queue number auto-assignment (range, determinism, collision-probing, missing-name error). ## Not included - `config.production.yaml` (untracked, real prod config) is not touched by this MR - it isn't under version control. Migrating it to use `defaults`/`by_network`/optional `queue_number` is a natural follow-up once this lands. - Version tag `v1.0.1` will be pushed separately after this MR is reviewed and merged, same as `v1.0.0` was for the previous release. ## Test plan - [x] `go build ./...` - [x] `make lint` (golangci-lint + yamllint) - [x] `make test` (`go test -race -cover ./...`) - [x] Manually loaded `docs/config.example.yaml` via `config.LoadFromFile` and confirmed defaults/CIDR-scoping/queue-number auto-assignment all resolve as documented
danny (Migrated from gitlab.keyop.co.uk) approved these changes 2026-07-05 16:39:48 +01:00
danny commented 2026-07-05 16:41:16 +01:00 (Migrated from gitlab.keyop.co.uk)

added 1 commit

  • 4ce5fcfc - Add latest Claude conversation export

Compare with previous version

added 1 commit <ul><li>4ce5fcfc - Add latest Claude conversation export</li></ul> [Compare with previous version](/keyop/go/nfq_forwarder/-/merge_requests/21/diffs?diff_id=270&start_sha=54b7ce5cdf2d0b364536c9d57c851ab263d4ec9e)
danny commented 2026-07-05 16:48:47 +01:00 (Migrated from gitlab.keyop.co.uk)

requested review from @danny

requested review from @danny
danny commented 2026-07-05 16:48:49 +01:00 (Migrated from gitlab.keyop.co.uk)

assigned to @danny

assigned to @danny
danny commented 2026-07-05 16:48:56 +01:00 (Migrated from gitlab.keyop.co.uk)

LGTM.

LGTM.
danny commented 2026-07-05 16:48:56 +01:00 (Migrated from gitlab.keyop.co.uk)

approved this merge request

approved this merge request
danny commented 2026-07-05 16:49:13 +01:00 (Migrated from gitlab.keyop.co.uk)

mentioned in commit 709e697017

mentioned in commit 709e697017c58bd464c92cdd2c015906164512f0
danny (Migrated from gitlab.keyop.co.uk) merged commit 709e697017 into main 2026-07-05 16:49:13 +01:00
danny commented 2026-07-05 17:02:15 +01:00 (Migrated from gitlab.keyop.co.uk)

mentioned in issue #20

mentioned in issue #20
danny commented 2026-07-06 07:42:17 +01:00 (Migrated from gitlab.keyop.co.uk)

mentioned in commit 4005455d53

mentioned in commit 4005455d53eead3015ef05d1d0cb6e08653bb5c3
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
keyop-go/nfq_forwarder!62
No description provided.