From 42bbfbe53838d7ae9b1f1172afcb86adce33ed8e Mon Sep 17 00:00:00 2001 From: Donald Cheng Hong Zou Date: Tue, 3 Aug 2021 18:45:40 -0400 Subject: [PATCH 01/14] v2.2-beta update --- README.md | 146 +++++++++++++++++++++++++++++++++++---- src/dashboard.py | 2 +- src/wg-dashboard.service | 11 +++ 3 files changed, 145 insertions(+), 14 deletions(-) create mode 100644 src/wg-dashboard.service diff --git a/README.md b/README.md index fcb4a84..4404d5a 100644 --- a/README.md +++ b/README.md @@ -29,14 +29,14 @@ ## Table of Content -- [πŸ’‘Features](https://github.com/donaldzou/wireguard-dashboard#-features) -- [πŸ“ Requirement](https://github.com/donaldzou/wireguard-dashboard#-requirement) -- [πŸ›  Install](https://github.com/donaldzou/wireguard-dashboard#-install) -- [πŸͺœ Usage](https://github.com/donaldzou/wireguard-dashboard#-usage) -- [βœ‚οΈ Dashboard Configuration](https://github.com/donaldzou/wireguard-dashboard#%EF%B8%8F-dashboard-configuration) -- [❓How to update the dashboard?](https://github.com/donaldzou/wireguard-dashboard#-how-to-update-the-dashboard) - - [⚠️ Update from v1.x.x](https://github.com/donaldzou/wireguard-dashboard#%EF%B8%8F--update-from-v1xx) -- [πŸ” Screenshot](https://github.com/donaldzou/wireguard-dashboard#-screenshot) +- [πŸ’‘ Features](https://github.com/donaldzou/wireguard-dashboard#-features) +- [πŸ“ Requirement](https://github.com/donaldzou/wireguard-dashboard#-requirement) +- [πŸ›  Install](https://github.com/donaldzou/wireguard-dashboard#-install) +- [πŸͺœ Usage](https://github.com/donaldzou/wireguard-dashboard#-usage) +- [βœ‚οΈ Dashboard Configuration](https://github.com/donaldzou/wireguard-dashboard#%EF%B8%8F-dashboard-configuration) +- [❓ How to update the dashboard?](https://github.com/donaldzou/wireguard-dashboard#-how-to-update-the-dashboard) + - [⚠️ Update from v1.x.x](https://github.com/donaldzou/wireguard-dashboard#%EF%B8%8F--update-from-v1xx) +- [πŸ” Screenshot](https://github.com/donaldzou/wireguard-dashboard#-screenshot) ## πŸ’‘ Features @@ -48,14 +48,17 @@ - And many more coming up! Welcome to contribute to this project! - ## πŸ“ Requirement - Ubuntu or Debian based OS, other might work, but haven't test yet. Tested on the following OS: - [x] Ubuntu 18.04.1 LTS + - [x] Ubuntu 20.04.1 LTS + - [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)] - [ ] 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! - + - ‼️ Make sure you have **Wireguard** and **Wireguard-Tools (`wg-quick`)** installed.‼️ How to install? - Configuration files under **/etc/wireguard** @@ -64,8 +67,6 @@ - **For peers, `PublicKey` & `AllowedIPs` is required.** - Python 3.7+ & Pip3 - - ## πŸ›  Install 1. **Download Wireguard Dashboard** @@ -96,7 +97,7 @@ ## πŸͺœ Usage -**1. Start/Stop/Restart Wireguard Dashboard** +#### Start/Stop/Restart Wireguard Dashboard ```shell @@ -111,6 +112,125 @@ $ ./wgd.sh stop # Stop the dashboard $ ./wgd.sh restart # Restart the dasboard ``` + + +#### 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= + ExecStart=/usr/bin/python3 /dashboard.py + Restart=always + + + [Install] + WantedBy=default.target + ``` + + Now, we need to replace both `` 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. + ⚠️ **For first time user please also read the next section.** ## βœ‚οΈ Dashboard Configuration diff --git a/src/dashboard.py b/src/dashboard.py index 87280dd..c59e33d 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -70,7 +70,7 @@ def read_conf_file(config_name): } peers_start = 0 for i in range(len(file)): - if not is_match("^#(.*)",file[i]): + if not is_match("#(.*)",file[i]): if file[i] == "[Peer]": peers_start = i break diff --git a/src/wg-dashboard.service b/src/wg-dashboard.service new file mode 100644 index 0000000..9a596df --- /dev/null +++ b/src/wg-dashboard.service @@ -0,0 +1,11 @@ +[Unit] +After=netword.service + +[Service] +WorkingDirectory= +ExecStart=/usr/bin/python3 dashboard.py +Restart=always + + +[Install] +WantedBy=default.target \ No newline at end of file From 4a04d4260006b818cca253305efae226556e3a0b Mon Sep 17 00:00:00 2001 From: Donald Cheng Hong Zou Date: Thu, 5 Aug 2021 00:45:15 -0400 Subject: [PATCH 02/14] v2.2-beta3 Finished QR code function and starting to test. --- README.md | 23 ++++--- src/dashboard.py | 82 +++++++++++++++-------- src/private_key.txt | 1 + src/public_key.txt | 1 + src/static/dashboard.css | 38 ++++++++++- src/templates/configuration.html | 109 ++++++++++++++++++++++++++++--- src/templates/get_conf.html | 5 ++ src/templates/header.html | 2 +- 8 files changed, 212 insertions(+), 49 deletions(-) create mode 100644 src/private_key.txt create mode 100644 src/public_key.txt diff --git a/README.md b/README.md index 4404d5a..4a0b01a 100644 --- a/README.md +++ b/README.md @@ -17,13 +17,14 @@

