Skip to content

fix(devcontainer): laat verkeer naar dc-net-siblings door de egress-f…#56

Open
insuT0ver wants to merge 1 commit into
mainfrom
fix/socket-proxy-compose-networking
Open

fix(devcontainer): laat verkeer naar dc-net-siblings door de egress-f…#56
insuT0ver wants to merge 1 commit into
mainfrom
fix/socket-proxy-compose-networking

Conversation

@insuT0ver

@insuT0ver insuT0ver commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

…irewall

docker compose up in een devcontainer zette services wél op dc-net- (DNS + IP klopten), maar de OUTPUT-firewall van de devcontainer dropte al het TCP behalve naar de huddle-proxy. Daardoor was bv. een compose-postgres op :5432 onbereikbaar (connectie hing, want DROP i.p.v. REJECT).

Twee aanpassingen op de drie plekken waar de iptables-regels worden opgezet (refreshContainerIptables, JB-flow, VS Code-flow):

  1. ACCEPT voor de eigen devcontainer-netwerk-subnetten vóór de DROP, zodat siblings op dc-net bereikbaar worden. Subnetten worden uit de interfaces afgeleid (ip -o addr, scope global), dus geen hardcoded CIDR.

  2. RETURN in de nat OUTPUT-chain voor die subnetten vóór de poort-80 DNAT, zodat een sibling die op :80 luistert de sibling zelf bereikt i.p.v. naar de huddle-proxy omgeleid te worden.

Summary

Related issue

Fixes #

Type of change

  • Bug fix (fix)
  • New feature (feat)
  • Documentation (docs)
  • Refactor / maintenance (refactor / chore)
  • Other:

Checklist

  • My branch is up to date with main and focused on a single change.
  • The project builds and type-checks locally.
  • Tests pass (npm --prefix gateway test) and I added/updated tests where relevant.
  • I ran Prettier and did not reformat unrelated code.
  • Commit messages follow Conventional Commits.
  • I did not introduce logging of secrets, tokens, or credentials.
  • Documentation is updated where needed (README / relevant docs).

Notes for reviewers

…irewall

`docker compose up` in een devcontainer zette services wél op dc-net-<naam>
(DNS + IP klopten), maar de OUTPUT-firewall van de devcontainer dropte al het
TCP behalve naar de huddle-proxy. Daardoor was bv. een compose-postgres op
:5432 onbereikbaar (connectie hing, want DROP i.p.v. REJECT).

Twee aanpassingen op de drie plekken waar de iptables-regels worden opgezet
(refreshContainerIptables, JB-flow, VS Code-flow):

1. ACCEPT voor de eigen devcontainer-netwerk-subnetten vóór de DROP, zodat
   siblings op dc-net bereikbaar worden. Subnetten worden uit de interfaces
   afgeleid (ip -o addr, scope global), dus geen hardcoded CIDR.

2. RETURN in de nat OUTPUT-chain voor die subnetten vóór de poort-80 DNAT,
   zodat een sibling die op :80 luistert de sibling zelf bereikt i.p.v. naar
   de huddle-proxy omgeleid te worden.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@insuT0ver insuT0ver requested a review from a team July 10, 2026 09:03
Comment thread gateway/src/docker.ts
| awk '/DNAT.*dpt:80/{print $1}' | sort -rn \
| while read LINE; do iptables -t nat -D OUTPUT "$LINE" 2>/dev/null || true; done
iptables -t nat -A OUTPUT -p tcp --dport 80 ! -d "$HUDDLE_IP" -j DNAT --to-destination "$HUDDLE_IP:80" 2>/dev/null || true
for CIDR in $(ip -o -f inet addr show scope global 2>/dev/null | awk '{print $4}'); do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Near-identical shell loop inserting nat-RETURN rules is duplicated across multiple config scripts; consider centralizing the iptables-subnet exclusion logic into a single helper to avoid repeated maintenance.

Details

✨ AI Reasoning
​The change adds a shell loop that enumerates host IPv4 subnets and inserts an iptables -t nat RETURN rule for port 80. Equivalent code is also added in the JB-flow and VS Code-flow setup scripts. This is a repeated, non-trivial business operation (altering container iptables/nat behavior) duplicated in multiple places; consolidating would reduce maintenance burden and risk of inconsistent updates.

🔧 How do I fix it?
Delete extra code. Extract repeated code sequences into reusable functions or methods. Use loops or data structures to eliminate repetitive patterns.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant