#!/bin/sh
# Entrypoint wrapper for a simulator on `internet-external` — a host out on
# the simulated public internet.
#
# Such a host must reach the customer's public prefix (203.0.113.0/24) through
# the ISP edge, fw-ext. Docker's default bridge gateway has no path across
# networks, so without this route a reply to the customer's WAN address is
# simply dropped and the connection hangs.
#
# This used to be invisible: fw-ext MASQUERADEd the customer to its own
# 100.64.0.1, which is on-link here, so replies never needed routing at all.
# Once fw-ext stopped re-NATing a subscriber that already holds a public
# address (the ISP routes it; it does not NAT it), the omission surfaced —
# every sim that had this route already kept working, and the four that did
# not started timing out. celilo-website-sim, isitup, pebble, namecheap-dns
# and the DNS hierarchy have carried it all along; this is the same two lines.
#
# fw-ext is per-test, so the route is unreachable while shared infra runs
# alone. That is harmless — nothing dials the customer before a test brings
# fw-ext up — hence the tolerant `|| true`.
ip route del default 2>/dev/null || true
ip route add default via 100.64.0.1 2>/dev/null || true

exec "$@"
