diff --git a/spindle/hydrant.go b/spindle/hydrant.go index d669c16cf..027aa454e 100644 --- a/spindle/hydrant.go +++ b/spindle/hydrant.go @@ -267,7 +267,7 @@ func (b *backfill) cursorPath() string { } func (b *backfill) settings() map[string]string { - return map[string]string{ + settings := map[string]string{ "HYDRANT_DATABASE_PATH": filepath.Join(b.dir, "db"), "HYDRANT_API_BIND": "unix:" + b.socketPath(), "HYDRANT_PLC_URL": b.s.cfg.Server.PlcUrl, @@ -281,6 +281,11 @@ func (b *backfill) settings() map[string]string { "HYDRANT_IDENTITY_CACHE_SIZE": "50000", "RUST_LOG": "warn", } + // dev hosts resolve to loopback, so hydrant needs the private network flag + if b.s.cfg.Server.Dev { + settings["HYDRANT_ALLOW_PRIVATE_NETWORKS"] = "true" + } + return settings } // round starts hydrant, hands it the queued owners and due retries, and diff --git a/spindle/hydrant_test.go b/spindle/hydrant_test.go index 34865fffb..73f3b02b7 100644 --- a/spindle/hydrant_test.go +++ b/spindle/hydrant_test.go @@ -871,6 +871,18 @@ func TestBackfillRequeuesOwnersWhenHydrantFailsToStart(t *testing.T) { } } +func TestBackfillSettingsAllowPrivateNetworksOnlyInDev(t *testing.T) { + for _, dev := range []bool{false, true} { + cfg := &config.Config{} + cfg.Server.Dev = dev + b := newBackfill(&Spindle{cfg: cfg}, slog.Default(), shortTempDir(t)) + got, ok := b.settings()["HYDRANT_ALLOW_PRIVATE_NETWORKS"] + if ok != dev || (dev && got != "true") { + t.Errorf("dev=%v: HYDRANT_ALLOW_PRIVATE_NETWORKS = %q (set: %v)", dev, got, ok) + } + } +} + // real hydrant, offline. nothing resolves so nothing backfills, but it has to // start, answer, shut down and let go of its db for the next round func TestBackfillRunsEmbeddedHydrant(t *testing.T) {