mirror of
https://github.com/fosrl/pangolin.git
synced 2026-09-10 21:16:35 +02:00
Move domain information to all in private
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
export function createCname(domainId: string, baseDomain: string) {}
|
||||
|
||||
export function createNs() {}
|
||||
@@ -493,23 +493,6 @@ export const configSchema = z
|
||||
.prefault({})
|
||||
})
|
||||
.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({})
|
||||
})
|
||||
.refine(
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -229,7 +229,7 @@ export const privateConfigSchema = z
|
||||
.number()
|
||||
.int()
|
||||
.positive()
|
||||
.default(60000),
|
||||
.default(5000),
|
||||
// Kept safely under Let's Encrypt's ~20 req/s limit since this
|
||||
// budget is shared across all pops workers and only covers the
|
||||
// request-issuing calls we make directly (not every request
|
||||
|
||||
@@ -21,6 +21,7 @@ import { LimitId } from "@server/lib/billing";
|
||||
import { isSecondLevelDomain, isValidDomain } from "@server/lib/validators";
|
||||
import { build } from "@server/build";
|
||||
import config from "@server/lib/config";
|
||||
import { createNs, createCname } from "#dynamic/lib/dns/generateDomains";
|
||||
|
||||
const paramsSchema = z.strictObject({
|
||||
orgId: z.string()
|
||||
@@ -283,8 +284,7 @@ export async function createOrgDomain(
|
||||
|
||||
// TODO: This needs to be cross region and not hardcoded
|
||||
if (type === "ns") {
|
||||
nsRecords = config.getRawConfig().dns.nameservers as string[];
|
||||
|
||||
nsRecords = createNs();
|
||||
// Save NS records to database
|
||||
for (const nsValue of nsRecords) {
|
||||
recordsToInsert.push({
|
||||
@@ -296,19 +296,7 @@ export async function createOrgDomain(
|
||||
});
|
||||
}
|
||||
} else if (type === "cname") {
|
||||
cnameRecords = [
|
||||
{
|
||||
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}`
|
||||
});
|
||||
}
|
||||
cnameRecords = createCname(domainId, baseDomain);
|
||||
|
||||
// Save CNAME records to database
|
||||
for (const cnameRecord of cnameRecords) {
|
||||
|
||||
Reference in New Issue
Block a user