From bdeb811943b9f9e6d3686dc70ff60ab9e70affbc Mon Sep 17 00:00:00 2001 From: Antonio Fernandez Date: Wed, 23 Dec 2020 00:03:58 -0500 Subject: [PATCH 1/2] DNS parameter removed when not entered Having the DNS parameter blank (e.g. "DNS = ") will cause import errors in the Android app using the QR Code. I've added an if statement that checks if the DNS field has been populated. If so then it will write out the whole "DNS = x.x.x.x". If not then it will not be included at all. --- wg_dashboard_backend/templates/peer.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wg_dashboard_backend/templates/peer.j2 b/wg_dashboard_backend/templates/peer.j2 index b78a305..a4b9b42 100644 --- a/wg_dashboard_backend/templates/peer.j2 +++ b/wg_dashboard_backend/templates/peer.j2 @@ -1,7 +1,9 @@ [Interface] Address = {{ data.peer.address }}/{{ data.server.subnet }}{%- if is_ipv6 -%},{{ data.peer.v6_address }}/{{ data.server.v6_subnet }}{%- endif %} PrivateKey = {{ data.peer.private_key }} +{% if data.peer.dns %} DNS = {{ data.peer.dns }} +{% endif %} [Peer] PublicKey = {{ data.server.public_key }} From c7645e5ce7d313573147910506594e43d70777bf Mon Sep 17 00:00:00 2001 From: Antonio Fernandez Date: Wed, 23 Dec 2020 00:14:28 -0500 Subject: [PATCH 2/2] Removed blank PostUp and PostDown Not every server config needs a PostUp or PostDown so I added an if statement to not include them if the values entered in the web interface are blank. --- wg_dashboard_backend/templates/server.j2 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wg_dashboard_backend/templates/server.j2 b/wg_dashboard_backend/templates/server.j2 index e542f3d..05a66c0 100644 --- a/wg_dashboard_backend/templates/server.j2 +++ b/wg_dashboard_backend/templates/server.j2 @@ -3,8 +3,12 @@ Address = {{ data.address }}/{{ data.subnet }}{%- if is_ipv6 -%},{{ data.v6_addr ListenPort = {{ data.listen_port }} PrivateKey = {{ data.private_key }} +{% if data.post_up or data.v6_post_up %} PostUp = {{ data.post_up }}{%- if is_ipv6 -%} {{ data.v6_post_up }}{%- endif %} +{%- endif %} +{% if data.post_down or data.v6_post_down %} PostDown = {{ data.post_down }}{%- if is_ipv6 -%} {{ data.v6_post_down }}{%- endif %} +{%- endif %} {% for peer in data.peers %} [Peer]