IC, Caddyfile

This commit is contained in:
2026-07-15 04:29:40 +02:00
commit 344608f056
11 changed files with 245 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import type { Service } from "./types";
/**
should validate config, for now just checks for port collisions
**/
export class ConfigValidator {
static validate(services: Service[]){
const hostports = new Map<string, Set<number>>();
for (const service of services) {
const hostip = service.host.ip;
if (!hostports.has(hostip)) {
hostports.set(hostip, new Set());
}
const ports = hostports.get(hostip)!;
if (ports.has(service.port)) {
throw new Error(`port collision: host ${hostip} already has a service on ${service.port}(${service.name})`)
}
ports.add(service.port);
}
console.log("validated collision");
}
}