From 91832c8e208f6d8c618371b72cddc0bbb0309f00 Mon Sep 17 00:00:00 2001 From: Emile Nijssen Date: Tue, 13 Jul 2021 21:39:45 +0200 Subject: [PATCH] wip --- .github/workflows/deploy.yml | 7 +- README.md | 11 + package.json | 8 - src/config.js | 3 + src/lib/Server.js | 5 + src/package.json | 1 + src/www/index.html | 758 ++++++++++++++++++----------------- src/www/js/api.js | 7 + src/www/js/app.js | 28 ++ 9 files changed, 449 insertions(+), 379 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7cbfd6b..46636e5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -35,10 +35,7 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} # Set environment variables - - run: echo GH_BRANCH=${GITHUB_REF#refs/heads/} >> $GITHUB_ENV - - run: echo VERSION=$(cat package.json | jq -r .version) >> $GITHUB_ENV - - run: echo DOCKER_TAGS=$(cat package.json | jq -r .docker[\"$GH_BRANCH\"].tags) >> $GITHUB_ENV - - run: echo Branch ${{ env.GH_BRANCH }}, Tags ${{ env.DOCKER_TAGS }} + - run: echo RELEASE=$(cat ./src/package.json | jq -r .release) >> $GITHUB_ENV # Build & Publish - name: Build & Publish Docker Image @@ -46,4 +43,4 @@ jobs: with: push: true platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 - tags: weejewel/wg-easy:v${{ env.VERSION }}, weejewel/wg-easy:${{ env.DOCKER_TAGS }} + tags: weejewel/wg-easy:latest, weejewel/wg-easy:${{ env.RELEASE }} diff --git a/README.md b/README.md index 63c0469..3dce467 100644 --- a/README.md +++ b/README.md @@ -80,3 +80,14 @@ These options can be configured in `docker-compose.yml` under `environment`. | `WG_ALLOWED_IPS` | `0.0.0.0/0, ::/0` | `192.168.15.0/24, 10.0.1.0/24` | Allowed IPs clients will use | > If you change `WG_PORT`, make sure to also change the exposed port. + +# Updating + +To update to the latest version, run: + +```bash +docker-compose down +docker-compose pull +docker-compose up --detach --remove-orphans +docker image prune +``` \ No newline at end of file diff --git a/package.json b/package.json index 7a76c53..20f2858 100644 --- a/package.json +++ b/package.json @@ -4,13 +4,5 @@ "build": "docker build --tag wg-easy .", "serve": "docker-compose -f docker-compose.yml -f docker-compose.dev.yml up", "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" - }, - "docker": { - "production": { - "tags": "latest" - }, - "staging": { - "tags": "beta" - } } } \ No newline at end of file diff --git a/src/config.js b/src/config.js index 8412344..c60d25b 100644 --- a/src/config.js +++ b/src/config.js @@ -1,5 +1,8 @@ 'use strict'; +const { release } = require('./package.json'); + +module.exports.RELEASE = release; module.exports.PORT = process.env.PORT || 51821; module.exports.PASSWORD = process.env.PASSWORD; module.exports.WG_PATH = process.env.WG_PATH || '/etc/wireguard/'; diff --git a/src/lib/Server.js b/src/lib/Server.js index 0f1c0ed..cf6b26e 100644 --- a/src/lib/Server.js +++ b/src/lib/Server.js @@ -12,6 +12,7 @@ const WireGuard = require('../services/WireGuard'); const { PORT, + RELEASE, PASSWORD, } = require('../config'); @@ -29,6 +30,10 @@ module.exports = class Server { saveUninitialized: true, })) + .get('/api/release', (Util.promisify(async () => { + return RELEASE; + }))) + // Authentication .get('/api/session', Util.promisify(async req => { const requiresPassword = !!process.env.PASSWORD; diff --git a/src/package.json b/src/package.json index f2b6519..0acd348 100644 --- a/src/package.json +++ b/src/package.json @@ -1,4 +1,5 @@ { + "release": 2, "name": "wg-easy", "version": "1.0.0", "description": "", diff --git a/src/www/index.html b/src/www/index.html index f8a955a..56d29eb 100644 --- a/src/www/index.html +++ b/src/www/index.html @@ -12,101 +12,94 @@ -
-
- - Logout - - - - -