Monitoring WireGuard is not convinient, need to login into server and type wg show. That's why this platform is being created, to view all configurations and manage them in a easier way.

-## πŸ“£ What's New: Version 2.1 +## πŸ“£ What's New: Version v2.2 -- 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 ([Bug report](https://github.com/donaldzou/wireguard-dashboard/issues/23#issuecomment-869189672)) -- Fixed crash when too many peers ([Bug report](https://github.com/donaldzou/wireguard-dashboard/issues/22#issuecomment-868840564)) +- πŸŽ‰ **New Features** + - **QR Code**: You can add the private key 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**. + - **Autostart on boot**: Added a tutorial on how to start the dashboard to on boot! Please read the [tutorial below](https://github.com/donaldzou/wireguard-dashboard/tree/v2.2-beta#autostart-wireguard-dashboard-on-boot). +- πŸͺš **Bug Fixed** + - When there are comments in the wireguard config file, will cause the dashboard to crash. + - Used regex to search for config files.
@@ -34,10 +35,14 @@ - [πŸ›  Install](https://github.com/donaldzou/wireguard-dashboard#-install) - [πŸͺœ Usage](https://github.com/donaldzou/wireguard-dashboard#-usage) - [βœ‚οΈ Dashboard Configuration](https://github.com/donaldzou/wireguard-dashboard#%EF%B8%8F-dashboard-configuration) + - [Start/Stop/Restart Wireguard Dashboard](https://github.com/donaldzou/wireguard-dashboard/tree/v2.2-beta#startstoprestart-wireguard-dashboard) + - [Autostart Wireguard Dashboard on boot](https://github.com/donaldzou/wireguard-dashboard/tree/v2.2-beta#autostart-wireguard-dashboard-on-boot) - [❓ How to update the dashboard?](https://github.com/donaldzou/wireguard-dashboard#-how-to-update-the-dashboard) - [⚠️ Update from v1.x.x](https://github.com/donaldzou/wireguard-dashboard#%EF%B8%8F--update-from-v1xx) - [πŸ” Screenshot](https://github.com/donaldzou/wireguard-dashboard#-screenshot) + + ## πŸ’‘ Features - Add peers for each WireGuard configuration @@ -71,7 +76,7 @@ 1. **Download Wireguard Dashboard** ```shell - $ git clone -b v2.1 https://github.com/donaldzou/Wireguard-Dashboard.git + $ git clone -b vv2.2 https://github.com/donaldzou/Wireguard-Dashboard.git 2. **Install Python Dependencies** ```shell @@ -262,7 +267,7 @@ All these settings will be able to configure within the dashboard in **Settings* ``` 2. Get the newest version ``` - $ sudo git pull https://github.com/donaldzou/wireguard-dashboard.git v2.1 --force + $ sudo git pull https://github.com/donaldzou/wireguard-dashboard.git vv2.2 --force ``` 3. Update and install all python dependencies ``` @@ -275,7 +280,7 @@ All these settings will be able to configure within the dashboard in **Settings* ### ⚠️ **Update from v1.x.x** 1. Stop the dashboard if it is running. -2. You can use `git pull https://github.com/donaldzou/Wireguard-Dashboard.git v2.1` to get the new update inside `Wireguard-Dashboard` directory. +2. You can use `git pull https://github.com/donaldzou/Wireguard-Dashboard.git vv2.2` to get the new update inside `Wireguard-Dashboard` directory. 3. Proceed **Step 2 & 3** in the [Install](#-install) step down below. ## πŸ” Screenshot diff --git a/src/dashboard.py b/src/dashboard.py index c59e33d..2019e20 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -13,6 +13,7 @@ import configparser import re # PIP installed library import ifcfg +from flask_qrcode import QRcode from tinydb import TinyDB, Query from icmplib import ping, multiping, traceroute, resolve, Host, Hop @@ -20,12 +21,16 @@ from icmplib import ping, multiping, traceroute, resolve, Host, Hop dashboard_version = 'v2.1' # Dashboard Config Name dashboard_conf = 'wg-dashboard.ini' +# Default Wireguard IP +wg_ip = ifcfg.default_interface()['inet'] + # Upgrade Required update = "" # Flask App Configuration app = Flask("Wireguard Dashboard") app.secret_key = secrets.token_urlsafe(16) app.config['TEMPLATES_AUTO_RELOAD'] = True +QRcode(app) def get_conf_peer_key(config_name): @@ -54,7 +59,6 @@ def get_conf_running_peer_number(config_name): count += 2 return running - def is_match(regex, text): pattern = re.compile(regex) return pattern.search(text) is not None @@ -97,7 +101,6 @@ def read_conf_file(config_name): # Read Configuration File End return conf_peer_data - def get_latest_handshake(config_name, db, peers): # Get latest handshakes try: @@ -172,17 +175,17 @@ def get_allowed_ip(config_name, db, peers, conf_peer_data): for i in conf_peer_data["Peers"]: db.update({"allowed_ip": i.get('AllowedIPs', '(None)')}, peers.id == i["PublicKey"]) - - def get_conf_peers_data(config_name): db = TinyDB('db/' + config_name + '.json') peers = Query() conf_peer_data = read_conf_file(config_name) for i in conf_peer_data['Peers']: - if not db.search(peers.id == i['PublicKey']): + search = db.search(peers.id == i['PublicKey']) + if not search: db.insert({ "id": i['PublicKey'], + "private_key": "", "name": "", "total_receive": 0, "total_sent": 0, @@ -193,6 +196,10 @@ def get_conf_peers_data(config_name): "allowed_ip": 0, "traffic": [] }) + else: + # Update database since V2.2 + if "private_key" not in search[0]: + db.update({'private_key':''}, peers.id == i['PublicKey']) tic = time.perf_counter() get_latest_handshake(config_name, db, peers) @@ -203,11 +210,6 @@ def get_conf_peers_data(config_name): print(f"Finish fetching data in {toc - tic:0.4f} seconds") db.close() - - - - - def get_peers(config_name): get_conf_peers_data(config_name) db = TinyDB('db/' + config_name + '.json') @@ -216,7 +218,6 @@ def get_peers(config_name): db.close() return result - def get_conf_pub_key(config_name): conf = configparser.ConfigParser(strict=False) conf.read(wg_conf_path + "/" + config_name + ".conf") @@ -225,7 +226,6 @@ def get_conf_pub_key(config_name): conf.clear() return pub.decode().strip("\n") - def get_conf_listen_port(config_name): conf = configparser.ConfigParser(strict=False) conf.read(wg_conf_path + "/" + config_name + ".conf") @@ -233,7 +233,6 @@ def get_conf_listen_port(config_name): conf.clear() return port - def get_conf_total_data(config_name): db = TinyDB('db/' + config_name + '.json') upload_total = 0 @@ -250,7 +249,6 @@ def get_conf_total_data(config_name): db.close() return [total, upload_total, download_total] - def get_conf_status(config_name): ifconfig = dict(ifcfg.interfaces().items()) if config_name in ifconfig.keys(): @@ -258,24 +256,21 @@ def get_conf_status(config_name): else: return "stopped" - def get_conf_list(): conf = [] for i in os.listdir(wg_conf_path): - if not i.startswith('.'): - if ".conf" in i: - i = i.replace('.conf', '') - temp = {"conf": i, "status": get_conf_status(i), "public_key": get_conf_pub_key(i)} - if temp['status'] == "running": - temp['checked'] = 'checked' - else: - temp['checked'] = "" - conf.append(temp) + if is_match("^(.{1,}).(conf)$", i): + i = i.replace('.conf', '') + temp = {"conf": i, "status": get_conf_status(i), "public_key": get_conf_pub_key(i)} + if temp['status'] == "running": + temp['checked'] = 'checked' + else: + temp['checked'] = "" + conf.append(temp) if len(conf) > 0: conf = sorted(conf, key=itemgetter('conf')) return conf - @app.before_request def auth_req(): conf = configparser.ConfigParser(strict=False) @@ -520,7 +515,7 @@ def get_conf(config_name): conf_data['checked'] = "nope" else: conf_data['checked'] = "checked" - return render_template('get_conf.html', conf=get_conf_list(), conf_data=conf_data) + return render_template('get_conf.html', conf=get_conf_list(), conf_data=conf_data, wg_ip=wg_ip) @app.route('/switch/', methods=['GET']) @@ -552,7 +547,7 @@ def add_peer(config_name): if type(keys) != list: return config_name+" is not running." if public_key in keys: - return "Key already exist." + return "Public key already exist." else: status = "" try: @@ -562,7 +557,7 @@ def add_peer(config_name): get_conf_peers_data(config_name) db = TinyDB("db/" + config_name + ".json") peers = Query() - db.update({"name": data['name']}, peers.id == public_key) + db.update({"name": data['name'], "private_key": data['private_key']}, peers.id == public_key) db.close() return "true" except subprocess.CalledProcessError as exc: @@ -617,8 +612,37 @@ def get_peer_name(config_name): db.close() return result[0]['name'] +@app.route('/generate_peer', methods=['GET']) +def generate_peer(): + gen = subprocess.check_output('wg genkey > private_key.txt && wg pubkey < private_key.txt > public_key.txt',shell=True) + private = open('private_key.txt') + private_key = private.readline().strip() + public = open('public_key.txt') + public_key = public.readline().strip() + data = {"private_key": private_key, "public_key": public_key} + private.close() + public.close() + os.remove('private_key.txt') + os.remove('public_key.txt') + return jsonify(data) - +@app.route('/generate_public_key', methods=['POST']) +def generate_public_key(): + data = request.get_json() + private_key = data['private_key'] + pri_key_file = open('private_key.txt', 'w') + pri_key_file.write(private_key) + pri_key_file.close() + try: + check = subprocess.check_output("wg pubkey < private_key.txt > public_key.txt", shell=True) + public = open('public_key.txt') + public_key = public.readline().strip() + os.remove('private_key.txt') + os.remove('public_key.txt') + return jsonify({"status":'success', "msg":"", "data":public_key}) + except subprocess.CalledProcessError as exc: + os.remove('private_key.txt') + return jsonify({"status":'failed', "msg":"Key is not the correct length or format", "data":""}) def init_dashboard(): # Set Default INI File diff --git a/src/private_key.txt b/src/private_key.txt new file mode 100644 index 0000000..adb45a4 --- /dev/null +++ b/src/private_key.txt @@ -0,0 +1 @@ +NZV8Z5QOobhbM4f6RLtICNghumYT30aKUxaUNmEtulM= \ No newline at end of file diff --git a/src/public_key.txt b/src/public_key.txt new file mode 100644 index 0000000..6a93f06 --- /dev/null +++ b/src/public_key.txt @@ -0,0 +1 @@ +NZV8Z5QOobhbM4f6RLtICNghumYT30aKUxaUNmEtulM= diff --git a/src/static/dashboard.css b/src/static/dashboard.css index 482b6b2..3d7c51f 100644 --- a/src/static/dashboard.css +++ b/src/static/dashboard.css @@ -195,4 +195,40 @@ main{ /* padding: 0.75rem 1.5rem;*/ /* border-radius: 3rem;*/ /* font-size: 1rem;*/ -/*}*/ \ No newline at end of file +/*}*/ + +@-webkit-keyframes rotating /* Safari and Chrome */ { + from { + -webkit-transform: rotate(0deg); + -o-transform: rotate(0deg); + transform: rotate(0deg); + } + to { + -webkit-transform: rotate(360deg); + -o-transform: rotate(360deg); + transform: rotate(360deg); + } +} +@keyframes rotating { + from { + -ms-transform: rotate(0deg); + -moz-transform: rotate(0deg); + -webkit-transform: rotate(0deg); + -o-transform: rotate(0deg); + transform: rotate(0deg); + } + to { + -ms-transform: rotate(360deg); + -moz-transform: rotate(360deg); + -webkit-transform: rotate(360deg); + -o-transform: rotate(360deg); + transform: rotate(360deg); + } +} +.rotating::before { + -webkit-animation: rotating 0.75s linear infinite; + -moz-animation: rotating 0.75s linear infinite; + -ms-animation: rotating 0.75s linear infinite; + -o-animation: rotating 0.75s linear infinite; + animation: rotating 0.75s linear infinite; +} \ No newline at end of file diff --git a/src/templates/configuration.html b/src/templates/configuration.html index 9183593..0e0114c 100644 --- a/src/templates/configuration.html +++ b/src/templates/configuration.html @@ -23,16 +23,32 @@
-
- - + +
+ +
+
+ +
+ +
- + + +
+ +
+
- +
@@ -95,6 +111,23 @@
+ +

-
-
- - - - - -
- -
-
- - {% for i in conf_data['peer_data']%} -
-
-
-
- + + + + + diff --git a/src/templates/header.html b/src/templates/header.html index f668382..4c3427e 100644 --- a/src/templates/header.html +++ b/src/templates/header.html @@ -1,10 +1,10 @@ - Wireguard Dashboard - - - + Wireguard Dashboard - {{ title }} + + + diff --git a/src/templates/navbar.html b/src/templates/navbar.html index e4d8ba4..348db6c 100644 --- a/src/templates/navbar.html +++ b/src/templates/navbar.html @@ -4,4 +4,7 @@ data-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" aria-label="Toggle navigation"> - \ No newline at end of file + +
+
+
\ No newline at end of file diff --git a/src/templates/settings.html b/src/templates/settings.html index 3605221..f4ddf15 100644 --- a/src/templates/settings.html +++ b/src/templates/settings.html @@ -1,41 +1,64 @@ - {% include "header.html" %} - - {% include "navbar.html" %} -
- {% include "sidebar.html" %} -
-
- {% if message != ""%} - - {% endif %} -

Settings

- {% if required_auth == "true" %} -

Account

-
-
+{% include "header.html" %} + +{% include "navbar.html" %} +
+ {% include "sidebar.html" %} +
+
+ {% if message != "" %} + + {% endif %} +

Settings

+ {% if required_auth == "true" %} +

Account

+ +
- - + + +
+ +
+

New Peer Default Settings

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

WireGuard Configuration Path

-
-
- + +
+
+
- -

Remember to remove / at the end of your path. e.g /etc/wireguard

+ +

WireGuard Configuration Path

+
+
+ + +

Remember to remove / at the end of your path. e.g /etc/wireguard +

-
-
-
-

Security

-
-
+
+
+
+

Security

+
+
@@ -43,37 +66,42 @@ +
+
+
+ {% endif %} +

Dashboard Configuration

+
+
+
+
+ + +

0.0.0.0 means it can be access by anyone with your server + IP Address.

- -
- {% endif %} -

Dashboard Configuration

-
-
-
-
- - -

0.0.0.0 means it can be access by anyone with your server IP Address.

-
-
- - -
-
- +
+ +
- +
+
-
- -
+ +
- +
+
+ {% include "footer.html" %} \ No newline at end of file diff --git a/src/templates/get_conf.html b/src/templates/get_conf.html index 75789fd..30d79a6 100644 --- a/src/templates/get_conf.html +++ b/src/templates/get_conf.html @@ -49,6 +49,10 @@ LISTEN PORT
{{conf_data['listen_port']}}
+
+ ADDRESS +
{{conf_data['conf_address']}}
+

@@ -66,12 +70,12 @@ diff --git a/src/templates/header.html b/src/templates/header.html index 4c3427e..c63fd7a 100644 --- a/src/templates/header.html +++ b/src/templates/header.html @@ -1,7 +1,7 @@ - Wireguard Dashboard - {{ title }} + Wireguard Dashboard | {{ title }} diff --git a/src/templates/index.html b/src/templates/index.html index 8dcf8f7..52ad2ad 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -1,5 +1,9 @@ -{% include "header.html" %} +{% with %} + {% set title="Home" %} + {% include "header.html"%} +{% endwith %} + {% include "navbar.html" %}
diff --git a/src/templates/settings.html b/src/templates/settings.html index f4ddf15..f9af059 100644 --- a/src/templates/settings.html +++ b/src/templates/settings.html @@ -1,5 +1,8 @@ -{% include "header.html" %} +{% with %} + {% set title="Settings" %} + {% include "header.html"%} +{% endwith %} {% include "navbar.html" %}
From 3140d46c944f56587bff8d97db141882c0333706 Mon Sep 17 00:00:00 2001 From: Donald Cheng Hong Zou Date: Sat, 14 Aug 2021 23:43:30 -0400 Subject: [PATCH 14/14] Finalizing the documentation --- README.md | 2 +- src/dashboard.py | 3 ++- src/templates/get_conf.html | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2fc2927..5a4894c 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ - **Search peers**: You can now search peers by their name. - **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)] - **Click to copy**: You can now click and copy all peer's public key and configuration's public key. - - And many more... + - .... - πŸͺš **Bug Fixed** - When there are comments in the wireguard config file, will cause the dashboard to crash. - Used regex to search for config files. diff --git a/src/dashboard.py b/src/dashboard.py index 7f96f80..974b22f 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -908,6 +908,7 @@ def download(config_name): private_key = peer['private_key'] allowed_ip = peer['allowed_ip'] DNS = peer['DNS'] + endpoint_allowed_ip = peer['endpoint_allowed_ip'] filename = peer['name'] if len(filename) == 0: filename = "Untitled_Peers" @@ -926,7 +927,7 @@ def download(config_name): filename = filename + "_" + config_name def generate(private_key, allowed_ip, DNS, public_key, endpoint): - yield "[Interface]\nPrivateKey = " + private_key + "\nAddress = " + allowed_ip + "\nDNS = " + DNS + "\n\n[Peer]\nPublicKey = " + public_key + "\nAllowedIPs = 0.0.0.0/0\nEndpoint = " + endpoint + yield "[Interface]\nPrivateKey = " + private_key + "\nAddress = " + allowed_ip + "\nDNS = " + DNS + "\n\n[Peer]\nPublicKey = " + public_key + "\nAllowedIPs = "+endpoint_allowed_ip+"\nEndpoint = " + endpoint return app.response_class(generate(private_key, allowed_ip, DNS, public_key, endpoint), mimetype='text/conf', diff --git a/src/templates/get_conf.html b/src/templates/get_conf.html index 30d79a6..820b40e 100644 --- a/src/templates/get_conf.html +++ b/src/templates/get_conf.html @@ -152,7 +152,7 @@ {% if i['private_key'] %}