mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-23 20:24:34 +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
|
@ -8,8 +8,31 @@ export async function copyInConfig() {
|
|||
const endpoint = config.getRawConfig().gerbil.base_endpoint;
|
||||
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) => {
|
||||
const rawDomains = config.getRawConfig().domains;
|
||||
const rawDomains = config.getRawConfig().domains!; // always defined if disable flag is not set
|
||||
|
||||
const configDomains = Object.entries(rawDomains).map(
|
||||
([key, value]) => ({
|
||||
|
@ -104,21 +127,4 @@ export async function copyInConfig() {
|
|||
.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