Browse Source

Use WG_PORT instead of WG_CLIENT_PORT for INIT_PORT fallback to match original behavior

- Changed setup/2.post.ts to use WG_INTERFACE_OVERRIDE_ENV.PORT instead of WG_CLIENT_OVERRIDE_ENV.CLIENT_PORT
- Changed sqlite.ts initialSetup to use WG_INTERFACE_OVERRIDE_ENV.PORT for consistency
- Updated unattended-setup.md documentation:
  - Changed INIT_PORT description to clarify it sets both interface port and endpoint port
  - Updated warning text to reference WG_PORT (not WG_CLIENT_PORT) as the override fallback
- This matches the original INIT_PORT behavior where updateHostPort() sets both ports to the same value

Co-authored-by: kaaax0815 <[email protected]>
copilot/add-env-variables-admin-panel
copilot-swe-agent[bot] 7 months ago
parent
commit
8b5e6c4c7a
  1. 4
      docs/content/advanced/config/unattended-setup.md
  2. 2
      src/server/api/setup/2.post.ts
  3. 2
      src/server/database/sqlite.ts

4
docs/content/advanced/config/unattended-setup.md

@ -12,7 +12,7 @@ These will only be used during the first start of the container. After that, the
| `INIT_USERNAME` | `admin` | Sets admin username | 1 |
| `INIT_PASSWORD` | `Se!ureP%ssw` | Sets admin password | 1 |
| `INIT_HOST` | `vpn.example.com` | Host clients will connect to | 2 |
| `INIT_PORT` | `51820` | Port clients will connect to (endpoint port) | 2 |
| `INIT_PORT` | `51820` | Port (sets both interface port and endpoint port) | 2 |
| `INIT_DNS` | `1.1.1.1,8.8.8.8` | Sets global dns setting | 3 |
| `INIT_IPV4_CIDR` | `10.8.0.0/24` | Sets IPv4 cidr | 4 |
| `INIT_IPV6_CIDR` | `2001:0DB8::/32` | Sets IPv6 cidr | 4 |
@ -22,7 +22,7 @@ These will only be used during the first start of the container. After that, the
If variables are in the same group, you have to set all of them. For example, if you set `INIT_IPV4_CIDR`, you also have to set `INIT_IPV6_CIDR`.
To skip the setup process, you must configure groups `1` and `2`. You can alternatively use `WG_HOST` and `WG_CLIENT_PORT` to set the host and port without using the `INIT_` variables.
To skip the setup process, you must configure groups `1` and `2`. You can alternatively use `WG_HOST` and `WG_PORT` to set the host and port without using the `INIT_` variables.
Avoid setting both `INIT_` and `WG_` variables for the same setting to prevent confusion.
///

2
src/server/api/setup/2.post.ts

@ -10,7 +10,7 @@ export default defineSetupEventHandler(2, async ({ event }) => {
// If host and port are already set by environment variables, skip step 4
const host = WG_INITIAL_ENV.HOST ?? WG_CLIENT_OVERRIDE_ENV.HOST;
const port = WG_INITIAL_ENV.PORT ?? WG_CLIENT_OVERRIDE_ENV.CLIENT_PORT;
const port = WG_INITIAL_ENV.PORT ?? WG_INTERFACE_OVERRIDE_ENV.PORT;
const setupDone = host && port;

2
src/server/database/sqlite.ts

@ -110,7 +110,7 @@ async function initialSetup(db: DBServiceType) {
// Use INIT vars or fall back to override vars for HOST and PORT
const host = WG_INITIAL_ENV.HOST ?? WG_CLIENT_OVERRIDE_ENV.HOST;
const port = WG_INITIAL_ENV.PORT ?? WG_CLIENT_OVERRIDE_ENV.CLIENT_PORT;
const port = WG_INITIAL_ENV.PORT ?? WG_INTERFACE_OVERRIDE_ENV.PORT;
// HOST and PORT can come from either INIT vars or override vars
if (host && port) {

Loading…
Cancel
Save