Add router image for allowlisted egress

This commit is contained in:
2026-10-23 22:29:01 +11:00
parent 20c9c9ff26
commit 4122e3592b
3 changed files with 27 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
FROM artifactapi.k8s.syd1.au.unkin.net/dockerhub/library/alpine:3.22
# hadolint ignore=DL3018
RUN apk add --no-cache dnsmasq nginx nginx-mod-stream socat
COPY start.sh /usr/local/bin/router-start
COPY forwarder /usr/local/bin/forwarder
# The launcher mounts the per-session config at /etc/router.
ENTRYPOINT ["/usr/local/bin/router-start"]
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
# Loopback forwarders in the sandbox netns. FORWARDS holds
# "bind:port:router:router_port" words.
set -eu
for fwd in $FORWARDS; do
# shellcheck disable=SC2046
set -- $(echo "$fwd" | tr : ' ')
socat "TCP-LISTEN:$2,bind=$1,fork,reuseaddr" "TCP:$3:$4" &
done
wait
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
# Start the per-session router from the launcher's config in /etc/router.
set -eu
resolver=$(awk '/^nameserver/ {print $2; exit}' /etc/resolv.conf)
sed "s/@RESOLVER@/$resolver/" /etc/router/nginx.conf >/tmp/nginx.conf
dnsmasq --conf-file=/etc/router/dnsmasq.conf
# ponytail: no supervisor; if dnsmasq dies the session loses DNS, restart the session.
exec nginx -c /tmp/nginx.conf -g 'daemon off;'