Browse Source

Add AmneziaWG support

pull/822/head
Viktor Yudov 3 years ago
parent
commit
03c0b1bd76
  1. 9
      .env
  2. 12
      Dockerfile
  3. 71
      README.md
  4. BIN
      assets/screenshot.png
  5. BIN
      assets/wg-easy.sketch
  6. 37
      docker-compose.yml
  7. 44
      src/lib/WireGuard.js
  8. 3
      src/www/img/_logo.svg
  9. BIN
      src/www/img/apple-touch-icon.png
  10. BIN
      src/www/img/favicon.ico
  11. BIN
      src/www/img/favicon.png
  12. BIN
      src/www/img/logo.png
  13. 33
      src/www/img/logo.svg
  14. 28
      src/www/index.html

9
.env

@ -0,0 +1,9 @@
WG_HOST=🚨YOUR_SERVER_IP
PASSWORD=🚨YOUR_ADMIN_PASSWORD
LANG=de
PORT=51821
WG_DEVICE=eth0
WG_PORT=51820
WG_DEFAULT_ADDRESS=10.8.0.x
WG_DEFAULT_DNS=1.1.1.1
WG_ALLOWED_IPS=0.0.0.0/0, ::/0

12
Dockerfile

@ -10,9 +10,15 @@ RUN npm ci --omit=dev
# Copy build result to a new image. # Copy build result to a new image.
# This saves a lot of disk space. # This saves a lot of disk space.
FROM docker.io/library/node:18-alpine # FROM docker.io/library/node:18-alpine
FROM amneziavpn/amnezia-wg:latest
COPY --from=build_node_modules /app /app COPY --from=build_node_modules /app /app
# Install Node.js
RUN apk add --no-cache \
nodejs \
npm
# Move node_modules one directory up, so during development # Move node_modules one directory up, so during development
# we don't have to mount it in a volume. # we don't have to mount it in a volume.
# This results in much faster reloading! # This results in much faster reloading!
@ -29,9 +35,7 @@ RUN npm i -g nodemon
RUN apk add --no-cache \ RUN apk add --no-cache \
dpkg \ dpkg \
dumb-init \ dumb-init \
iptables \ iptables
iptables-legacy \
wireguard-tools
# Use iptables-legacy # Use iptables-legacy
RUN update-alternatives --install /sbin/iptables iptables /sbin/iptables-legacy 10 --slave /sbin/iptables-restore iptables-restore /sbin/iptables-legacy-restore --slave /sbin/iptables-save iptables-save /sbin/iptables-legacy-save RUN update-alternatives --install /sbin/iptables iptables /sbin/iptables-legacy 10 --slave /sbin/iptables-restore iptables-restore /sbin/iptables-legacy-restore --slave /sbin/iptables-save iptables-save /sbin/iptables-legacy-save

71
README.md

