gw-01 — Execution

Prerequisites

  • Go ≥ 1.25 (stdlib only; no modules to download — works offline).
  • Optional for the hands-on lab: wrk/wrk2, ss, nstat/netstat, python3 (for a throwaway origin), nc.

One-shot: prove the lab works

cd gw-01-l4-data-plane
bash scripts/verify.sh        # go vet + go build + go test -race

A green run ends with:

=== gw-01 OK ===

Per-language workflow (Go)

cd gw-01-l4-data-plane/src/go
go test -race -count=1 ./...      # 6 tests in package l4
go build -o /tmp/l4proxy ./cmd/l4proxy

Run the proxy

# origin:
python3 -m http.server 9000 &
# proxy (with per-second churn stats):
/tmp/l4proxy -listen :8080 -origin 127.0.0.1:9000 -stats 1s

CLI flags

flagdefaultmeaning
-listen:8080bind address
-origin127.0.0.1:9000upstream host:port
-proxy-headerfalseemit PROXY-protocol v1 to the origin
-drain25sgraceful-drain timeout on SIGINT/SIGTERM
-stats0if >0, print connection/churn stats each interval

Try it

# forward a line through the proxy:
printf 'GET / HTTP/1.0\r\n\r\n' | nc 127.0.0.1 8080 | head

# load with vs without keep-alive (watch accepted/s in the proxy log):
wrk -t4 -c100 -d10s http://127.0.0.1:8080/
wrk -t4 -c100 -d10s -H 'Connection: close' http://127.0.0.1:8080/

# graceful drain: start a slow connection, then Ctrl-C the proxy and
# watch it wait for in-flight before exiting.

See GUIDE.md §5 for the full hands-on lab and the kernel counters to read.