From 0d60117a638320dad0dfa90cec4c75f38e16afff Mon Sep 17 00:00:00 2001 From: Bernd Storath <32197462+kaaax0815@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:29:16 +0200 Subject: [PATCH] Chore: Deprecate Dockerless (#1377) * deprecate dockerless --- README.md | 1 - docker-compose.yml | 1 - package.json | 7 ++----- src/server/utils/WireGuard.ts | 3 +-- src/server/utils/config.ts | 2 -- src/services/database/lowdb.ts | 3 +-- wg-easy.service | 22 ---------------------- 7 files changed, 4 insertions(+), 35 deletions(-) delete mode 100644 wg-easy.service diff --git a/README.md b/README.md index ea951bce..bf0269ff 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,6 @@ These options can be configured by setting environment variables using `-e KEY=" | --------- | ----------------- | ------------- | -------------------------------------------- | | `PORT` | `51821` | `6789` | TCP port for Web UI. | | `HOST` | `0.0.0.0` | `localhost` | IP address web UI binds to. | -| `WG_PATH` | `/etc/wireguard/` | `/home/user/` | The Path your `wg0.conf` and `db.json` lives | ## Updating diff --git a/docker-compose.yml b/docker-compose.yml index c1e00063..1eb082f3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,6 @@ services: - PORT=51821 # Optional: # - HOST=0.0.0.0 - # - WG_PATH=/etc/wireguard/ image: ghcr.io/wg-easy/wg-easy container_name: wg-easy diff --git a/package.json b/package.json index af3378b9..ecf2bff0 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,8 @@ { "version": "1.0.1", "scripts": { - "sudobuild": "DOCKER_BUILDKIT=1 sudo docker build --tag wg-easy .", - "build:docker": "DOCKER_BUILDKIT=1 docker build --tag wg-easy .", - "serve": "docker compose -f docker-compose.yml -f docker-compose.dev.yml up", - "sudostart": "sudo docker run --env WG_HOST=0.0.0.0 --name wg-easy --cap-add=NET_ADMIN --cap-add=SYS_MODULE --sysctl=\"net.ipv4.conf.all.src_valid_mark=1\" --mount type=bind,source=\"$(pwd)\"/config,target=/etc/wireguard -p 51820:51820/udp -p 51821:51821/tcp wg-easy", - "start": "docker run --env WG_HOST=0.0.0.0 --name wg-easy --cap-add=NET_ADMIN --cap-add=SYS_MODULE --sysctl=\"net.ipv4.conf.all.src_valid_mark=1\" --mount type=bind,source=\"$(pwd)\"/config,target=/etc/wireguard -p 51820:51820/udp -p 51821:51821/tcp wg-easy" + "dev": "docker compose -f docker-compose.dev.yml up", + "build": "docker build -t wg-easy ." }, "packageManager": "pnpm@9.9.0" } diff --git a/src/server/utils/WireGuard.ts b/src/server/utils/WireGuard.ts index e0b52f72..ce339fa9 100644 --- a/src/server/utils/WireGuard.ts +++ b/src/server/utils/WireGuard.ts @@ -1,5 +1,4 @@ import fs from 'node:fs/promises'; -import path from 'path'; import debug from 'debug'; import crypto from 'node:crypto'; import QRCode from 'qrcode'; @@ -30,7 +29,7 @@ class WireGuard { } DEBUG('Config saving...'); - await fs.writeFile(path.join(WG_PATH, 'wg0.conf'), result.join('\n\n'), { + await fs.writeFile('/etc/wireguard/wg0.conf', result.join('\n\n'), { mode: 0o600, }); DEBUG('Config saved.'); diff --git a/src/server/utils/config.ts b/src/server/utils/config.ts index ba9714ee..f927590a 100644 --- a/src/server/utils/config.ts +++ b/src/server/utils/config.ts @@ -5,8 +5,6 @@ import type { Database } from '~~/services/database/repositories/database'; import { parseCidr } from 'cidr-tools'; import { stringifyIp } from 'ip-bigint'; -export const WG_PATH = process.env.WG_PATH || '/etc/wireguard/'; - export const RELEASE = packageJson.release.version; export const SERVER_DEBUG = debug('Server'); diff --git a/src/services/database/lowdb.ts b/src/services/database/lowdb.ts index 0f9320a7..4ad3e736 100644 --- a/src/services/database/lowdb.ts +++ b/src/services/database/lowdb.ts @@ -1,6 +1,5 @@ import crypto from 'node:crypto'; import debug from 'debug'; -import { join } from 'path'; import { DatabaseProvider, @@ -22,7 +21,7 @@ export default class LowDB extends DatabaseProvider { #connected = false; private async __init() { - const dbFilePath = join(WG_PATH, 'db.json'); + const dbFilePath = '/etc/wireguard/db.json'; this.#db = await JSONFilePreset(dbFilePath, DEFAULT_DATABASE); } diff --git a/wg-easy.service b/wg-easy.service deleted file mode 100644 index bcdf72fd..00000000 --- a/wg-easy.service +++ /dev/null @@ -1,22 +0,0 @@ -[Unit] -Description=Wireguard VPN + Web-based Admin UI -After=network-online.target nss-lookup.target - -[Service] -Environment="WG_HOST=raspberrypi.local" # Change this to your host's public address or static public ip. -Environment="PASSWORD=REPLACEME" # When set, requires a password when logging in to the Web UI, to disable add a hashtag -#Environment="WG_DEFAULT_ADDRESS=10.0.8.x" #Clients IP address range. -#Environment="WG_DEFAULT_DNS=10.0.8.1, 1.1.1.1" #DNS server clients will use. If set to blank value, clients will not use any DNS. -#Environment="WG_ALLOWED_IPS=0.0.0.0/0,::/0" #Allowed IPs clients will use. -#Environment="WG_DEVICE=ens1" #Ethernet device the wireguard traffic should be forwarded through. -#Environment="PORT=80" #TCP port for Web UI. Default : 51821 -#Environment="WG_MTU=1420" #The MTU the clients will use. Server uses default WG MTU -#Environment="WG_PERSISTENT_KEEPALIVE=25" #Value in seconds to keep the "connection" open. If this value is 0, then connections won't be kept alive. -Type=simple -RemainAfterExit=no -ExecStart=/usr/bin/env node /app/server.js -Restart=on-failure -RestartSec=1 - -[Install] -WantedBy=multi-user.target