import type { Service } from "./types"; /** should validate config, for now just checks for port collisions **/ export class ConfigValidator { static validatecaddyfile(services: Service[]){ const hostports = new Map>(); 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"); } }