@ -1,12 +1,6 @@
# WireGuard Easy # AmnewziaWG Easy
[![Build & Publish Docker Image to Docker Hub](https://github.com/wg-easy/wg-easy/actions/workflows/deploy.yml/badge.svg?branch=production)](https://github.com/wg-easy/wg-easy/actions/workflows/deploy.yml) You have found the easiest way to install & manage AmneziaWG on any Linux host!
[![Lint](https://github.com/wg-easy/wg-easy/actions/workflows/lint.yml/badge.svg?branch=master)](https://github.com/wg-easy/wg-easy/actions/workflows/lint.yml)
![Docker](https://img.shields.io/docker/pulls/weejewel/wg-easy.svg)
[![Sponsor](https://img.shields.io/github/sponsors/weejewel)](https://github.com/sponsors/WeeJeWel)
![GitHub Stars](https://img.shields.io/github/stars/wg-easy/wg-easy)
You have found the easiest way to install & manage WireGuard on any Linux host!
<p align="center"> <p align="center">
<img src="./assets/screenshot.png" width="802" /> <img src="./assets/screenshot.png" width="802" />
@ -14,10 +8,9 @@ You have found the easiest way to install & manage WireGuard on any Linux host!
## Features ## Features
* All-in-one: WireGuard + Web UI. * All-in-one: AmneziaWG + Web UI.
* Easy installation, simple to use. * Easy installation, simple to use.
* List, create, edit, delete, enable & disable clients. * List, create, edit, delete, enable & disable clients.
* Show a client's QR code.
* Download a client's configuration file. * Download a client's configuration file.
* Statistics for which clients are connected. * Statistics for which clients are connected.
* Tx/Rx charts for each connected client. * Tx/Rx charts for each connected client.
@ -26,7 +19,6 @@ You have found the easiest way to install & manage WireGuard on any Linux host!
## Requirements ## Requirements
* A host with a kernel that supports WireGuard (all modern kernels).
* A host with Docker installed. * A host with Docker installed.
## Installation ## Installation
@ -43,38 +35,21 @@ $ exit
And log in again. And log in again.
### 2. Run WireGuard Easy ### 2. Set environment variables
To automatically install & run wg-easy, simply run:
<pre>
$ docker run -d \
--name=wg-easy \
-e LANG=de \
-e WG_HOST=<b>🚨YOUR_SERVER_IP</b> \
-e PASSWORD=<b>🚨YOUR_ADMIN_PASSWORD</b> \
-v ~/.wg-easy:/etc/wireguard \
-p 51820:51820/udp \
-p 51821:51821/tcp \
--cap-add=NET_ADMIN \
--cap-add=SYS_MODULE \
--sysctl="net.ipv4.conf.all.src_valid_mark=1" \
--sysctl="net.ipv4.ip_forward=1" \
--restart unless-stopped \
ghcr.io/wg-easy/wg-easy
</pre>
> 💡 Replace `YOUR_SERVER_IP` with your WAN IP, or a Dynamic DNS hostname.
>
> 💡 Replace `YOUR_ADMIN_PASSWORD` with a password to log in on the Web UI.
The Web UI will now be available on `http://0.0.0.0:51821`. In [.env](.env) set the following environment variables:
- Replace `YOUR_SERVER_IP` with your WAN IP, or a Dynamic DNS hostname.
- Replace `YOUR_ADMIN_PASSWORD` with a password to log in on the Web UI.
> 💡 Your configuration files will be saved in `~/.wg-easy` ### 3. Build & run the Docker image
### 3. Sponsor ```bash
$ docker-compose up -d
```
Are you enjoying this project? [Buy Emile a beer!](https://github.com/sponsors/WeeJeWel) 🍻 The Web UI will now be available on `http://0.0.0.0:51821`.
> 💡 Your configuration files will be saved in `~/.amnezia-wg-easy`
## Options ## Options
@ -100,21 +75,3 @@ These options can be configured by setting environment variables using `-e KEY="
> If you change `WG_PORT`, make sure to also change the exposed port. > If you change `WG_PORT`, make sure to also change the exposed port.
## Updating
To update to the latest version, simply run:
```bash
docker stop wg-easy
docker rm wg-easy
docker pull ghcr.io/wg-easy/wg-easy
```
And then run the `docker run -d \ ...` command above again.
## Common Use Cases
* [Using WireGuard-Easy with Pi-Hole](https://github.com/wg-easy/wg-easy/wiki/Using-WireGuard-Easy-with-Pi-Hole)
* [Using WireGuard-Easy with nginx/SSL](https://github.com/wg-easy/wg-easy/wiki/Using-WireGuard-Easy-with-nginx-SSL)
For less common or specific edge-case scenarios, please refer to the detailed information provided in the [Wiki](https://github.com/wg-easy/wg-easy/wiki).

BIN
assets/screenshot.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 65 KiB

BIN
assets/wg-easy.sketch

Binary file not shown.

37
docker-compose.yml

@ -3,35 +3,16 @@ volumes:
etc_wireguard: etc_wireguard:
services: services:
wg-easy: amnezia-wg-easy:
environment: env_file:
# Change Language: - .env
# (Supports: en, ru, tr, no, pl, fr, de) build: .
- LANG=de container_name: amnezia-wg-easy
# ⚠️ Required:
# Change this to your host's public address
- WG_HOST=raspberrypi.local
# Optional:
# - PASSWORD=foobar123
# - WG_PORT=51820
# - WG_DEFAULT_ADDRESS=10.8.0.x
# - WG_DEFAULT_DNS=1.1.1.1
# - WG_MTU=1420
# - WG_ALLOWED_IPS=192.168.15.0/24, 10.0.1.0/24
# - WG_PERSISTENT_KEEPALIVE=25
# - WG_PRE_UP=echo "Pre Up" > /etc/wireguard/pre-up.txt
# - WG_POST_UP=echo "Post Up" > /etc/wireguard/post-up.txt
# - WG_PRE_DOWN=echo "Pre Down" > /etc/wireguard/pre-down.txt
# - WG_POST_DOWN=echo "Post Down" > /etc/wireguard/post-down.txt
image: ghcr.io/wg-easy/wg-easy
container_name: wg-easy
volumes: volumes:
- etc_wireguard:/etc/wireguard - ~/.amnezia-wg-easy:/etc/wireguard
ports: ports:
- "51820:51820/udp" - "${WG_PORT}:51820/udp"
- "51821:51821/tcp" - "${PORT}:${PORT}/tcp"
restart: unless-stopped restart: unless-stopped
cap_add: cap_add:
- NET_ADMIN - NET_ADMIN
@ -39,3 +20,5 @@ services:
sysctls: sysctls:
- net.ipv4.ip_forward=1 - net.ipv4.ip_forward=1
- net.ipv4.conf.all.src_valid_mark=1 - net.ipv4.conf.all.src_valid_mark=1
devices:
- /dev/net/tun:/dev/net/tun

44
src/lib/WireGuard.js

@ -45,16 +45,40 @@ module.exports = class WireGuard {
const publicKey = await Util.exec(`echo ${privateKey} | wg pubkey`, { const publicKey = await Util.exec(`echo ${privateKey} | wg pubkey`, {
log: 'echo ***hidden*** | wg pubkey', log: 'echo ***hidden*** | wg pubkey',
}); });
const getRandomInt = (min, max) => min + Math.floor(Math.random() * (max - min));
const getRandomJunkSize = () => getRandomInt(15, 150)
const getRandomHeader = () => getRandomInt(1, 2_147_483_647)
const address = WG_DEFAULT_ADDRESS.replace('x', '1'); const address = WG_DEFAULT_ADDRESS.replace('x', '1');
const jc = getRandomInt(3, 10);
const jmin = 50;
const jmax = 1000;
const s1 = getRandomJunkSize();
const s2 = getRandomJunkSize();
const h1 = getRandomHeader();
const h2 = getRandomHeader();
const h3 = getRandomHeader();
const h4 = getRandomHeader();
config = { config = {
server: { server: {
privateKey, privateKey,
publicKey, publicKey,
address, address,
jc,
jmin,
jmax,
s1,
s2,
h1,
h2,
h3,
h4,
}, },
clients: {}, clients: {},
}; };
debug('Configuration generated.'); debug('Configuration generated.');
} }
@ -100,6 +124,15 @@ PreUp = ${WG_PRE_UP}
PostUp = ${WG_POST_UP} PostUp = ${WG_POST_UP}
PreDown = ${WG_PRE_DOWN} PreDown = ${WG_PRE_DOWN}
PostDown = ${WG_POST_DOWN} PostDown = ${WG_POST_DOWN}
Jc = ${config.server.jc}
Jmin = ${config.server.jmin}
Jmax = ${config.server.jmax}
S1 = ${config.server.s1}
S2 = ${config.server.s2}
H1 = ${config.server.h1}
H2 = ${config.server.h2}
H3 = ${config.server.h3}
H4 = ${config.server.h4}
`; `;
for (const [clientId, client] of Object.entries(config.clients)) { for (const [clientId, client] of Object.entries(config.clients)) {
@ -198,9 +231,18 @@ AllowedIPs = ${client.address}/32`;
return `[Interface] return `[Interface]
PrivateKey = ${client.privateKey} PrivateKey = ${client.privateKey}
Address = ${client.address}/24 Address = ${client.address}
${WG_DEFAULT_DNS ? `DNS = ${WG_DEFAULT_DNS}\n` : ''}\ ${WG_DEFAULT_DNS ? `DNS = ${WG_DEFAULT_DNS}\n` : ''}\
${WG_MTU ? `MTU = ${WG_MTU}\n` : ''}\ ${WG_MTU ? `MTU = ${WG_MTU}\n` : ''}\
Jc = ${config.server.jc}
Jmin = ${config.server.jmin}
Jmax = ${config.server.jmax}
S1 = ${config.server.s1}
S2 = ${config.server.s2}
H1 = ${config.server.h1}
H2 = ${config.server.h2}
H3 = ${config.server.h3}
H4 = ${config.server.h4}
[Peer] [Peer]
PublicKey = ${config.server.publicKey} PublicKey = ${config.server.publicKey}

3
src/www/img/_logo.svg

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.0 KiB

BIN
src/www/img/apple-touch-icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 43 KiB

BIN
src/www/img/favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
src/www/img/favicon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

BIN
src/www/img/logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

33
src/www/img/logo.svg

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 28 KiB

28
src/www/index.html

@ -5,7 +5,7 @@
<title>WireGuard</title> <title>WireGuard</title>
<link href="./css/app.css" rel="stylesheet"> <link href="./css/app.css" rel="stylesheet">
<link rel="manifest" href="./manifest.json"> <link rel="manifest" href="./manifest.json">
<link rel="icon" type="image/png" href="./img/favicon.png"> <link rel="icon" href="img/favicon.ico" sizes="any">
<link rel="apple-touch-icon" href="./img/apple-touch-icon.png"> <link rel="apple-touch-icon" href="./img/apple-touch-icon.png">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
@ -35,8 +35,8 @@
</svg> </svg>
</span> </span>
<h1 class="text-4xl dark:text-neutral-200 font-medium mt-2 mb-2"> <h1 class="text-4xl dark:text-neutral-200 font-medium mt-2 mb-2">
<img src="./img/logo.png" width="32" class="inline align-middle dark:bg" /> <img src="./img/logo.svg" width="60" class="inline align-middle dark:bg" />
<span class="align-middle">WireGuard</span> <span class="align-middle">AmneziaWG</span>
</h1> </h1>
<h2 class="text-sm text-gray-400 dark:text-neutral-400 mb-10"></h2> <h2 class="text-sm text-gray-400 dark:text-neutral-400 mb-10"></h2>
@ -212,18 +212,6 @@
<div class="rounded-full w-4 h-4 m-1 bg-white"></div> <div class="rounded-full w-4 h-4 m-1 bg-white"></div>
</div> </div>
<!-- Show QR-->
<button
class="align-middle bg-gray-100 dark:bg-neutral-600 dark:text-neutral-300 hover:bg-red-800 dark:hover:bg-red-800 hover:text-white dark:hover:text-white p-2 rounded transition"
:title="$t('showQR')" @click="qrcode = `./api/wireguard/client/${client.id}/qrcode.svg`">
<svg class="w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M16 20h4M4 12h4m12 0h.01M5 8h2a1 1 0 001-1V5a1 1 0 00-1-1H5a1 1 0 00-1 1v2a1 1 0 001 1zm12 0h2a1 1 0 001-1V5a1 1 0 00-1-1h-2a1 1 0 00-1 1v2a1 1 0 001 1zM5 20h2a1 1 0 001-1v-2a1 1 0 00-1-1H5a1 1 0 00-1 1v2a1 1 0 001 1z" />
</svg>
</button>
<!-- Download Config --> <!-- Download Config -->
<a :href="'./api/wireguard/client/' + client.id + '/configuration'" download <a :href="'./api/wireguard/client/' + client.id + '/configuration'" download
class="align-middle inline-block bg-gray-100 dark:bg-neutral-600 dark:text-neutral-300 hover:bg-red-800 dark:hover:bg-red-800 hover:text-white dark:hover:text-white p-2 rounded transition" class="align-middle inline-block bg-gray-100 dark:bg-neutral-600 dark:text-neutral-300 hover:bg-red-800 dark:hover:bg-red-800 hover:text-white dark:hover:text-white p-2 rounded transition"
@ -440,8 +428,8 @@
<div v-if="authenticated === false"> <div v-if="authenticated === false">
<h1 class="text-4xl font-medium my-16 text-gray-700 dark:text-neutral-200 text-center"> <h1 class="text-4xl font-medium my-16 text-gray-700 dark:text-neutral-200 text-center">
<img src="./img/logo.png" width="32" class="inline align-middle dark:bg" /> <img src="./img/logo.svg" width="60" class="inline align-middle dark:bg" />
<span class="align-middle">WireGuard</span> <span class="align-middle">AmneziaWG</span>
</h1> </h1>
<form @submit="login" <form @submit="login"
@ -490,12 +478,6 @@
</div> </div>
<p v-cloak class="text-center m-10 text-gray-300 dark:text-neutral-600 text-xs"> <a class="hover:underline" target="_blank"
href="https://github.com/wg-easy/wg-easy">WireGuard Easy</a> © 2021-2024 by <a class="hover:underline" target="_blank"
href="https://emilenijssen.nl/?ref=wg-easy">Emile Nijssen</a> is licensed under <a class="hover:underline" target="_blank"
href="http://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a> · <a class="hover:underline"
href="https://github.com/sponsors/WeeJeWel" target="_blank">{{$t("donate")}}</a></p>
</div> </div>
<script src="./js/vendor/vue.min.js"></script> <script src="./js/vendor/vue.min.js"></script>

Loading…
Cancel
Save