mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-26 21:54:38 +02:00
add flag to disable config managed domains
This commit is contained in:
parent
a24431bc3b
commit
17ac5a5e81
3 changed files with 14188 additions and 14074 deletions
28189
package-lock.json
generated
28189
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -40,20 +40,7 @@ export const configSchema = z
|
||||||
prefer_wildcard_cert: z.boolean().optional().default(false)
|
prefer_wildcard_cert: z.boolean().optional().default(false)
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.refine(
|
.optional(),
|
||||||
(domains) => {
|
|
||||||
const keys = Object.keys(domains);
|
|
||||||
|
|
||||||
if (keys.length === 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
{
|
|
||||||
message: "At least one domain must be defined"
|
|
||||||
}
|
|
||||||
),
|
|
||||||
server: z.object({
|
server: z.object({
|
||||||
integration_port: portSchema
|
integration_port: portSchema
|
||||||
.optional()
|
.optional()
|
||||||
|
@ -253,6 +240,7 @@ export const configSchema = z
|
||||||
enable_redis: z.boolean().optional(),
|
enable_redis: z.boolean().optional(),
|
||||||
disable_local_sites: z.boolean().optional(),
|
disable_local_sites: z.boolean().optional(),
|
||||||
disable_basic_wireguard_sites: z.boolean().optional(),
|
disable_basic_wireguard_sites: z.boolean().optional(),
|
||||||
|
disable_config_managed_domains: z.boolean().optional()
|
||||||
})
|
})
|
||||||
.optional()
|
.optional()
|
||||||
})
|
})
|
||||||
|
@ -267,6 +255,21 @@ export const configSchema = z
|
||||||
message:
|
message:
|
||||||
"If Redis is enabled, configuration details must be provided"
|
"If Redis is enabled, configuration details must be provided"
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
.refine(
|
||||||
|
(data) => {
|
||||||
|
const keys = Object.keys(data.domains || {});
|
||||||
|
if (data.flags?.disable_config_managed_domains) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (keys.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
message: "At least one domain must be defined"
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export function readConfigFile() {
|
export function readConfigFile() {
|
||||||
|
|
|
@ -8,8 +8,31 @@ export async function copyInConfig() {
|
||||||
const endpoint = config.getRawConfig().gerbil.base_endpoint;
|
const endpoint = config.getRawConfig().gerbil.base_endpoint;
|
||||||
const listenPort = config.getRawConfig().gerbil.start_port;
|
const listenPort = config.getRawConfig().gerbil.start_port;
|
||||||
|
|
||||||
|
if (!config.getRawConfig().flags?.disable_config_managed_domains) {
|
||||||
|
await copyInDomains();
|
||||||
|
}
|
||||||
|
|
||||||
|
const exitNodeName = config.getRawConfig().gerbil.exit_node_name;
|
||||||
|
if (exitNodeName) {
|
||||||
|
await db
|
||||||
|
.update(exitNodes)
|
||||||
|
.set({ endpoint, listenPort })
|
||||||
|
.where(eq(exitNodes.name, exitNodeName));
|
||||||
|
} else {
|
||||||
|
await db
|
||||||
|
.update(exitNodes)
|
||||||
|
.set({ endpoint })
|
||||||
|
.where(ne(exitNodes.endpoint, endpoint));
|
||||||
|
await db
|
||||||
|
.update(exitNodes)
|
||||||
|
.set({ listenPort })
|
||||||
|
.where(ne(exitNodes.listenPort, listenPort));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function copyInDomains() {
|
||||||
await db.transaction(async (trx) => {
|
await db.transaction(async (trx) => {
|
||||||
const rawDomains = config.getRawConfig().domains;
|
const rawDomains = config.getRawConfig().domains!; // always defined if disable flag is not set
|
||||||
|
|
||||||
const configDomains = Object.entries(rawDomains).map(
|
const configDomains = Object.entries(rawDomains).map(
|
||||||
([key, value]) => ({
|
([key, value]) => ({
|
||||||
|
@ -104,21 +127,4 @@ export async function copyInConfig() {
|
||||||
.where(eq(resources.resourceId, resource.resourceId));
|
.where(eq(resources.resourceId, resource.resourceId));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const exitNodeName = config.getRawConfig().gerbil.exit_node_name;
|
|
||||||
if (exitNodeName) {
|
|
||||||
await db
|
|
||||||
.update(exitNodes)
|
|
||||||
.set({ endpoint, listenPort })
|
|
||||||
.where(eq(exitNodes.name, exitNodeName));
|
|
||||||
} else {
|
|
||||||
await db
|
|
||||||
.update(exitNodes)
|
|
||||||
.set({ endpoint })
|
|
||||||
.where(ne(exitNodes.endpoint, endpoint));
|
|
||||||
await db
|
|
||||||
.update(exitNodes)
|
|
||||||
.set({ listenPort })
|
|
||||||
.where(ne(exitNodes.listenPort, listenPort));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue