//go:build testbuild package egress import ( "net/netip" "os" "strings" ) // A test build's relay may carry an allowed host to a fake provider on // a loopback address (a real Pi against a fake TensorX), named in // EQUIPO_TEST_EGRESS_UPSTREAM as host=127.0.0.1:port pairs separated by // commas. Only hosts the policy already allows reach here, and only a // loopback address is taken. A release build never passes -tags // testbuild, so has no such route. func init() { upstreamOverride = func(host string) (string, bool) { for _, pair := range strings.Split(os.Getenv("EQUIPO_TEST_EGRESS_UPSTREAM"), ",") { name, to, ok := strings.Cut(pair, "=") if !ok || name != host { continue } addr, err := netip.ParseAddrPort(to) if err == nil && addr.Addr().IsLoopback() { return to, true } } return "", false } }