Compare commits

..
40 Commits
Author SHA1 Message Date
daanselen 5e18da8ee4 chore: remove arm/v7 due to deprecation 2026-10-26 00:52:11 +01:00
daanselen 42c195717d Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/src/static/app/development/electron-builder-26.18.0' into development 2026-10-26 00:50:18 +01:00
daanselen fbce8e6a7f Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/src/static/app/development/npm-12.2.1' into development 2026-10-26 00:50:14 +01:00
dependabot[bot] 44032d1e9d build(deps): bump electron-builder in /src/static/app
Bumps [electron-builder](https://github.com/electron-userland/electron-builder/tree/HEAD/packages/electron-builder) from 26.7.0 to 26.18.0.
- [Release notes](https://github.com/electron-userland/electron-builder/releases)
- [Changelog](https://github.com/electron-userland/electron-builder/blob/[email protected]/packages/electron-builder/CHANGELOG.md)
- [Commits](https://github.com/electron-userland/electron-builder/commits/[email protected]/packages/electron-builder)

---
updated-dependencies:
- dependency-name: electron-builder
  dependency-version: 26.18.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:48:45 +00:00
daanselen 05fbfe5cb5 Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/src/static/app/development/bootstrap-icons-1.13.2' into development 2026-10-26 00:48:43 +01:00
dependabot[bot] 16e6b62113 build(deps): bump npm from 11.13.0 to 12.2.1 in /src/static/app
Bumps [npm](https://github.com/npm/cli) from 11.13.0 to 12.2.1.
- [Release notes](https://github.com/npm/cli/releases)
- [Changelog](https://github.com/npm/cli/blob/latest/CHANGELOG.md)
- [Commits](https://github.com/npm/cli/compare/v11.13.0...v12.2.1)

---
updated-dependencies:
- dependency-name: npm
  dependency-version: 12.2.1
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:48:29 +00:00
dependabot[bot] 4b625430d0 build(deps): bump bootstrap-icons in /src/static/app
Bumps [bootstrap-icons](https://github.com/twbs/icons) from 1.13.1 to 1.13.2.
- [Release notes](https://github.com/twbs/icons/releases)
- [Commits](https://github.com/twbs/icons/compare/v1.13.1...v1.13.2)

---
updated-dependencies:
- dependency-name: bootstrap-icons
  dependency-version: 1.13.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:48:11 +00:00
dependabot[bot] d0dfb83733 build(deps): bump vue-chartjs from 5.3.3 to 5.3.4 in /src/static/app
Bumps [vue-chartjs](https://github.com/apertureless/vue-chartjs) from 5.3.3 to 5.3.4.
- [Release notes](https://github.com/apertureless/vue-chartjs/releases)
- [Changelog](https://github.com/apertureless/vue-chartjs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/apertureless/vue-chartjs/compare/v5.3.3...v5.3.4)

---
updated-dependencies:
- dependency-name: vue-chartjs
  dependency-version: 5.3.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:47:53 +00:00
dependabot[bot] f26d774d18 build(deps): bump pinia from 3.0.4 to 4.1.0 in /src/static/app
Bumps [pinia](https://github.com/vuejs/pinia) from 3.0.4 to 4.1.0.
- [Release notes](https://github.com/vuejs/pinia/releases)
- [Commits](https://github.com/vuejs/pinia/compare/v3.0.4...v4.1.0)

---
updated-dependencies:
- dependency-name: pinia
  dependency-version: 4.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:45:41 +00:00
daanselen f6be8c2766 Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/src/static/client/development/vue-router-5.4.0' into development 2026-10-26 00:44:17 +01:00
daanselen 71af1978cd Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/src/static/client/development/axios-1.20.0' into development 2026-10-26 00:44:10 +01:00
daanselen 0ce7a1daeb Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/src/static/app/development/uuid-14.0.3' into development 2026-10-26 00:44:00 +01:00
dependabot[bot] 12d1122272 build(deps): bump uuid from 14.0.0 to 14.0.3 in /src/static/app
Bumps [uuid](https://github.com/uuidjs/uuid) from 14.0.0 to 14.0.3.
- [Release notes](https://github.com/uuidjs/uuid/releases)
- [Changelog](https://github.com/uuidjs/uuid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/uuidjs/uuid/compare/v14.0.0...v14.0.3)

---
updated-dependencies:
- dependency-name: uuid
  dependency-version: 14.0.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:43:46 +00:00
daanselen 05d615d640 Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/src/static/app/development/volar/language-server-2.4.30' into development 2026-10-26 00:43:32 +01:00
daanselen 20dbbda530 Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/src/static/app/development/ol-10.11.0' into development 2026-10-26 00:43:16 +01:00
daanselen a96653c506 Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/src/static/app/development/vite-8.3.5' into development 2026-10-26 00:43:11 +01:00
dependabot[bot] 356e3601a6 build(deps-dev): bump vite from 8.0.16 to 8.3.5 in /src/static/app
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 8.0.16 to 8.3.5.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v8.3.5/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 8.3.5
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:42:39 +00:00
dependabot[bot] f2b58c9f57 build(deps): bump ol from 10.9.0 to 10.11.0 in /src/static/app
Bumps [ol](https://github.com/openlayers/openlayers) from 10.9.0 to 10.11.0.
- [Release notes](https://github.com/openlayers/openlayers/releases)
- [Commits](https://github.com/openlayers/openlayers/compare/v10.9.0...v10.11.0)

---
updated-dependencies:
- dependency-name: ol
  dependency-version: 10.11.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:42:26 +00:00
dependabot[bot] 752c1f0047 build(deps): bump axios from 1.18.0 to 1.20.0 in /src/static/client
Bumps [axios](https://github.com/axios/axios) from 1.18.0 to 1.20.0.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.18.0...v1.20.0)

---
updated-dependencies:
- dependency-name: axios
  dependency-version: 1.20.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:42:22 +00:00
dependabot[bot] dd7b0b5ebf build(deps): bump vue-router from 5.1.0 to 5.4.0 in /src/static/client
Bumps [vue-router](https://github.com/vuejs/router) from 5.1.0 to 5.4.0.
- [Release notes](https://github.com/vuejs/router/releases)
- [Commits](https://github.com/vuejs/router/compare/v5.1.0...v5.4.0)

---
updated-dependencies:
- dependency-name: vue-router
  dependency-version: 5.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:42:11 +00:00
dependabot[bot] 98aff0c0e2 build(deps): bump @volar/language-server in /src/static/app
Bumps [@volar/language-server](https://github.com/volarjs/volar.js/tree/HEAD/packages/language-server) from 2.4.28 to 2.4.30.
- [Release notes](https://github.com/volarjs/volar.js/releases)
- [Changelog](https://github.com/volarjs/volar.js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/volarjs/volar.js/commits/v2.4.30/packages/language-server)

---
updated-dependencies:
- dependency-name: "@volar/language-server"
  dependency-version: 2.4.30
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:42:07 +00:00
dependabot[bot] 436601daee build(deps): bump dayjs from 1.11.21 to 1.11.23 in /src/static/client
Bumps [dayjs](https://github.com/iamkun/dayjs) from 1.11.21 to 1.11.23.
- [Release notes](https://github.com/iamkun/dayjs/releases)
- [Changelog](https://github.com/iamkun/dayjs/blob/v1.11.23/CHANGELOG.md)
- [Commits](https://github.com/iamkun/dayjs/compare/v1.11.21...v1.11.23)

---
updated-dependencies:
- dependency-name: dayjs
  dependency-version: 1.11.23
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:41:31 +00:00
daanselen d987207c46 Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/src/static/app/development/vue/language-server-3.3.13' into development 2026-10-26 00:40:10 +01:00
daanselen bf4c3dc276 Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/src/static/app/development/dayjs-1.11.23' into development 2026-10-26 00:40:05 +01:00
daanselen 5eb680077a Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/src/static/app/development/cidr-tools-13.0.4' into development 2026-10-26 00:40:00 +01:00
daanselen 49d7586651 Merge remote-tracking branch 'origin/dependabot/pip/src/development/pymysql-1.2.3' into development 2026-10-26 00:39:23 +01:00
dependabot[bot] 503be07292 build(deps): bump @vue/language-server in /src/static/app
Bumps [@vue/language-server](https://github.com/vuejs/language-tools/tree/HEAD/packages/language-server) from 3.2.7 to 3.3.13.
- [Release notes](https://github.com/vuejs/language-tools/releases)
- [Changelog](https://github.com/vuejs/language-tools/blob/master/CHANGELOG.md)
- [Commits](https://github.com/vuejs/language-tools/commits/v3.3.13/packages/language-server)

---
updated-dependencies:
- dependency-name: "@vue/language-server"
  dependency-version: 3.3.13
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:38:48 +00:00
daanselen 5189f791a3 Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/src/static/app/development/vueuse/shared-15.0.0' into development 2026-10-26 00:38:32 +01:00
daanselen d0625ef8c9 Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/src/static/client/development/pinia-4.1.0' into development 2026-10-26 00:38:02 +01:00
daanselen 25cc9ca35a Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/src/static/client/development/bootstrap-icons-1.13.2' into development 2026-10-26 00:37:50 +01:00
dependabot[bot] 42c2535ad6 build(deps): bump pymysql from 1.2.0 to 1.2.3 in /src
Bumps [pymysql](https://github.com/PyMySQL/PyMySQL) from 1.2.0 to 1.2.3.
- [Release notes](https://github.com/PyMySQL/PyMySQL/releases)
- [Changelog](https://github.com/PyMySQL/PyMySQL/blob/main/CHANGELOG.md)
- [Commits](https://github.com/PyMySQL/PyMySQL/compare/v1.2.0...v1.2.3)

---
updated-dependencies:
- dependency-name: pymysql
  dependency-version: 1.2.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:37:40 +00:00
dependabot[bot] 55970cb8c2 build(deps): bump cidr-tools from 12.0.2 to 13.0.4 in /src/static/app
Bumps [cidr-tools](https://github.com/silverwind/cidr-tools) from 12.0.2 to 13.0.4.
- [Release notes](https://github.com/silverwind/cidr-tools/releases)
- [Commits](https://github.com/silverwind/cidr-tools/compare/12.0.2...13.0.4)

---
updated-dependencies:
- dependency-name: cidr-tools
  dependency-version: 13.0.4
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:34:44 +00:00
dependabot[bot] 7f5d75370f build(deps): bump dayjs from 1.11.19 to 1.11.23 in /src/static/app
Bumps [dayjs](https://github.com/iamkun/dayjs) from 1.11.19 to 1.11.23.
- [Release notes](https://github.com/iamkun/dayjs/releases)
- [Changelog](https://github.com/iamkun/dayjs/blob/v1.11.23/CHANGELOG.md)
- [Commits](https://github.com/iamkun/dayjs/compare/v1.11.19...v1.11.23)

---
updated-dependencies:
- dependency-name: dayjs
  dependency-version: 1.11.23
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:34:34 +00:00
dependabot[bot] b13bcef3f6 build(deps): bump @vueuse/shared in /src/static/app
Bumps [@vueuse/shared](https://github.com/vueuse/vueuse/tree/HEAD/packages/shared) from 14.4.0 to 15.0.0.
- [Release notes](https://github.com/vueuse/vueuse/releases)
- [Commits](https://github.com/vueuse/vueuse/commits/v15.0.0/packages/shared)

---
updated-dependencies:
- dependency-name: "@vueuse/shared"
  dependency-version: 15.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:34:29 +00:00
dependabot[bot] 56d6b31daa build(deps): bump pinia from 3.0.4 to 4.1.0 in /src/static/client
Bumps [pinia](https://github.com/vuejs/pinia) from 3.0.4 to 4.1.0.
- [Release notes](https://github.com/vuejs/pinia/releases)
- [Commits](https://github.com/vuejs/pinia/compare/v3.0.4...v4.1.0)

---
updated-dependencies:
- dependency-name: pinia
  dependency-version: 4.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:34:26 +00:00
dependabot[bot] 116db7cb78 build(deps): bump bootstrap-icons in /src/static/client
Bumps [bootstrap-icons](https://github.com/twbs/icons) from 1.13.1 to 1.13.2.
- [Release notes](https://github.com/twbs/icons/releases)
- [Commits](https://github.com/twbs/icons/compare/v1.13.1...v1.13.2)

---
updated-dependencies:
- dependency-name: bootstrap-icons
  dependency-version: 1.13.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:34:19 +00:00
dependabot[bot] 8f0c37f716 build(deps): bump sqlalchemy-utils from 0.42.1 to 0.43.0 in /src
Bumps [sqlalchemy-utils](https://github.com/kvesteri/sqlalchemy-utils) from 0.42.1 to 0.43.0.
- [Release notes](https://github.com/kvesteri/sqlalchemy-utils/releases)
- [Changelog](https://github.com/kvesteri/sqlalchemy-utils/blob/master/CHANGES.rst)
- [Commits](https://github.com/kvesteri/sqlalchemy-utils/compare/0.42.1...0.43.0)

---
updated-dependencies:
- dependency-name: sqlalchemy-utils
  dependency-version: 0.43.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:33:48 +00:00
daanselen 42fcbb5a6e Merge remote-tracking branch 'origin/dependabot/docker/docker/development/golang-1.27-alpine3.24' into development 2026-10-26 00:29:56 +01:00
dependabot[bot] 017e375f90 build(deps): bump python in /docker
Bumps python from 3.14-alpine3.24 to 3.15-alpine3.24.

---
updated-dependencies:
- dependency-name: python
  dependency-version: 3.15-alpine3.23
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:29:28 +00:00
dependabot[bot] 3bd56d5593 build(deps): bump golang in /docker
Bumps golang from 1.26-alpine3.24 to 1.27-alpine3.24.

---
updated-dependencies:
- dependency-name: golang
  dependency-version: 1.27-alpine3.24
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-10-25 23:28:43 +00:00
9 changed files with 452 additions and 571 deletions
+5 -5
View File
@@ -4,7 +4,7 @@
# #
# Pull the current golang-alpine image. # Pull the current golang-alpine image.
FROM golang:1.27-alpine3.24 AS awg-go-builder FROM golang:1.27-alpine3.24 AS awg-go
# Install build-dependencies. # Install build-dependencies.
RUN apk add --no-cache \ RUN apk add --no-cache \
@@ -30,7 +30,7 @@ RUN go version && \
# AWG TOOLS BUILDING STAGE # AWG TOOLS BUILDING STAGE
# Base: Alpine # Base: Alpine
# #
FROM alpine:3.24 AS awg-tools-builder FROM alpine:3.24 AS awg-tools
# Install needed dependencies. # Install needed dependencies.
RUN apk add --no-cache \ RUN apk add --no-cache \
@@ -121,9 +121,9 @@ RUN apk add --no-cache \
SHELL ["/bin/bash", "-o", "pipefail", "-c"] SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Copy only the final binaries from the AWG builder stages # Copy only the final binaries from the AWG builder stages
COPY --from=awg-go-builder /usr/bin/amneziawg-go /usr/bin/amneziawg-go COPY --from=awg-go /usr/bin/amneziawg-go /usr/bin/amneziawg-go
COPY --from=awg-tools-builder /workspace/awg-tools/src/wg /usr/bin/awg COPY --from=awg-tools /workspace/awg-tools/src/wg /usr/bin/awg
COPY --from=awg-tools-builder /workspace/awg-tools/src/wg-quick/linux.bash /usr/bin/awg-quick COPY --from=awg-tools /workspace/awg-tools/src/wg-quick/linux.bash /usr/bin/awg-quick
# Environment variables # Environment variables
ARG wg_net="10.0.0.1" ARG wg_net="10.0.0.1"
+9 -7
View File
@@ -9,7 +9,8 @@ from zipfile import ZipFile
from datetime import datetime, timedelta from datetime import datetime, timedelta
import sqlalchemy import sqlalchemy
from flask import Flask, request, render_template, session, send_file, current_app from jinja2 import Template
from flask import Flask, request, render_template, session, send_file, current_app, redirect, url_for
from flask_cors import CORS from flask_cors import CORS
from icmplib import ping, traceroute from icmplib import ping, traceroute
from flask.json.provider import DefaultJSONProvider from flask.json.provider import DefaultJSONProvider
@@ -19,8 +20,7 @@ from sqlalchemy import RowMapping
from modules.Utilities import ( from modules.Utilities import (
RegexMatch, StringToBoolean, ValidateDNSAddress, RegexMatch, StringToBoolean, ValidateDNSAddress,
GenerateWireguardPublicKey, GenerateWireguardPrivateKey, GenerateWireguardPublicKey, GenerateWireguardPrivateKey
RenderSandboxedTemplate
) )
from packaging import version from packaging import version
from modules.Email import EmailSender from modules.Email import EmailSender
@@ -1597,9 +1597,10 @@ def API_Email_Send():
if configuration is not None: if configuration is not None:
fp, p = configuration.searchPeer(data.get('Peer')) fp, p = configuration.searchPeer(data.get('Peer'))
if fp: if fp:
template = Template(body)
download = p.downloadPeer() download = p.downloadPeer()
body = RenderSandboxedTemplate(body, peer=p.toJson(), configurationFile=download) body = template.render(peer=p.toJson(), configurationFile=download)
subject = RenderSandboxedTemplate(data.get('Subject', ''), peer=p.toJson(), configurationFile=download) subject = Template(data.get('Subject', '')).render(peer=p.toJson(), configurationFile=download)
if data.get('IncludeAttachment', False): if data.get('IncludeAttachment', False):
u = str(uuid4()) u = str(uuid4())
peerName = p.toJson().get('name', '').strip() peerName = p.toJson().get('name', '').strip()
@@ -1628,10 +1629,11 @@ def API_Email_PreviewBody():
return ResponseObject(False, "Peer does not exist") return ResponseObject(False, "Peer does not exist")
try: try:
template = Template(body)
download = p.downloadPeer() download = p.downloadPeer()
return ResponseObject(data={ return ResponseObject(data={
"Body": RenderSandboxedTemplate(body, peer=p.toJson(), configurationFile=download), "Body": Template(body).render(peer=p.toJson(), configurationFile=download),
"Subject": RenderSandboxedTemplate(subject, peer=p.toJson(), configurationFile=download) "Subject": Template(subject).render(peer=p.toJson(), configurationFile=download)
}) })
except Exception as e: except Exception as e:
return ResponseObject(False, message=str(e)) return ResponseObject(False, message=str(e))
+3 -3
View File
@@ -7,12 +7,12 @@ import json
import os, subprocess, uuid, random, re import os, subprocess, uuid, random, re
from datetime import timedelta from datetime import timedelta
import jinja2
import sqlalchemy as db import sqlalchemy as db
from .PeerJob import PeerJob from .PeerJob import PeerJob
from flask import current_app from flask import current_app
from .PeerShareLink import PeerShareLink from .PeerShareLink import PeerShareLink
from .Utilities import GenerateWireguardPublicKey, CheckAddress, ValidateDNSAddress, \ from .Utilities import GenerateWireguardPublicKey, CheckAddress, ValidateDNSAddress
RenderSandboxedTemplate
class Peer: class Peer:
@@ -237,7 +237,7 @@ class Peer:
if val is not None and ((type(val) is str and len(val) > 0) or (type(val) is int and val > 0)): if val is not None and ((type(val) is str and len(val) > 0) or (type(val) is int and val > 0)):
final["file"] += f"{key} = {val}\n" final["file"] += f"{key} = {val}\n"
final["file"] = RenderSandboxedTemplate(final["file"], configuration=self.configuration) final["file"] = jinja2.Template(final["file"]).render(configuration=self.configuration)
if self.configuration.Protocol == "awg": if self.configuration.Protocol == "awg":
-15
View File
@@ -1,21 +1,6 @@
import re, ipaddress import re, ipaddress
import subprocess import subprocess
import sqlalchemy import sqlalchemy
from jinja2.sandbox import SandboxedEnvironment
sandboxEnvironment = SandboxedEnvironment()
def RenderSandboxedTemplate(source: str, **context) -> str:
"""
Render a Jinja2 template within a sandboxed environment. Template sources built with
user-provided content (e.g. email body, peer configuration file) must go through this
function, so unsafe attribute access (such as __globals__) is denied and template
injection cannot escalate into arbitrary code execution.
@param source: Template source string, may contain user-provided content
@param context: Variables passed into the template
@return: Rendered template
"""
return sandboxEnvironment.from_string(source).render(**context)
def RegexMatch(regex, text) -> bool: def RegexMatch(regex, text) -> bool:
""" """
+3 -3
View File
@@ -3,6 +3,7 @@ WireGuard Configuration
""" """
from typing import Any from typing import Any
import jinja2
import sqlalchemy, random, shutil, configparser, ipaddress, os, subprocess, time, re, uuid, psutil, traceback import sqlalchemy, random, shutil, configparser, ipaddress, os, subprocess, time, re, uuid, psutil, traceback
from zipfile import ZipFile from zipfile import ZipFile
from datetime import datetime, timedelta from datetime import datetime, timedelta
@@ -20,8 +21,7 @@ from .Utilities import StringToBoolean, \
ValidateDNSAddress, \ ValidateDNSAddress, \
ValidateEndpointAllowedIPs, \ ValidateEndpointAllowedIPs, \
CheckAddress, \ CheckAddress, \
CheckPeerKey, \ CheckPeerKey
RenderSandboxedTemplate
from .WireguardConfigurationInfo import WireguardConfigurationInfo, PeerGroupsClass from .WireguardConfigurationInfo import WireguardConfigurationInfo, PeerGroupsClass
from .DashboardWebHooks import DashboardWebHooks from .DashboardWebHooks import DashboardWebHooks
@@ -1242,7 +1242,7 @@ class WireguardConfiguration:
elif key == "OverridePeerSettings": elif key == "OverridePeerSettings":
for (key, val) in value.items(): for (key, val) in value.items():
try: try:
status, msg = self.__validateOverridePeerSettings(key, RenderSandboxedTemplate(val, configuration=self.toJson())) status, msg = self.__validateOverridePeerSettings(key, jinja2.Template(val).render(configuration=self.toJson()))
if not status: if not status:
return False, msg, key return False, msg, key
except Exception as e: except Exception as e:
+1 -1
View File
@@ -13,5 +13,5 @@ sqlalchemy_utils==0.43.0
psycopg[binary]==3.3.6 psycopg[binary]==3.3.6
PyMySQL==1.2.3 PyMySQL==1.2.3
tzlocal==5.4.5 tzlocal==5.4.5
python-jose[cryptography]==3.5.0 python-jose==3.5.0
pydantic==2.14.1 pydantic==2.14.1
+6 -6
View File
@@ -2555,9 +2555,9 @@
} }
}, },
"node_modules/defu": { "node_modules/defu": {
"version": "6.1.7", "version": "6.1.4",
"resolved": "https://registry.npmjs.org/defu/-/defu-6.1.7.tgz", "resolved": "https://registry.npmmirror.com/defu/-/defu-6.1.4.tgz",
"integrity": "sha512-7z22QmUWiQ/2d0KkdYmANbRUVABpZ9SNYyH5vx6PZ+nE5bcC0l7uFvEfHlyld/HcGBFTL536ClDt3DEcSlEJAQ==", "integrity": "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/delayed-stream": { "node_modules/delayed-stream": {
@@ -3013,9 +3013,9 @@
} }
}, },
"node_modules/fflate": { "node_modules/fflate": {
"version": "0.8.3", "version": "0.8.2",
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz", "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz",
"integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==", "integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/filelist": { "node_modules/filelist": {
+26 -26
View File
@@ -1242,9 +1242,9 @@
} }
}, },
"node_modules/baseline-browser-mapping": { "node_modules/baseline-browser-mapping": {
"version": "2.11.33", "version": "2.10.34",
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.33.tgz", "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.34.tgz",
"integrity": "sha512-yiVKDX+qCMRKBE084lXvq9EcwFUhKZ2nU8TK1EQQuOgPNR/lmbGxXOeDdlGUqC2Zz11Cs9rk1d/8NfgBmlkt0w==", "integrity": "sha512-IMDedajPifLnHNY0X9n8hKxRTQ6/eTHwr5bDo04WnuqxyKw6LYtQywCuuqPZwhl3aBXMvQpJov42GLCwRRdQzw==",
"dev": true, "dev": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"bin": { "bin": {
@@ -1299,9 +1299,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/browserslist": { "node_modules/browserslist": {
"version": "4.29.4", "version": "4.28.2",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.4.tgz", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.2.tgz",
"integrity": "sha512-2TcbbiwXEq+N0kD36tykpCfyyQigUXmuwNQbnPp4Xk4PX9JOqVIKjJlIDjpH7uY6tmRGoAd+apeT1p60T8wsdA==", "integrity": "sha512-48xSriZYYg+8qXna9kwqjIVzuQxi+KYWp2+5nCYnYKPTr0LvD89Jqk2Or5ogxz0NUMfIjhh2lIUX/LyX9B4oIg==",
"dev": true, "dev": true,
"funding": [ "funding": [
{ {
@@ -1319,11 +1319,11 @@
], ],
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"baseline-browser-mapping": "^2.11.29", "baseline-browser-mapping": "^2.10.12",
"caniuse-lite": "^1.0.30001816", "caniuse-lite": "^1.0.30001782",
"electron-to-chromium": "^1.5.459", "electron-to-chromium": "^1.5.328",
"node-releases": "^2.0.59", "node-releases": "^2.0.36",
"update-browserslist-db": "^1.3.4" "update-browserslist-db": "^1.2.3"
}, },
"bin": { "bin": {
"browserslist": "cli.js" "browserslist": "cli.js"
@@ -1371,9 +1371,9 @@
} }
}, },
"node_modules/caniuse-lite": { "node_modules/caniuse-lite": {
"version": "1.0.30001819", "version": "1.0.30001793",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001819.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001793.tgz",
"integrity": "sha512-LFUqIIAwpzsIuevnKnsR9qnStBcgzPShTX61lBwN9uFkkf8o8zLiebEjbW8AYtZiF+1YKDWfdt/pWDtMuG8Xwg==", "integrity": "sha512-iwSsYWaCOoh26cV8NwNRViHlrfUvYsHDfRVcbtmw0Kg6PJIZZXwMkj1442FYLBGkeUf1juAsU3DTfxW579mrPA==",
"dev": true, "dev": true,
"funding": [ "funding": [
{ {
@@ -1581,9 +1581,9 @@
} }
}, },
"node_modules/electron-to-chromium": { "node_modules/electron-to-chromium": {
"version": "1.5.464", "version": "1.5.368",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.464.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.368.tgz",
"integrity": "sha512-nRa65aFge40viPAKxMKULIY8tcXKwKboJWNn4RoKwyWXJ6SP7BnrDGKUTzc64818jIciH0PK7LSF8QzZes19GA==", "integrity": "sha512-7RckJJK4uESJF9PxvfMWd3TGqIiieUTG4HxnKaKuIpGbcr+r2ZEB3g2gAhCP3Fqm42vJSzLfgab9eva/C4/XVw==",
"dev": true, "dev": true,
"license": "ISC" "license": "ISC"
}, },
@@ -1713,9 +1713,9 @@
} }
}, },
"node_modules/follow-redirects": { "node_modules/follow-redirects": {
"version": "1.16.2", "version": "1.16.0",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.2.tgz", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz",
"integrity": "sha512-/kVP2U8z596Ia0gwFrwyIeo74ta5aVmSeU1FfAUMAmcEP5EP7zydmag3SLiN64NaRKef3lxsq7i/g7ltJQDGow==", "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==",
"funding": [ "funding": [
{ {
"type": "individual", "type": "individual",
@@ -2431,9 +2431,9 @@
} }
}, },
"node_modules/node-releases": { "node_modules/node-releases": {
"version": "2.0.60", "version": "2.0.47",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.60.tgz", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.47.tgz",
"integrity": "sha512-OmO8+GM1JUZqXET720VrJCwkjUCXmCMQm0Z3UDDRbfNLHS4NEAvY60j5jiFv0tkKw2PNNlqOLhahVmwJIOLDIQ==", "integrity": "sha512-Uzmd6LXpouKo8EUK68IjH4+E01w/hXyV3R3g/geCJo+rXLNfh1xucB+LOzYEOQPSiUK3h/xZf0cQGcSsmyL2Og==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {
@@ -2928,9 +2928,9 @@
} }
}, },
"node_modules/update-browserslist-db": { "node_modules/update-browserslist-db": {
"version": "1.3.4", "version": "1.2.3",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.4.tgz", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz",
"integrity": "sha512-t8wonIOdQyOjtPd2VktlBu6QjTVTks6v8bSi7kd0r2Vll8TK1JYDZtRRdbmCHOAMphkZgrzK+L+vXK4pyZ8t4A==", "integrity": "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==",
"dev": true, "dev": true,
"funding": [ "funding": [
{ {
+101 -207
View File
@@ -5,17 +5,12 @@
#trap "kill $TOP_PID" #trap "kill $TOP_PID"
export TOP_PID=$$ export TOP_PID=$$
#------------------------------------------------------------------------------
# Configuration
#------------------------------------------------------------------------------
app_name="dashboard.py" app_name="dashboard.py"
app_official_name="WGDashboard" app_official_name="WGDashboard"
venv_python="./venv/bin/python3" venv_python="./venv/bin/python3"
venv_gunicorn="./venv/bin/gunicorn" venv_gunicorn="./venv/bin/gunicorn"
pythonExecutable="python3" pythonExecutable="python3"
frontend_dirs=("./static/app" "./static/client")
heavy_checkmark=$(printf "\xE2\x9C\x85") heavy_checkmark=$(printf "\xE2\x9C\x85")
heavy_crossmark=$(printf "\xE2\x9D\x8C") heavy_crossmark=$(printf "\xE2\x9D\x8C")
install=$(printf "\xF0\x9F\x92\xBF") install=$(printf "\xF0\x9F\x92\xBF")
@@ -35,10 +30,6 @@ fi
dashes='---------------------------------------------------------------------------------' dashes='---------------------------------------------------------------------------------'
equals='============================================================' equals='============================================================'
helpMsg="[WGDashboard] Please check ./log/install.txt for more details. For further assistance, please open a ticket on https://github.com/WGDashboard/WGDashboard/issues/new/choose, I'm more than happy to help :)" helpMsg="[WGDashboard] Please check ./log/install.txt for more details. For further assistance, please open a ticket on https://github.com/WGDashboard/WGDashboard/issues/new/choose, I'm more than happy to help :)"
#------------------------------------------------------------------------------
# Output helpers
#------------------------------------------------------------------------------
print_header(){ print_header(){
printf "=================================================================================\n" printf "=================================================================================\n"
printf "+ <WGDashboard> by Donald Zou - https://github.com/donaldzou +\n" printf "+ <WGDashboard> by Donald Zou - https://github.com/donaldzou +\n"
@@ -58,19 +49,6 @@ help () {
printf "=================================================================================\n" printf "=================================================================================\n"
} }
_logSection(){
{ printf "\n\n [%s] [%s] \n\n" "$1" "$(date)"; } >> ./log/install.txt
}
_unsupportedOS(){
printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS. With experimental support for Alpine Linux.\n" "$heavy_crossmark"
printf "%s\n" "$helpMsg"
kill $TOP_PID
}
#------------------------------------------------------------------------------
# Environment detection
#------------------------------------------------------------------------------
_check_and_set_venv(){ _check_and_set_venv(){
VIRTUAL_ENV="./venv" VIRTUAL_ENV="./venv"
if [ ! -d $VIRTUAL_ENV ]; then if [ ! -d $VIRTUAL_ENV ]; then
@@ -94,16 +72,15 @@ _determineOS(){
elif [ -f /etc/redhat-release ]; then elif [ -f /etc/redhat-release ]; then
OS="redhat" OS="redhat"
else else
_unsupportedOS printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS. With experimental support for Alpine Linux.\n" "$heavy_crossmark"
printf "%s\n" "$helpMsg"
kill $TOP_PID
fi fi
printf "[WGDashboard] OS: %s\n" "$OS" printf "[WGDashboard] OS: %s\n" "$OS"
} }
#------------------------------------------------------------------------------
# Python
#------------------------------------------------------------------------------
_installPython(){ _installPython(){
_logSection "Installing Python" { printf "\n\n [Installing Python] [%s] \n\n""$(date)"; } >> ./log/install.txt
printf "[WGDashboard] %s Installing Python\n" "$install" printf "[WGDashboard] %s Installing Python\n" "$install"
case "$OS" in case "$OS" in
ubuntu|debian|raspbian) ubuntu|debian|raspbian)
@@ -135,7 +112,7 @@ _installPython(){
} }
_installPythonVenv(){ _installPythonVenv(){
_logSection "Installing Python Venv" { printf "\n\n [Installing Python Venv] [%s] \n\n""$(date)"; } >> ./log/install.txt
printf "[WGDashboard] %s Installing Python Virtual Environment\n" "$install" printf "[WGDashboard] %s Installing Python Virtual Environment\n" "$install"
if [ "$pythonExecutable" = "python3" ]; then if [ "$pythonExecutable" = "python3" ]; then
case "$OS" in case "$OS" in
@@ -156,7 +133,9 @@ _installPythonVenv(){
{ echo "Python Virtual Environment is installed by default from version Python3.3"; printf "\n\n"; } &>> ./log/install.txt # https://wiki.archlinux.org/title/Python/Virtual_environment { echo "Python Virtual Environment is installed by default from version Python3.3"; printf "\n\n"; } &>> ./log/install.txt # https://wiki.archlinux.org/title/Python/Virtual_environment
;; ;;
*) *)
_unsupportedOS printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS. With experimental support for Alpine Linux.\n" "$heavy_crossmark"
printf "%s\n" "$helpMsg"
kill $TOP_PID
;; ;;
esac esac
else else
@@ -177,7 +156,7 @@ _installPythonVenv(){
} }
_installPythonPip(){ _installPythonPip(){
_logSection "Installing Python Pip" { printf "\n\n [Installing Python Pip] [%s] \n\n""$(date)"; } >> ./log/install.txt
if ! $pythonExecutable -m pip -h > /dev/null 2>&1 if ! $pythonExecutable -m pip -h > /dev/null 2>&1
then then
@@ -204,7 +183,9 @@ _installPythonPip(){
{ sudo pacman -Syu python-pip; printf "\n\n"; } &>> ./log/install.txt { sudo pacman -Syu python-pip; printf "\n\n"; } &>> ./log/install.txt
;; ;;
*) *)
_unsupportedOS printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS. With experimental support for Alpine Linux.\n" "$heavy_crossmark"
printf "%s\n" "$helpMsg"
kill $TOP_PID
;; ;;
esac esac
fi fi
@@ -219,82 +200,6 @@ _installPythonPip(){
fi fi
} }
_checkPythonVersion(){
version_pass=$($pythonExecutable -c 'import sys; print("1") if (sys.version_info.major == 3 and sys.version_info.minor >= 12) else print("0");')
version=$($pythonExecutable --version)
if [ $version_pass == "1" ]
then
printf "[WGDashboard] %s Found compatible version of Python. Will be using %s to install WGDashboard.\n" "$heavy_checkmark" "$($pythonExecutable --version)"
return;
elif python3.12 --version > /dev/null 2>&1
then
printf "[WGDashboard] %s Found Python 3.12. Will be using [python3.12] to install WGDashboard.\n" "$heavy_checkmark"
pythonExecutable="python3.12"
else
printf "[WGDashboard] %s Could not find a compatible version of Python. Current Python is %s.\n" "$heavy_crossmark" "$version"
printf "[WGDashboard] WGDashboard required Python 3.12 or above. Halting install now.\n"
kill $TOP_PID
fi
}
_determinePypiMirror(){
printf "[WGDashboard] %s Pinging list of recommended Python Package Index mirror\n" "$install"
urls=(
"https://pypi.org/simple/"
"https://pypi.tuna.tsinghua.edu.cn/simple/"
"https://pypi.mirrors.ustc.edu.cn/simple/"
"https://mirrors.aliyun.com/pypi/simple/"
"https://pypi.douban.com/simple/"
)
# Ping each mirror's hostname once and extract the RTT
index=1
printf " ---------------------------------------------------------\n"
for url in "${urls[@]}"; do
hostname=$(echo "$url" | awk -F/ '{print $3}')
rtt=$(ping -c 1 -W 1 "$hostname" 2>/dev/null | grep 'time=' | awk -F'time=' '{print $2}' | awk '{print $1}')
# Handle cases where the hostname is not reachable
if [ -z "$rtt" ]; then
rtt="9999"
printf " [%i] [FAILED] %s\n" "$index" "$url"
else
rtt=${rtt//.*/}
printf " [%i] %sms %s\n" "$index" "$rtt" "$url"
fi
rtthost[$index]=$rtt
index=$((index+1))
done
printf " ---------------------------------------------------------\n"
for i in "${!rtthost[@]}"; do
[[ -z ${rtthost[i]} ]] && continue # Skip unset or empty values
if [[ -z $min_val || ${rtthost[i]} -lt $min_val ]]; then
min_val=${rtthost[i]}
min_idx=$i
fi
done
min_idx=$((min_idx - 1))
printf " Which mirror you would like to use (Hit enter to use default)\n"
printf " Default is %s :" "${urls[$min_idx]}"
read -t ${msleep} -r choice
printf "\n"
if [[ -z "$choice" ]]; then
choice=$((min_idx + 1))
fi
if [[ "$choice" =~ ^[0-9]+$ ]] && (( choice >= 1 && choice <= ${#urls[@]} )); then
selected_url="${urls[choice-1]}"
printf "[WGDashboard] %s Will download Python packages from %s\n" "$heavy_checkmark" "$selected_url"
else
selected_url="${urls[0]}"
printf "[WGDashboard] %s Will download Python packages from %s\n" "$heavy_checkmark" "${urls[0]}"
fi
}
#------------------------------------------------------------------------------
# WireGuard
#------------------------------------------------------------------------------
_checkWireguard(){ _checkWireguard(){
if ! command -v wg > /dev/null 2>&1 || ! command -v wg-quick > /dev/null 2>&1 if ! command -v wg > /dev/null 2>&1 || ! command -v wg-quick > /dev/null 2>&1
then then
@@ -338,100 +243,81 @@ _checkWireguard(){
fi fi
} }
#------------------------------------------------------------------------------
# Frontend (Node.js) - Docker builds the frontend itself, so this is only for
# bare-metal installs.
#------------------------------------------------------------------------------ _checkPythonVersion(){
_installNode(){ version_pass=$($pythonExecutable -c 'import sys; print("1") if (sys.version_info.major == 3 and sys.version_info.minor >= 12) else print("0");')
_logSection "Installing Node.js" version=$($pythonExecutable --version)
printf "[WGDashboard] %s Installing Node.js and npm\n" "$install" if [ $version_pass == "1" ]
case "$OS" in then
ubuntu|debian|raspbian) printf "[WGDashboard] %s Found compatible version of Python. Will be using %s to install WGDashboard.\n" "$heavy_checkmark" "$($pythonExecutable --version)"
{ sudo apt update ; sudo apt-get install -y nodejs npm; printf "\n\n"; } &>> ./log/install.txt return;
;; elif python3.12 --version > /dev/null 2>&1
centos|fedora|redhat|rhel|almalinux|rocky) then
if command -v dnf &> /dev/null; then printf "[WGDashboard] %s Found Python 3.12. Will be using [python3.12] to install WGDashboard.\n" "$heavy_checkmark"
{ sudo dnf install -y nodejs npm; printf "\n\n"; } &>> ./log/install.txt pythonExecutable="python3.12"
else else
{ sudo yum install -y nodejs npm; printf "\n\n"; } &>> ./log/install.txt printf "[WGDashboard] %s Could not find a compatible version of Python. Current Python is %s.\n" "$heavy_crossmark" "$version"
printf "[WGDashboard] WGDashboard required Python 3.12 or above. Halting install now.\n"
kill $TOP_PID
fi fi
;;
alpine)
{ sudo apk update; sudo apk add nodejs npm --no-cache; printf "\n\n"; } &>> ./log/install.txt
;;
arch)
{ sudo pacman -Syu nodejs npm; printf "\n\n"; } &>> ./log/install.txt
;;
*)
_unsupportedOS
;;
esac
} }
# Vite requires Node.js ^20.19.0 || >=22.12.0 _determinePypiMirror(){
_isNodeVersionSupported(){ printf "[WGDashboard] %s Pinging list of recommended Python Package Index mirror\n" "$install"
local node_version major minor urls=(
node_version=$(node --version 2>/dev/null | sed 's/^v//') "https://pypi.org/simple/"
major=${node_version%%.*} "https://pypi.tuna.tsinghua.edu.cn/simple/"
minor=${node_version#*.} "https://pypi.mirrors.ustc.edu.cn/simple/"
minor=${minor%%.*} "https://mirrors.aliyun.com/pypi/simple/"
[[ "$major" =~ ^[0-9]+$ && "$minor" =~ ^[0-9]+$ ]] || return 1 "https://pypi.douban.com/simple/"
)
if (( major > 22 )); then return 0; fi # Function to extract hostname and ping it
if (( major == 22 && minor >= 12 )); then return 0; fi index=1
if (( major == 20 && minor >= 19 )); then return 0; fi printf " ---------------------------------------------------------\n"
return 1 for url in "${urls[@]}"; do
} # Extract the hostname from the URL
hostname=$(echo "$url" | awk -F/ '{print $3}')
_checkNode(){ # Ping the hostname once and extract the RTT
if ! command -v node > /dev/null 2>&1 || ! command -v npm > /dev/null 2>&1 rtt=$(ping -c 1 -W 1 "$hostname" 2>/dev/null | grep 'time=' | awk -F'time=' '{print $2}' | awk '{print $1}')
then # Handle cases where the hostname is not reachable
_installNode if [ -z "$rtt" ]; then
fi rtt="9999"
printf " [%i] [FAILED] %s\n" "$index" "$url"
if ! command -v node > /dev/null 2>&1 || ! command -v npm > /dev/null 2>&1
then
printf "[WGDashboard] %s Node.js and npm are still not installed, halting script now.\n" "$heavy_crossmark"
printf "%s\n" "$helpMsg"
kill $TOP_PID
elif ! _isNodeVersionSupported
then
printf "[WGDashboard] %s Found Node.js %s, but the frontend requires Node.js 20.19+ or 22.12+. Halting install now.\n" "$heavy_crossmark" "$(node --version)"
printf "%s\n" "$helpMsg"
kill $TOP_PID
else else
printf "[WGDashboard] %s Node.js %s and npm %s are installed\n" "$heavy_checkmark" "$(node --version)" "$(npm --version)" rtt=${rtt//.*/}
printf " [%i] %sms %s\n" "$index" "$rtt" "$url"
fi fi
} rtthost[$index]=$rtt
index=$((index+1))
_compileFrontend(){ done
_logSection "Compiling Frontend" printf " ---------------------------------------------------------\n"
_checkNode for i in "${!rtthost[@]}"; do
[[ -z ${rtthost[i]} ]] && continue # Skip unset or empty values
local dir if [[ -z $min_val || ${rtthost[i]} -lt $min_val ]]; then
for dir in "${frontend_dirs[@]}"; do min_val=${rtthost[i]}
printf "[WGDashboard] %s Compiling frontend in %s\n" "$install" "$dir" min_idx=$i
if ! ( cd "$dir" && npm ci && npm run build ) &>> ./log/install.txt
then
printf "[WGDashboard] %s Failed to compile frontend in %s, halting script now.\n" "$heavy_crossmark" "$dir"
printf "%s\n" "$helpMsg"
kill $TOP_PID
return 1
fi fi
done done
printf "[WGDashboard] %s Frontend is compiled\n" "$heavy_checkmark" min_idx=$((min_idx - 1))
}
#------------------------------------------------------------------------------ printf " Which mirror you would like to use (Hit enter to use default)\n"
# Install printf " Default is %s :" "${urls[$min_idx]}"
#------------------------------------------------------------------------------ read -t ${msleep} -r choice
_ensureFolder(){ printf "\n"
if [ ! -d "$1" ]
then if [[ -z "$choice" ]]; then
mkdir "$1" choice=$((min_idx + 1))
printf "[WGDashboard] %s Created ./%s folder\n" "$heavy_checkmark" "$1" fi
if [[ "$choice" =~ ^[0-9]+$ ]] && (( choice >= 1 && choice <= ${#urls[@]} )); then
selected_url="${urls[choice-1]}"
printf "[WGDashboard] %s Will download Python packages from %s\n" "$heavy_checkmark" "$selected_url"
else else
printf "[WGDashboard] %s Found existing ./%s folder\n" "$heavy_checkmark" "$1" selected_url="${urls[0]}"
printf "[WGDashboard] %s Will download Python packages from %s\n" "$heavy_checkmark" "${urls[0]}"
fi fi
} }
@@ -439,9 +325,29 @@ install_wgd(){
printf "[WGDashboard] Starting to install WGDashboard\n" printf "[WGDashboard] Starting to install WGDashboard\n"
_determineOS _determineOS
_ensureFolder "log" if [ ! -d "log" ]
_ensureFolder "download" then
_ensureFolder "db" mkdir "log"
printf "[WGDashboard] %s Created ./log folder\n" "$heavy_checkmark"
else
printf "[WGDashboard] %s Found existing ./log folder\n" "$heavy_checkmark"
fi
if [ ! -d "download" ]
then
mkdir "download"
printf "[WGDashboard] %s Created ./download folder\n" "$heavy_checkmark"
else
printf "[WGDashboard] %s Found existing ./download folder\n" "$heavy_checkmark"
fi
if [ ! -d "db" ]
then
mkdir "db"
printf "[WGDashboard] %s Created ./db folder\n" "$heavy_checkmark"
else
printf "[WGDashboard] %s Found existing ./db folder\n" "$heavy_checkmark"
fi
if ! python3 --version > /dev/null 2>&1 if ! python3 --version > /dev/null 2>&1
then then
@@ -456,7 +362,6 @@ install_wgd(){
_installPythonVenv _installPythonVenv
_installPythonPip _installPythonPip
_checkWireguard _checkWireguard
_compileFrontend
sudo chmod -R 755 /etc/wireguard/ sudo chmod -R 755 /etc/wireguard/
_check_and_set_venv _check_and_set_venv
@@ -466,6 +371,7 @@ install_wgd(){
printf "[WGDashboard] %s Installing latest Python dependencies\n" "$install" printf "[WGDashboard] %s Installing latest Python dependencies\n" "$install"
{ date; python3 -m pip install -r requirements.txt -i "$selected_url"; printf "\n\n"; } >> ./log/install.txt #This all works on the default installation. { date; python3 -m pip install -r requirements.txt -i "$selected_url"; printf "\n\n"; } >> ./log/install.txt #This all works on the default installation.
if [ ! -f "ssl-tls.ini" ] if [ ! -f "ssl-tls.ini" ]
then then
printf "[SSL/TLS]\ncertificate_path = \nprivate_key_path = \n" >> ssl-tls.ini printf "[SSL/TLS]\ncertificate_path = \nprivate_key_path = \n" >> ssl-tls.ini
@@ -473,14 +379,10 @@ install_wgd(){
else else
printf "[WGDashboard] %s Found existing ssl-tls.ini\n" "$heavy_checkmark" printf "[WGDashboard] %s Found existing ssl-tls.ini\n" "$heavy_checkmark"
fi fi
printf "[WGDashboard] %s WGDashboard installed successfully!\n" "$heavy_checkmark" printf "[WGDashboard] %s WGDashboard installed successfully!\n" "$heavy_checkmark"
printf "[WGDashboard] Enter ./wgd.sh start to start the dashboard\n" printf "[WGDashboard] Enter ./wgd.sh start to start the dashboard\n"
} }
#------------------------------------------------------------------------------
# Status / SSL
#------------------------------------------------------------------------------
check_wgd_status(){ check_wgd_status(){
if test -f "$PID_FILE"; then if test -f "$PID_FILE"; then
if ps aux | grep -v grep | grep $(cat ./gunicorn.pid) > /dev/null; then if ps aux | grep -v grep | grep $(cat ./gunicorn.pid) > /dev/null; then
@@ -505,9 +407,6 @@ certbot_renew_ssl () {
certbot renew --work-dir $cb_work_dir --config-dir $cb_config_dir certbot renew --work-dir $cb_work_dir --config-dir $cb_config_dir
} }
#------------------------------------------------------------------------------
# Start / Stop
#------------------------------------------------------------------------------
gunicorn_start () { gunicorn_start () {
printf "[WGDashboard] Starting WGDashboard with Gunicorn in the background.\n" printf "[WGDashboard] Starting WGDashboard with Gunicorn in the background.\n"
d=$(date '+%Y%m%d%H%M%S') d=$(date '+%Y%m%d%H%M%S')
@@ -563,9 +462,6 @@ start_wgd_debug() {
sudo "$venv_python" "$app_name" sudo "$venv_python" "$app_name"
} }
#------------------------------------------------------------------------------
# Update
#------------------------------------------------------------------------------
update_wgd() { update_wgd() {
_determineOS _determineOS
if ! python3 --version > /dev/null 2>&1 if ! python3 --version > /dev/null 2>&1
@@ -609,9 +505,7 @@ update_wgd() {
fi fi
} }
#------------------------------------------------------------------------------
# Entry point
#------------------------------------------------------------------------------
print_header print_header
if [ "$#" -lt 1 ]; then if [ "$#" -lt 1 ]; then
help help