1
0
mirror of https://github.com/donaldzou/WGDashboard.git synced 2024-11-04 15:00:23 +01:00
WGDashboard/README.md

403 lines
17 KiB
Markdown
Raw Normal View History

2021-05-14 00:00:40 +02:00
<hr>
2021-07-11 19:07:27 +02:00
<p align=center>Please provide your OS name and version if you can run the dashboard on it perfectly in <a href="https://github.com/donaldzou/wireguard-dashboard/issues/31">#31</a>, since I only tested on Ubuntu. Thank you!</p>
2021-05-14 00:00:40 +02:00
<hr>
2021-07-11 19:07:27 +02:00
2021-04-13 05:18:57 +02:00
<p align="center">
<img src="https://raw.githubusercontent.com/donaldzou/wireguard-dashboard/main/img/Group%202.png" width="128">
</p>
2021-04-06 04:41:55 +02:00
<h1 align="center"> Wireguard Dashboard</h1>
2021-04-13 04:28:30 +02:00
2021-04-07 18:15:45 +02:00
<p align="center">
<img src="http://ForTheBadge.com/images/badges/made-with-python.svg">
</p>
<p align="center">
2021-04-07 18:19:23 +02:00
<a href="https://github.com/donaldzou/wireguard-dashboard/releases/latest"><img src="https://img.shields.io/github/v/release/donaldzou/wireguard-dashboard"></a>
2021-04-07 18:15:45 +02:00
</p>
2021-05-05 23:25:23 +02:00
<p align="center">Monitoring WireGuard is not convinient, need to login into server and type <code>wg show</code>. That's why this platform is being created, to view all configurations and manage them in a easier way.</p>
2021-05-05 03:26:40 +02:00
2021-05-05 20:38:10 +02:00
## 📣 What's New: Version v2.2
- 🎉 **New Features**
2021-08-05 07:39:32 +02:00
- **QR Code**: You can add the private key in peer setting of your existed peer to create a QR code. Or just create a new one, dashboard will now be able to auto generate a private key and public key ;) Don't worry, all keys will be generated on your machine, and **will delete all key files after they got generated**. [❤️ in [#29](https://github.com/donaldzou/wireguard-dashboard/issues/15)]
- **Autostart on boot**: Added a tutorial on how to start the dashboard to on boot! Please read the [tutorial below](#autostart-wireguard-dashboard-on-boot). [❤️ in [#29](https://github.com/donaldzou/wireguard-dashboard/issues/29)]
- 🪚 **Bug Fixed**
- When there are comments in the wireguard config file, will cause the dashboard to crash.
- Used regex to search for config files.
2021-05-14 00:00:40 +02:00
<hr>
2021-08-04 00:06:43 +02:00
2021-08-04 00:06:22 +02:00
## Table of Content
2021-08-05 07:21:44 +02:00
- [💡 Features](#-features)
- [📝 Requirement](#-requirement)
- [🛠 Install](#-install)
- [🪜 Usage](#-usage)
- [Start/Stop/Restart Wireguard Dashboard](#startstoprestart-wireguard-dashboard)
- [Autostart Wireguard Dashboard on boot](#autostart-wireguard-dashboard-on-boot)
- [✂️ Dashboard Configuration](#%EF%B8%8F-dashboard-configuration)
- [Dashboard Configuration file](#dashboard-configuration-file)
- [Generating QR code](#generating-qr-code)
- [❓ How to update the dashboard?](#-how-to-update-the-dashboard)
- [⚠️ Update from v1.x.x](#%EF%B8%8F--update-from-v1xx)
- [🔍 Screenshot](#-screenshot)
- [⏰ Changelog](#--changelog)
- [🛒 Dependencies](#-dependencies)
- [✨ Contributors](#-contributors)
2021-04-07 23:25:21 +02:00
## 💡 Features
2021-04-03 03:12:46 +02:00
2021-05-05 03:26:40 +02:00
- Add peers for each WireGuard configuration
2021-05-05 20:38:10 +02:00
2021-05-05 03:26:40 +02:00
- Manage peer
2021-05-05 20:38:10 +02:00
2021-04-03 03:12:46 +02:00
- Delete peers
2021-05-05 20:38:10 +02:00
2021-04-03 03:12:46 +02:00
- And many more coming up! Welcome to contribute to this project!
2021-05-05 20:38:10 +02:00
2021-04-07 23:25:21 +02:00
## 📝 Requirement
2021-04-03 03:12:46 +02:00
2021-05-05 03:26:40 +02:00
- Ubuntu or Debian based OS, other might work, but haven't test yet. Tested on the following OS:
2021-08-05 07:07:10 +02:00
- [x] Ubuntu 18.04.1 LTS - 20.04.1 LTS
2021-08-04 00:45:40 +02:00
- [x] Debian GNU/Linux 10 (buster) [❤️ @[robchez](https://github.com/robchez)]
- [x] AlmaLinux 8.4 (Electric Cheetah) [❤️ @[barry-smithjr](https://github.com/)]
- [x] CentOS 7 [❤️ @[PrzemekSkw](https://github.com/PrzemekSkw)]
2021-07-11 19:07:27 +02:00
- [ ] If you have tested on other OS and it works perfectly please provide it to me in [#31](https://github.com/donaldzou/wireguard-dashboard/issues/31). Thank you!
2021-08-04 00:45:40 +02:00
2021-05-05 03:26:40 +02:00
- ‼️ Make sure you have **Wireguard** and **Wireguard-Tools (`wg-quick`)** installed.‼️ <a href="https://www.wireguard.com/install/">How to install?</a>
2020-10-18 08:09:14 +02:00
- Configuration files under **/etc/wireguard**
2021-04-07 23:25:21 +02:00
2021-07-02 20:31:33 +02:00
- **Note**:
- **For `[Interface]` in the `.conf` file, please make sure you have `SaveConfig = true` under `[Interface]`** (Bug mentioned in [#9](https://github.com/donaldzou/wireguard-dashboard/issues/9#issuecomment-852346481))
- **For peers, `PublicKey` & `AllowedIPs` is required.**
2021-04-07 21:58:00 +02:00
- Python 3.7+ & Pip3
2020-10-18 08:09:14 +02:00
2021-04-07 23:25:21 +02:00
## 🛠 Install
2021-07-11 19:07:27 +02:00
1. **Download Wireguard Dashboard**
2021-07-11 18:49:58 +02:00
2021-07-11 19:07:27 +02:00
```shell
2021-08-05 07:07:10 +02:00
$ git clone -b v2.2 https://github.com/donaldzou/Wireguard-Dashboard.git
2021-07-11 19:07:27 +02:00
2. **Install Python Dependencies**
2021-04-03 03:12:46 +02:00
2021-07-11 19:07:27 +02:00
```shell
$ cd Wireguard-Dashboard/src
$ python3 -m pip install -r requirements.txt
```
2021-04-03 03:12:46 +02:00
2021-07-11 19:07:27 +02:00
3. **Install & run Wireguard Dashboard**
2021-05-05 20:38:10 +02:00
2021-07-11 19:07:27 +02:00
```shell
$ sudo chmod -R 744 /etc/wireguard # Add read and execute permission of the wireguard config folder
$ sudo chmod u+x wgd.sh
$ ./wgd.sh start
```
**Note**:
> For [`pivpn`](https://github.com/pivpn/pivpn) user, please use `sudo ./wgd.sh start` to run if your current account does not have the permission to run `wg show` and `wg-quick`.
4. **Access dashboard**
Access your server with port `10086` ! e.g (http://your_server_ip:10086), continue to read to on how to change port and ip that dashboard is running with.
2021-05-05 20:38:10 +02:00
2021-05-05 03:26:40 +02:00
## 🪜 Usage
2021-08-04 00:45:40 +02:00
#### Start/Stop/Restart Wireguard Dashboard
2021-04-03 03:12:46 +02:00
2021-07-02 19:28:29 +02:00
2021-05-14 00:00:40 +02:00
```shell
2021-07-03 16:30:54 +02:00
$ cd Wireguard-Dashboard/src
-----------------------------
$ ./wgd.sh start # Start the dashboard in background
-----------------------------
$ ./wgd.sh debug # Start the dashboard in foreground (debug mode)
-----------------------------
$ ./wgd.sh stop # Stop the dashboard
-----------------------------
$ ./wgd.sh restart # Restart the dasboard
2021-07-02 20:31:33 +02:00
```
2020-10-18 08:09:14 +02:00
2021-08-04 00:45:40 +02:00
#### Autostart Wireguard Dashboard on boot
In the `src` folder, it contained a file called `wg-dashboard.service`, we can use this file to let our system to autostart the dashboard after reboot. The following has tested on Ubuntu 18.04.1 LTS, please don't hesitate to provide your system if you have tested the autostart on another system.
1. **Changing the directory to the dashboard's directory**
```bash
$ cd wireguard-dashboard/src
```
2. **Get the full path of the dashboard's directory**
```bash
$ pwd
#Output: /root/wireguard-dashboard/src
```
For me, my output is the one above, your's might be different since it depends on where you downloaded the dashboard. **Copy the the output to somewhere, we will need this in the next step.**
3. **Edit the service file**
```bash
$ nano wg-dashboard.service
```
You will see something like this:
```
[Unit]
After=netword.service
[Service]
WorkingDirectory=<your dashboard directory full path here>
ExecStart=/usr/bin/python3 <your dashboard directory full path here>/dashboard.py
Restart=always
[Install]
WantedBy=default.target
```
Now, we need to replace both `<your dashboard directory full path here>` to the one you just copied from step 2. After doing this, the file will become something like this:
```
[Unit]
After=netword.service
[Service]
WorkingDirectory=/root/wireguard-dashboard/src
ExecStart=/usr/bin/python3 /root/wireguard-dashboard/src/dashboard.py
Restart=always
[Install]
WantedBy=default.target
```
**Be aware that after the value of `WorkingDirectory`, it does not have a `/` (slash).** You can save the file with `control+x` and press `Y`.
4. **Copy the service file to systemd folder**
```bash
$ cp wg-dashboard.service /etc/systemd/system/wg-dashboard.service
```
To make sure you copy the file successfully, you can use this command `cat /etc/systemd/system/wg-dashboard.service` to see if it will output the file you just edited.
5. **Enable the service**
```bash
$ sudo chmod 664 /etc/systemd/system/wg-dashboard.service
$ sudo systemctl daemon-reload
$ sudo systemctl enable wg-dashboard.service
$ sudo systemctl start wg-dashboard.service # <-- To start the service
```
6. **Check if the service run correctly**
```bash
$ sudo systemctl status wg-dashboard.service
```
And you should see something like this
```bash
● wg-dashboard.service
Loaded: loaded (/etc/systemd/system/wg-dashboard.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-08-03 22:31:26 UTC; 4s ago
Main PID: 6602 (python3)
Tasks: 1 (limit: 453)
Memory: 26.1M
CGroup: /system.slice/wg-dashboard.service
└─6602 /usr/bin/python3 /root/wireguard-dashboard/src/dashboard.py
Aug 03 22:31:26 ubuntu-wg systemd[1]: Started wg-dashboard.service.
Aug 03 22:31:27 ubuntu-wg python3[6602]: * Serving Flask app "Wireguard Dashboard" (lazy loading)
Aug 03 22:31:27 ubuntu-wg python3[6602]: * Environment: production
Aug 03 22:31:27 ubuntu-wg python3[6602]: WARNING: This is a development server. Do not use it in a production deployment.
Aug 03 22:31:27 ubuntu-wg python3[6602]: Use a production WSGI server instead.
Aug 03 22:31:27 ubuntu-wg python3[6602]: * Debug mode: off
Aug 03 22:31:27 ubuntu-wg python3[6602]: * Running on all addresses.
Aug 03 22:31:27 ubuntu-wg python3[6602]: WARNING: This is a development server. Do not use it in a production deployment.
Aug 03 22:31:27 ubuntu-wg python3[6602]: * Running on http://0.0.0.0:10086/ (Press CTRL+C to quit)
```
If you see `Active:` followed by `active (running) since...` then it means it run correctly.
7. **Stop/Start/Restart the service**
```bash
$ sudo systemctl stop wg-dashboard.service # <-- To stop the service
$ sudo systemctl start wg-dashboard.service # <-- To start the service
$ sudo systemctl restart wg-dashboard.service # <-- To restart the service
```
8. And now you can reboot your system, and use the command at step 6 to see if it will auto start after the reboot. If you have any questions or problem, please report a bug.
2021-05-05 20:38:10 +02:00
⚠️ **For first time user please also read the next section.**
2021-05-05 03:26:40 +02:00
## ✂️ Dashboard Configuration
2021-08-05 07:07:10 +02:00
#### Dashboard Configuration file
2021-05-05 03:26:40 +02:00
Since version 2.0, Wireguard Dashboard will be using a configuration file called `wg-dashboard.ini`, (It will generate automatically after first time running the dashboard). More options will include in future versions, and for now it included the following config:
2021-07-11 19:07:27 +02:00
| | Description | Default Value |
| --------------- | ------------------------------------------------------------ | ------------------------ |
| **`[Account]`** | | |
| `username` | Dashboard login username | `admin` |
| `password` | Password, will be hash with SHA256 | `admin` hashed in SHA256 |
| **`[Server]`** | | |
| `wg_conf_path` | The path of all the Wireguard configurations | `/etc/wireguard` |
| `app_ip` | IP address the dashboard will run with | `0.0.0.0` |
| `app_port` | Port the the dashboard will run with | `10086` |
| `auth_req` | Does the dashboard need authentication to access | `true` |
| | If `auth_req = false` , user will not be access the **Setting** tab due to security consideration. **User can only change the file directly in system**. | |
| `version` | Dashboard Version | N/A |
<p align=center>Latest Version: V2.1</p>
2021-05-05 20:38:10 +02:00
All these settings will be able to configure within the dashboard in **Settings** on the sidebar, without changing the actual file. **Except `version` and `auth_req` due to security consideration.**
2021-05-05 03:26:40 +02:00
2021-08-05 07:07:10 +02:00
#### Generating QR code
Starting version 2.2, dashboard can now generate QR code for each peer. Here is a template of what each QR code encoded with:
```
[Interface]
PrivateKey = QWERTYUIOPO234567890YUSDAKFH10E1B12JE129U21=
Address = 0.0.0.0/32
DNS = 1.1.1.1
[Peer]
PublicKey = QWERTYUIOPO234567890YUSDAKFH10E1B12JE129U21=
AllowedIPs = 0.0.0.0/0
Endpoint = 0.0.0.0:51820
```
2021-08-05 07:39:32 +02:00
| | Description | Default Value |
| ----------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| **`[Interface]`** | | |
| `PrivateKey` | The private key of this peer | N/A |
| `Address` | The `allowed_ips` of your peer | N/A |
| `DNS` | The DNS server your peer will use | `1.1.1.1` - Cloud flare DNS, you can switch it to Google DNS - `8.8.8.8`, or use your own DNS, you can edit it later in the WireGuard phone app. |
| **`[Peer]`** | | |
| `PublicKey` | The public key of your server | N/A |
| `AllowedIPs` | IP ranges for which a peer will route traffic | `0.0.0.0/0` - Indicated a default route to send all internet and VPN traffic through that peer |
| `Endpoint` | Your wireguard server ip and port, the dashboard will search for your server's default interface's ip. | `<your server default interface ip>:<listen port>` |
2021-08-05 07:07:10 +02:00
2021-05-05 03:26:40 +02:00
## ❓ How to update the dashboard?
2021-07-02 19:23:04 +02:00
1. Change your directory to `wireguard-dashboard`
```
$ cd wireguard-dashboard
```
2. Get the newest version
```
2021-08-05 07:07:10 +02:00
$ sudo git pull https://github.com/donaldzou/wireguard-dashboard.git v2.2 --force
2021-07-02 19:23:04 +02:00
```
3. Update and install all python dependencies
```
$ python3 -m pip install -r requirements.txt
```
4. Start the dashboard
```
$ ./wgd.sh start
```
2021-07-11 18:49:58 +02:00
### ⚠️ **Update from v1.x.x**
2021-05-05 03:41:13 +02:00
2021-07-02 19:23:04 +02:00
1. Stop the dashboard if it is running.
2021-08-05 07:07:10 +02:00
2. You can use `git pull https://github.com/donaldzou/Wireguard-Dashboard.git v2.2` to get the new update inside `Wireguard-Dashboard` directory.
2021-07-02 19:23:04 +02:00
3. Proceed **Step 2 & 3** in the [Install](#-install) step down below.
2021-05-05 03:26:40 +02:00
2021-05-05 20:38:10 +02:00
## 🔍 Screenshot
2021-05-05 03:26:40 +02:00
2020-10-22 02:30:16 +02:00
![Index Image](https://github.com/donaldzou/Wireguard-Dashboard/raw/main/src/static/index.png)
2021-05-05 03:26:40 +02:00
<p align=center>Index Page</p>
![Signin Image](https://github.com/donaldzou/Wireguard-Dashboard/raw/main/src/static/signin.png)
<p align=center>Signin Page</p>
![Configuration Image](https://github.com/donaldzou/Wireguard-Dashboard/raw/main/src/static/configuration.png)
<p align=center>Configuration Page</p>
![Settings Image](https://github.com/donaldzou/Wireguard-Dashboard/raw/main/src/static/settings.png)
<p align=center>Settings Page</p>
2021-04-07 01:51:50 +02:00
2021-05-14 00:00:40 +02:00
2021-08-05 07:15:17 +02:00
## ⏰ Changelog
#### v2.1 - Jul 2, 2021
- Added **Ping** and **Traceroute** tools!
- Adjusted the calculation of data usage on each peers
- Added refresh interval of the dashboard
- Bug fixed when no configuration on fresh install ([#23](https://github.com/donaldzou/wireguard-dashboard/issues/23))
- Fixed crash when too many peers ([#22](https://github.com/donaldzou/wireguard-dashboard/issues/22))
#### v2.0 - May 5, 2021
- Added login function to dashboard
- ***I'm not using the most ideal way to store the username and password, feel free to provide a better way to do this if you any good idea!***
- Added a config file to the dashboard
- Dashboard config can be change within the **Setting** tab on the side bar
- Adjusted UI
- And much more!
#### v1.1.2 - Apr 3, 2021
- Resolved issue [#3](https://github.com/donaldzou/wireguard-dashboard/issues/3).
#### v1.1.1 - Apr 2, 2021
- Able to add a friendly name to each peer. Thanks [#2](https://github.com/donaldzou/wireguard-dashboard/issues/2) !
#### v1.0 - Dec 27, 2020
- Added the function to remove peers
2021-05-14 00:00:40 +02:00
## 🛒 Dependencies
- CSS/JS
- [Bootstrap](https://getbootstrap.com/docs/4.6/getting-started/introduction/) `v4.6.0`
- [Bootstrap Icon](https://icons.getbootstrap.com) `v1.4.0`
- [jQuery](https://jquery.com) `v3.5.1`
- Python
- [Flask](https://pypi.org/project/Flask/) `v1.1.2`
- [TinyDB](https://pypi.org/project/tinydb/) `v4.3.0`
- [ifcfg](https://pypi.org/project/ifcfg/) `v0.21`
- [icmplib](https://pypi.org/project/icmplib/) `v2.1.1`
2021-08-05 07:15:17 +02:00
## ✨ Contributors
2021-04-13 04:26:55 +02:00
2021-04-13 04:28:30 +02:00
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
2021-04-13 04:29:47 +02:00
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)
2021-04-13 04:28:30 +02:00
<!-- ALL-CONTRIBUTORS-BADGE:END -->
2021-04-13 04:26:55 +02:00
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://github.com/antonioag95"><img src="https://avatars.githubusercontent.com/u/30556866?v=4?s=100" width="100px;" alt=""/><br /><sub><b>antonioag95</b></sub></a><br /><a href="https://github.com/donaldzou/wireguard-dashboard/commits?author=antonioag95" title="Tests">⚠️</a> <a href="https://github.com/donaldzou/wireguard-dashboard/commits?author=antonioag95" title="Code">💻</a></td>
2021-04-13 04:29:47 +02:00
<td align="center"><a href="https://github.com/tonjo"><img src="https://avatars.githubusercontent.com/u/4726289?v=4?s=100" width="100px;" alt=""/><br /><sub><b>tonjo</b></sub></a><br /><a href="https://github.com/donaldzou/wireguard-dashboard/commits?author=tonjo" title="Code">💻</a></td>
2021-04-13 04:26:55 +02:00
</tr>
</table>
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
2021-04-13 04:28:30 +02:00
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
2021-05-05 03:26:40 +02:00