- - WireGuard -

-

-
-
-
-

Clients

-
-
- +
+ +
+ +
+ + Logout + + + + +

+ + WireGuard +

+

+ +
+
+
+

There is an update available!

+

{{latestRelease.changelog}}

+
+ + + Update → +
-
-
-
- - - - - -
-
-
-
-
- +
+
- -
+

Clients

+
+
+ +
+
- - - {{client.name}} +
+
+
+ + + + - - - - - - +
+
+
+
- -
- - - +
+ +
- - {{client.address}} + + {{client.name}} - - - - - - · - - - - {{client.transferTx | bytes}} - - - - - · - - - - {{client.transferRx | bytes}} - - - - - · {{new Date(client.latestHandshakeAt) | timeago}} - -
-
- -
-
- - -
-
-
-
-
- - + +
- - - - - - + + - - + + + {{client.address}} + + + + + + + + + + + + · + + + + {{client.transferTx | bytes}} + + + + + · + + + + {{client.transferRx | bytes}} + + + + + · {{new Date(client.latestHandshakeAt) | timeago}} + +
-
+
+
+ + +
+
+
+
+
+
+ + + + + + + + + + + + + +
+
+ +
+
+

There are no clients yet.

+ +

+
+
+ + + + + +
-
-

There are no clients yet.

- -

+ +
-
+
+ + +
+
+ + + + + + + +
+
+ + +
+
+ + + + + + + +
+
+
+ +
+

WireGuard

+ +
+ +
+ + + +
+ + + +
-
+ + + +
- -
-
-
- - -
-
+
+ + + + + + +
- -
-
- - - - - - - -
-
- - -
-
- - - - - - - -
-
-
- -
-

WireGuard

- -
- -
- - - -
- - - - - - -
-
- -
- - - - - - -

Made by Emile Nijssen · Donate · GitHub

diff --git a/src/www/js/api.js b/src/www/js/api.js index 7fbf3b6..accbb57 100644 --- a/src/www/js/api.js +++ b/src/www/js/api.js @@ -29,6 +29,13 @@ class API { return json; } + async getRelease() { + return this.call({ + method: 'get', + path: '/release', + }); + } + async getSession() { return this.call({ method: 'get', diff --git a/src/www/js/app.js b/src/www/js/app.js index e0e48c9..97a50a3 100644 --- a/src/www/js/app.js +++ b/src/www/js/app.js @@ -22,6 +22,9 @@ new Vue({ clientEditAddress: null, clientEditAddressId: null, qrcode: null, + + currentRelease: null, + latestRelease: null, }, methods: { dateTime: value => { @@ -155,5 +158,30 @@ new Vue({ setInterval(() => { this.refresh().catch(console.error); }, 1000); + + Promise.resolve().then(async () => { + const currentRelease = await this.api.getRelease(); + const latestRelease = await fetch('https://weejewel.github.io/wg-easy/changelog.json') + .then(res => res.json()) + .then(releases => { + const releasesArray = Object.entries(releases).map(([version, changelog]) => ({ + version: parseInt(version, 10), + changelog, + })); + releasesArray.sort((a, b) => { + return b.version - a.version; + }); + + return releasesArray[0]; + }); + + console.log(`Current Release: ${currentRelease}`); + console.log(`Latest Release: ${latestRelease.version}`); + + if (currentRelease >= latestRelease.version) return; + + this.currentRelease = currentRelease; + this.latestRelease = latestRelease; + }).catch(console.error); }, });