From d12045e10cdc5c39e01c3d9e595e6d2dd03c4912 Mon Sep 17 00:00:00 2001
From: Bernd Storath <999999bst@gmail.com>
Date: Mon, 17 Nov 2025 10:15:22 +0100
Subject: [PATCH] fix ui, fix client
---
.../advanced/config/optional-config.md | 5 ++++-
src/app/components/Form/ArrayField.vue | 2 +-
src/app/components/Form/HostField.vue | 2 +-
src/app/components/Form/NullTextField.vue | 2 +-
src/app/components/Form/NumberField.vue | 2 +-
src/app/components/Form/SwitchField.vue | 2 +-
src/app/components/Form/TextField.vue | 2 +-
.../database/repositories/client/service.ts | 21 ++++++++++++-------
8 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/docs/content/advanced/config/optional-config.md b/docs/content/advanced/config/optional-config.md
index 0bba7b3e..ab9969f0 100644
--- a/docs/content/advanced/config/optional-config.md
+++ b/docs/content/advanced/config/optional-config.md
@@ -73,7 +73,10 @@ When these override environment variables are set:
- However, the overridden values from environment variables will always take precedence at runtime
- The Web UI will display the database values with warning indicators showing which fields are overridden
-These overrides are useful for containerized environments where configuration should be controlled externally.
+Some overrides will not be applied to existing clients until they are manually edited.
+
+- `WG_DEFAULT_*` settings will only apply to new clients
+- `WG_IPV4_CIDR` and `WG_IPV6_CIDR` changes will require clients to be manually edited to take effect
///
diff --git a/src/app/components/Form/ArrayField.vue b/src/app/components/Form/ArrayField.vue
index d7de0195..80bd86e2 100644
--- a/src/app/components/Form/ArrayField.vue
+++ b/src/app/components/Form/ArrayField.vue
@@ -2,7 +2,7 @@
This field is overridden by an environment variable
diff --git a/src/app/components/Form/HostField.vue b/src/app/components/Form/HostField.vue
index 2e2d1ea6..eec76a36 100644
--- a/src/app/components/Form/HostField.vue
+++ b/src/app/components/Form/HostField.vue
@@ -10,7 +10,7 @@
v-if="overridden"
text="This field is overridden by an environment variable"
>
-
+
diff --git a/src/app/components/Form/NullTextField.vue b/src/app/components/Form/NullTextField.vue
index a9c01f26..d3387ef6 100644
--- a/src/app/components/Form/NullTextField.vue
+++ b/src/app/components/Form/NullTextField.vue
@@ -10,7 +10,7 @@
v-if="overridden"
text="This field is overridden by an environment variable"
>
-
+
-
+
diff --git a/src/app/components/Form/SwitchField.vue b/src/app/components/Form/SwitchField.vue
index 1824cbd8..43cc8d26 100644
--- a/src/app/components/Form/SwitchField.vue
+++ b/src/app/components/Form/SwitchField.vue
@@ -10,7 +10,7 @@
v-if="overridden"
text="This field is overridden by an environment variable"
>
-
+
diff --git a/src/app/components/Form/TextField.vue b/src/app/components/Form/TextField.vue
index 8a226805..4f99dba4 100644
--- a/src/app/components/Form/TextField.vue
+++ b/src/app/components/Form/TextField.vue
@@ -10,7 +10,7 @@
v-if="overridden"
text="This field is overridden by an environment variable"
>
-
+
{
const clients = await tx.query.client.findMany().execute();
- const clientInterface = await tx.query.wgInterface
+ const _clientInterface = await tx.query.wgInterface
.findFirst({
where: eq(wgInterface.name, 'wg0'),
})
.execute();
- if (!clientInterface) {
+ if (!_clientInterface) {
throw new Error('WireGuard interface not found');
}
- const clientConfig = await tx.query.userConfig
+ const clientInterface = applyInterfaceOverrides(_clientInterface);
+
+ const _clientConfig = await tx.query.userConfig
.findFirst({
where: eq(userConfig.id, clientInterface.name),
})
.execute();
- if (!clientConfig) {
+ if (!_clientConfig) {
throw new Error('WireGuard interface configuration not found');
}
+ const clientConfig = applyUserConfigOverrides(_clientConfig);
+
const ipv4Cidr = parseCidr(clientInterface.ipv4Cidr);
const ipv4Address = nextIP(4, ipv4Cidr, clients);
const ipv6Cidr = parseCidr(clientInterface.ipv6Cidr);
@@ -241,16 +245,18 @@ export class ClientService {
update(id: ID, data: UpdateClientType) {
return this.#db.transaction(async (tx) => {
- const clientInterface = await tx.query.wgInterface
+ const _clientInterface = await tx.query.wgInterface
.findFirst({
where: eq(wgInterface.name, 'wg0'),
})
.execute();
- if (!clientInterface) {
+ if (!_clientInterface) {
throw new Error('WireGuard interface not found');
}
+ const clientInterface = applyInterfaceOverrides(_clientInterface);
+
if (!containsCidr(clientInterface.ipv4Cidr, data.ipv4Address)) {
throw new Error('IPv4 address is not within the CIDR range');
}
@@ -272,7 +278,8 @@ export class ClientService {
privateKey,
publicKey,
}: ClientCreateFromExistingType) {
- const clientConfig = await Database.userConfigs.get();
+ const _clientConfig = await Database.userConfigs.get();
+ const clientConfig = applyUserConfigOverrides(_clientConfig);
return this.#db
.insert(client)