Clean up config for dns servers

This commit is contained in:
Owen
2026-10-28 15:51:08 -04:00
parent 3dd46e48ec
commit 8ce036b413
5 changed files with 63 additions and 0 deletions
+9
View File
@@ -4,6 +4,7 @@ import { configFilePath1, configFilePath2 } from "./consts";
import { z } from "zod";
import stoi from "./stoi";
import { getEnvOrYaml, readEnvOrFile } from "./getEnvOrYaml";
import { getRunMode } from "./runMode";
// type-only: offlineThresholds imports config, which imports this file
import type { OfflineThresholds } from "@server/lib/offlineThresholds";
@@ -325,6 +326,10 @@ export const configSchema = z
base_endpoint: z
.string()
.optional()
// The standalone DNS server never creates exit nodes
.transform((url) =>
url === undefined && getRunMode() === "dns" ? "" : url
)
.pipe(z.string())
.transform((url) => url.toLowerCase()),
subnet_group: z.string().optional().default("100.89.137.0/18"),
@@ -516,6 +521,10 @@ export const configSchema = z
)
.refine(
(data) => {
// The standalone DNS server never uses the secret
if (getRunMode() === "dns") {
return true;
}
// If hybrid is not defined, server secret must be defined
return (
data.server?.secret !== undefined &&
+14
View File
@@ -0,0 +1,14 @@
// Which entry point is running. Standalone entry points set this before
// anything loads the config, so the config schema can skip requirements
// that only apply to the full Pangolin server.
export type RunMode = "server" | "dns";
let runMode: RunMode = "server";
export function setRunMode(mode: RunMode) {
runMode = mode;
}
export function getRunMode(): RunMode {
return runMode;
}