From c5a77883946918367382ede8a22a919d056336c1 Mon Sep 17 00:00:00 2001
From: Galonza Peter
Date: Sun, 17 Oct 2021 20:00:12 +0300
Subject: [PATCH 01/22] optimized pattern
---
src/dashboard.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/dashboard.py b/src/dashboard.py
index 99a4c19..07bb5ca 100644
--- a/src/dashboard.py
+++ b/src/dashboard.py
@@ -58,8 +58,7 @@ def clean_IP_with_range(ip):
# Check IP with range (IPv4 only now)
# TODO: Add IPv6 support
def check_IP_with_range(ip):
- return regex_match("((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|\/)){4}(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|" +
- "18|19|20|21|22|23|24|25|26|27|28|29|30|31|32)(,|$)", ip)
+ return regex_match("((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|\/)){4}([0-9]{1,2})(,|$)", ip)
# Check allowed ips list
def check_Allowed_IPs(ip):
From ffa63b3f82caa6aff75c5fac925611a40a7c23df Mon Sep 17 00:00:00 2001
From: Galonza Peter
Date: Sun, 17 Oct 2021 20:22:27 +0300
Subject: [PATCH 02/22] completed todo. Added IPv6
---
src/dashboard.py | 42 +++++++++++++++++++++++++++++++++---------
1 file changed, 33 insertions(+), 9 deletions(-)
diff --git a/src/dashboard.py b/src/dashboard.py
index 07bb5ca..93c2daf 100644
--- a/src/dashboard.py
+++ b/src/dashboard.py
@@ -42,10 +42,22 @@ def regex_match(regex, text):
pattern = re.compile(regex)
return pattern.search(text) is not None
-# Check IP format (IPv4 only now)
-# TODO: Add IPv6 support
+# Check IP format
def check_IP(ip):
- return regex_match("((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}", ip)
+ ip_patterns = (
+ r"((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}",
+ r"((^|:)([0-9a-fA-F]{0,4})){1,8}$"
+ )
+
+ for match_pattern in ip_patterns:
+ match_result = regex_match(match_pattern, ip)
+ if match_result:
+ result = match_result
+ break
+ else:
+ result = None
+
+ return result
# Clean IP
def clean_IP(ip):
@@ -55,10 +67,22 @@ def clean_IP(ip):
def clean_IP_with_range(ip):
return clean_IP(ip).split(',')
-# Check IP with range (IPv4 only now)
-# TODO: Add IPv6 support
+# Check IP with range
def check_IP_with_range(ip):
- return regex_match("((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|\/)){4}([0-9]{1,2})(,|$)", ip)
+ ip_patterns = (
+ r"((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|\/)){4}([0-9]{1,2})(,|$)",
+ r"((^|:)([0-9a-fA-F]{0,4})){1,8}\/([0-9]{1,3})(,|$)"
+ )
+
+ for match_pattern in ip_patterns:
+ match_result = regex_match(match_pattern, ip)
+ if match_result:
+ result = match_result
+ break
+ else:
+ result = None
+
+ return result
# Check allowed ips list
def check_Allowed_IPs(ip):
@@ -76,10 +100,10 @@ def check_DNS(dns):
return False
return True
-# Check remote endpoint (Both IPv4 address and valid hostname)
-# TODO: Add IPv6 support
+# Check remote endpoint
def check_remote_endpoint(address):
- return (regex_match("((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}", address) or regex_match("(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z][a-z]{0,61}[a-z]",address))
+
+ return (check_IP(address) or regex_match("(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z][a-z]{0,61}[a-z]", address))
"""
From 62be683dd859496814f705fc67a4f4b712869dc7 Mon Sep 17 00:00:00 2001
From: Galonza Peter
Date: Sun, 17 Oct 2021 21:13:18 +0300
Subject: [PATCH 03/22] fixed search ipv6 in the string with comma
---
src/dashboard.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/dashboard.py b/src/dashboard.py
index 93c2daf..f742891 100644
--- a/src/dashboard.py
+++ b/src/dashboard.py
@@ -46,7 +46,7 @@ def regex_match(regex, text):
def check_IP(ip):
ip_patterns = (
r"((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}",
- r"((^|:)([0-9a-fA-F]{0,4})){1,8}$"
+ r"[0-9a-fA-F]{0,4}(:([0-9a-fA-F]{0,4})){1,7}$"
)
for match_pattern in ip_patterns:
@@ -71,7 +71,7 @@ def clean_IP_with_range(ip):
def check_IP_with_range(ip):
ip_patterns = (
r"((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|\/)){4}([0-9]{1,2})(,|$)",
- r"((^|:)([0-9a-fA-F]{0,4})){1,8}\/([0-9]{1,3})(,|$)"
+ r"[0-9a-fA-F]{0,4}(:([0-9a-fA-F]{0,4})){1,7}\/([0-9]{1,3})(,|$)"
)
for match_pattern in ip_patterns:
From caa9a904763ad4232205b7c8e547a065a392f6a9 Mon Sep 17 00:00:00 2001
From: Galonza Peter
Date: Sun, 17 Oct 2021 22:55:08 +0300
Subject: [PATCH 04/22] added dual-stack
---
src/dashboard.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/dashboard.py b/src/dashboard.py
index f742891..9addd11 100644
--- a/src/dashboard.py
+++ b/src/dashboard.py
@@ -1139,7 +1139,7 @@ def init_dashboard():
if 'wg_conf_path' not in config['Server']:
config['Server']['wg_conf_path'] = '/etc/wireguard'
if 'app_ip' not in config['Server']:
- config['Server']['app_ip'] = '0.0.0.0'
+ config['Server']['app_ip'] = '::'
if 'app_port' not in config['Server']:
config['Server']['app_port'] = '10086'
if 'auth_req' not in config['Server']:
From b3dc60b7ca08a38b7612796a4000557f8f15f28c Mon Sep 17 00:00:00 2001
From: Galonza Peter
Date: Sun, 24 Oct 2021 12:05:14 +0300
Subject: [PATCH 05/22] fixed check ipv6 dns
---
src/dashboard.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/dashboard.py b/src/dashboard.py
index 9addd11..15b7572 100644
--- a/src/dashboard.py
+++ b/src/dashboard.py
@@ -96,7 +96,7 @@ def check_DNS(dns):
dns = dns.replace(' ','').split(',')
status = True
for i in dns:
- if not (regex_match("((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}", i) or regex_match("(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z][a-z]{0,61}[a-z]",i)):
+ if not (check_IP(dns) or regex_match("(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z][a-z]{0,61}[a-z]",i)):
return False
return True
From bdfc260dd2b7cda4eec10bd1531744687908f0d4 Mon Sep 17 00:00:00 2001
From: Galonza Peter
Date: Sun, 24 Oct 2021 13:32:21 +0300
Subject: [PATCH 06/22] fixed
---
src/dashboard.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/dashboard.py b/src/dashboard.py
index 15b7572..ce49d81 100644
--- a/src/dashboard.py
+++ b/src/dashboard.py
@@ -96,7 +96,7 @@ def check_DNS(dns):
dns = dns.replace(' ','').split(',')
status = True
for i in dns:
- if not (check_IP(dns) or regex_match("(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z][a-z]{0,61}[a-z]",i)):
+ if not (check_IP(i) or regex_match("(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z][a-z]{0,61}[a-z]",i)):
return False
return True
From 2cc6fbd643bcc9180d6edec87495e7fc4d11b131 Mon Sep 17 00:00:00 2001
From: Donald Zou
Date: Wed, 10 Nov 2021 11:40:46 -0500
Subject: [PATCH 07/22] Update README.md
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index 333bd4b..0658051 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,6 @@
+
Hi! I'm planning the next major update for this project, please let me know if you have any suggestions or feature requests ;) You can create an issue with the "Feature request" template. Cheers!
+
Please provide your OS name and version if you can run the dashboard on it perfectly in #31, since I only tested on Ubuntu. Thank you!
From ed9b05cdf9d4a7e2c0f08d6bc9a09eacb0ea09e2 Mon Sep 17 00:00:00 2001
From: Donald Zou
Date: Fri, 19 Nov 2021 14:44:40 -0500
Subject: [PATCH 08/22] Update README.md
---
README.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 0658051..4be9593 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,9 @@
Hi! I'm planning the next major update for this project, please let me know if you have any suggestions or feature requests ;) You can create an issue with the "Feature request" template. Cheers!
-
Please provide your OS name and version if you can run the dashboard on it perfectly in #31, since I only tested on Ubuntu. Thank you!
+
Help Wanted
+
- If anyone know a better way to distubute releases of python application other than GitHub, please let me know in #31!
+
- Please provide your OS name and version if you can run the dashboard on it perfectly in #31, since I only tested on Ubuntu. Thank you!
From 257a2c2d9fcd9f04886912913c3dac8c3d27b16a Mon Sep 17 00:00:00 2001
From: Donald Zou
Date: Fri, 19 Nov 2021 14:45:37 -0500
Subject: [PATCH 09/22] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 4be9593..e7f3653 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
Hi! I'm planning the next major update for this project, please let me know if you have any suggestions or feature requests ;) You can create an issue with the "Feature request" template. Cheers!
Help Wanted
-
- If anyone know a better way to distubute releases of python application other than GitHub, please let me know in #31!
+
- If anyone know a better way to distubute releases of python application other than GitHub, please let me know in #103!
- Please provide your OS name and version if you can run the dashboard on it perfectly in #31, since I only tested on Ubuntu. Thank you!
From 62acc1081f45ced0ed2cb86d5ee0910fa2d46360 Mon Sep 17 00:00:00 2001
From: Donald Zou
Date: Fri, 19 Nov 2021 14:48:46 -0500
Subject: [PATCH 10/22] Update README.md
---
README.md | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index e7f3653..35aa6af 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,14 @@
-
Hi! I'm planning the next major update for this project, please let me know if you have any suggestions or feature requests ;) You can create an issue with the "Feature request" template. Cheers!
-
-
Help Wanted
-
- If anyone know a better way to distubute releases of python application other than GitHub, please let me know in #103!
-
- Please provide your OS name and version if you can run the dashboard on it perfectly in #31, since I only tested on Ubuntu. Thank you!
-
+> Hi! I'm planning the next major update for this project, please let me know if you have any suggestions or feature requests ;) You can create an issue with the "Feature request" template. Cheers!
+### Help Wanted
+
+> If anyone know a better way to distribute releases of python application other than GitHub, please let me know in #103!
+
+> Please provide your OS name and version if you can run the dashboard on it perfectly in #31, since I only tested on Ubuntu. Thank you!
+
+
From 805f03d231a52dafefb8832c7512bc2263e6c951 Mon Sep 17 00:00:00 2001
From: Markus Neubauer
Date: Thu, 25 Nov 2021 16:03:09 +0100
Subject: [PATCH 11/22] Update .gitignore
---
.gitignore | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 8104ed3..076f2e7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,4 +11,5 @@ src/wg-dashboard.ini
src/static/pic.xd
*.conf
private_key.txt
-public_key.txt
\ No newline at end of file
+public_key.txt
+venv/*
From 79b41e10568ddb351efe75a17078536e3eff51f2 Mon Sep 17 00:00:00 2001
From: Donald Zou
Date: Mon, 6 Dec 2021 14:15:22 -0500
Subject: [PATCH 12/22] Update README.md
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index 35aa6af..a2577bf 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,7 @@
+
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.
Note: This project is not affiliate to the official WireGuard Project ;)
From 78ef870d919e99ca892fdd411c14cca18bf48bda Mon Sep 17 00:00:00 2001
From: Markus Neubauer
Date: Thu, 25 Nov 2021 15:33:06 +0100
Subject: [PATCH 13/22] Update wg-dashboard.service
A more automated approach
---
src/wg-dashboard.service | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/wg-dashboard.service b/src/wg-dashboard.service
index 9a596df..44b5c43 100644
--- a/src/wg-dashboard.service
+++ b/src/wg-dashboard.service
@@ -1,11 +1,14 @@
[Unit]
-After=netword.service
+After=syslog.target network-online.target
+ConditionPathIsDirectory=/etc/wireguard
[Service]
-WorkingDirectory=
-ExecStart=/usr/bin/python3 dashboard.py
+Environment="VIRTUAL_ENV={{VIRTUAL_ENV}}"
+WorkingDirectory={{APP_ROOT}}
+ExecStart={{VIRTUAL_ENV}}/bin/python3 {{APP_ROOT}}dashboard.py
+PrivateTmp=yes
Restart=always
[Install]
-WantedBy=default.target
\ No newline at end of file
+WantedBy=multi-user.target
From 591b60c336e0ee1d2e4b71403a4506c032385cbc Mon Sep 17 00:00:00 2001
From: Markus Neubauer
Date: Thu, 25 Nov 2021 15:55:56 +0100
Subject: [PATCH 14/22] Update wgd.sh
a more automated approach to systemctl
---
src/wgd.sh | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/src/wgd.sh b/src/wgd.sh
index 3676947..38814a1 100755
--- a/src/wgd.sh
+++ b/src/wgd.sh
@@ -20,6 +20,17 @@ help () {
printf "=================================================================================\n"
}
+_check_and_set_venv(){
+ # deb/ubuntu users: might need a 'apt install python3.8-venv'
+ # set up the local environment
+ APP_ROOT=`pwd`
+ VIRTUAL_ENV="${APP_ROOT%/*}/venv"
+ if [ ! -d $VIRTUAL_ENV ]; then
+ python3 -m venv $VIRTUAL_ENV
+ fi
+ . ${VIRTUAL_ENV}/activate
+}
+
install_wgd(){
# Check Python3 version
version_pass=$(python3 -c 'import sys; print("1") if (sys.version_info.major == 3 and sys.version_info.minor >= 7) else print("0");')
@@ -33,9 +44,24 @@ install_wgd(){
then mkdir "log"
fi
printf "| Installing latest Python dependencies |\n"
+
+ # set up the local environment
+ _check_and_set_venv
+
python3 -m pip install -r requirements.txt > /dev/null 2>&1
printf "| WGDashboard installed successfully! |\n"
- printf "| Starting Dashboard |\n"
+
+ printf "| Preparing the systemctl unit file |\n"
+ sed -i "s#{{APP_ROOT}}#${APP_ROOT}#" wg-dashboard.service
+ sed -i "s#{{VIRTUAL_ENV}}#${VIRTUAL_ENV}#" wg-dashboard.service
+ cat wg-dashboard.service | sudo SYSTEMD_EDITOR=tee systemctl edit --force --full wg-dashboard.service
+ systemctl daemon-reload
+ printf "| Consider 'systemctl enable wg-dashboard' |\n"
+ printf " and 'systemctl start wg-dashboard'\n"
+ printf " use '${0} stop' before starting with systemctl\n"
+ echo
+
+ printf "| Now starting Dashboard in background |\n"
start_wgd
}
@@ -50,6 +76,7 @@ check_wgd_status(){
}
start_wgd () {
+ _check_and_set_venv
printf "%s\n" "$dashes"
printf "| Starting WGDashboard in the background. |\n"
if [ ! -d "log" ]
@@ -67,6 +94,7 @@ stop_wgd() {
start_wgd_debug() {
printf "%s\n" "$dashes"
+ _check_and_set_venv
printf "| Starting WGDashboard in the foreground. |\n"
python3 "$app_name"
printf "%s\n" "$dashes"
@@ -84,6 +112,7 @@ update_wgd() {
git stash > /dev/null 2>&1
git pull https://github.com/donaldzou/wireguard-dashboard.git $new_ver --force > /dev/null 2>&1
printf "| Installing latest Python dependencies |\n"
+ _check_and_set_venv
python3 -m pip install -r requirements.txt > /dev/null 2>&1
printf "| Update Successfully! |\n"
start_wgd
@@ -142,4 +171,3 @@ if [ "$#" != 1 ];
help
fi
fi
-
From fbce01d8463d204cd17e5aea18850e0e58d999ac Mon Sep 17 00:00:00 2001
From: Donald Cheng Hong Zou
Date: Sun, 19 Dec 2021 18:15:51 -0500
Subject: [PATCH 15/22] Update .gitignore
---
.gitignore | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 076f2e7..0cfdd62 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,4 +12,4 @@ src/static/pic.xd
*.conf
private_key.txt
public_key.txt
-venv/*
+venv/**
\ No newline at end of file
From 280802cf748aa0cb3b54724af81da0748f348ff8 Mon Sep 17 00:00:00 2001
From: Donald Cheng Hong Zou
Date: Sun, 19 Dec 2021 18:16:45 -0500
Subject: [PATCH 16/22] Update .gitignore
---
.gitignore | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 076f2e7..6ec7b5e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,4 +12,6 @@ src/static/pic.xd
*.conf
private_key.txt
public_key.txt
-venv/*
+venv/**
+log/**
+*~
\ No newline at end of file
From 304d4293f3d60c2cdb447012738e4ef4e75ab065 Mon Sep 17 00:00:00 2001
From: Donald Cheng Hong Zou
Date: Mon, 20 Dec 2021 19:54:53 -0500
Subject: [PATCH 17/22] Update wgd.sh
---
src/wgd.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/wgd.sh b/src/wgd.sh
index 38814a1..bc0705f 100755
--- a/src/wgd.sh
+++ b/src/wgd.sh
@@ -28,7 +28,7 @@ _check_and_set_venv(){
if [ ! -d $VIRTUAL_ENV ]; then
python3 -m venv $VIRTUAL_ENV
fi
- . ${VIRTUAL_ENV}/activate
+ . ${VIRTUAL_ENV}/bin/activate
}
install_wgd(){
From b8e070824ab2eb165375723f465e9cbedbe21e01 Mon Sep 17 00:00:00 2001
From: Richard Newton
Date: Tue, 21 Dec 2021 15:31:16 +0000
Subject: [PATCH 18/22] Update get_conf.html
Added MTU and PersistentKeepalive back into QR Code.
Update dashboard.py
Added MTU and PersistentKeepalive to downloaded file.
---
src/dashboard.py | 8 +++++---
src/templates/get_conf.html | 2 +-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/dashboard.py b/src/dashboard.py
index 99a4c19..c433a47 100644
--- a/src/dashboard.py
+++ b/src/dashboard.py
@@ -994,7 +994,9 @@ def download(config_name):
private_key = peer['private_key']
allowed_ip = peer['allowed_ip']
DNS = peer['DNS']
+ MTU = peer['mtu']
endpoint_allowed_ip = peer['endpoint_allowed_ip']
+ keepalive = peer['keepalive']
filename = peer['name']
if len(filename) == 0:
filename = "Untitled_Peers"
@@ -1011,10 +1013,10 @@ def download(config_name):
filename = "".join(filename.split(' '))
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 = "+endpoint_allowed_ip+"\nEndpoint = " + endpoint
+ def generate(private_key, allowed_ip, DNS, MTU, public_key, endpoint, keepalive):
+ yield "[Interface]\nPrivateKey = " + private_key + "\nAddress = " + allowed_ip + "\nDNS = " + DNS + "\nMTU = " + MTU + "\n\n[Peer]\nPublicKey = " + public_key + "\nAllowedIPs = " + endpoint_allowed_ip + "\nEndpoint = " + endpoint+ "\nPersistentKeepalive = " + keepalive
- return app.response_class(generate(private_key, allowed_ip, DNS, public_key, endpoint),
+ return app.response_class(generate(private_key, allowed_ip, DNS, MTU, public_key, endpoint, keepalive),
mimetype='text/conf',
headers={"Content-Disposition": "attachment;filename=" + filename + ".conf"})
else:
diff --git a/src/templates/get_conf.html b/src/templates/get_conf.html
index 1032ad7..4b95885 100644
--- a/src/templates/get_conf.html
+++ b/src/templates/get_conf.html
@@ -182,7 +182,7 @@
{% if i['private_key'] %}