Move domain information to all in private

This commit is contained in:
Owen
2026-09-10 13:57:28 -04:00
parent 217a59ad10
commit d49177642c
5 changed files with 54 additions and 33 deletions
+3
View File
@@ -0,0 +1,3 @@
export function createCname(domainId: string, baseDomain: string) {}
export function createNs() {}
-17
View File
@@ -493,23 +493,6 @@ export const configSchema = z
.prefault({}) .prefault({})
}) })
.optional() .optional()
.prefault({}),
dns: z
.object({
nameservers: z
.array(z.string().optional().optional())
.optional()
.default([
"ns1.pangolin.net",
"ns2.pangolin.net",
"ns3.pangolin.net"
]),
cname_extension: z
.string()
.optional()
.default("cname.pangolin.net")
})
.optional()
.prefault({}) .prefault({})
}) })
.refine( .refine(
+47
View File
@@ -0,0 +1,47 @@
/*
* This file is part of a proprietary work.
*
* Copyright (c) 2025-2026 Fossorial, Inc.
* All rights reserved.
*
* This file is licensed under the Fossorial Commercial License.
* You may not use this file except in compliance with the License.
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
*
* This file is not licensed under the AGPLv3.
*/
import { build } from "@server/build";
import privateConfig from "#private/lib/config";
export function createCname(domainId: string, baseDomain: string) {
if (!privateConfig.getRawPrivateConfig().dns?.cname_extension) {
throw new Error("CNAME extension not configured");
}
let cnameRecords = [
{
value: `${domainId}.${privateConfig.getRawPrivateConfig().dns?.cname_extension}`,
baseDomain: baseDomain
},
{
value: `_acme-challenge.${domainId}.${privateConfig.getRawPrivateConfig().dns?.cname_extension}`,
baseDomain: `_acme-challenge.${baseDomain}`
}
];
return cnameRecords;
}
export function createNs() {
if (!privateConfig.getRawPrivateConfig().dns?.nameserver_name) {
throw new Error("Nameservers not configured");
}
const nsRecords = [
privateConfig.getRawPrivateConfig().dns?.nameserver_name,
...(privateConfig.getRawPrivateConfig().dns?.alternate_nameservers ||
[])
] as string[];
return nsRecords;
}
+1 -1
View File
@@ -229,7 +229,7 @@ export const privateConfigSchema = z
.number() .number()
.int() .int()
.positive() .positive()
.default(60000), .default(5000),
// Kept safely under Let's Encrypt's ~20 req/s limit since this // Kept safely under Let's Encrypt's ~20 req/s limit since this
// budget is shared across all pops workers and only covers the // budget is shared across all pops workers and only covers the
// request-issuing calls we make directly (not every request // request-issuing calls we make directly (not every request
+3 -15
View File
@@ -21,6 +21,7 @@ import { LimitId } from "@server/lib/billing";
import { isSecondLevelDomain, isValidDomain } from "@server/lib/validators"; import { isSecondLevelDomain, isValidDomain } from "@server/lib/validators";
import { build } from "@server/build"; import { build } from "@server/build";
import config from "@server/lib/config"; import config from "@server/lib/config";
import { createNs, createCname } from "#dynamic/lib/dns/generateDomains";
const paramsSchema = z.strictObject({ const paramsSchema = z.strictObject({
orgId: z.string() orgId: z.string()
@@ -283,8 +284,7 @@ export async function createOrgDomain(
// TODO: This needs to be cross region and not hardcoded // TODO: This needs to be cross region and not hardcoded
if (type === "ns") { if (type === "ns") {
nsRecords = config.getRawConfig().dns.nameservers as string[]; nsRecords = createNs();
// Save NS records to database // Save NS records to database
for (const nsValue of nsRecords) { for (const nsValue of nsRecords) {
recordsToInsert.push({ recordsToInsert.push({
@@ -296,19 +296,7 @@ export async function createOrgDomain(
}); });
} }
} else if (type === "cname") { } else if (type === "cname") {
cnameRecords = [ cnameRecords = createCname(domainId, baseDomain);
{
value: `${domainId}.${config.getRawConfig().dns.cname_extension}`,
baseDomain: baseDomain
}
];
if (build == "saas") {
cnameRecords.push({
value: `_acme-challenge.${domainId}.${config.getRawConfig().dns.cname_extension}`,
baseDomain: `_acme-challenge.${baseDomain}`
});
}
// Save CNAME records to database // Save CNAME records to database
for (const cnameRecord of cnameRecords) { for (const cnameRecord of cnameRecords) {