mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-01-02 14:36:16 +00:00
refactor cluster settings handling and update DNS version logic
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Example configuration for Cluster Node
|
||||
# Rename this file to .env before starting
|
||||
COMPOSE_PROJECT_NAME=wireguard_webadmin_cluster_node
|
||||
COMPOSE_PROJECT_NAME=wireguard_webadmin_cluster_node_test2
|
||||
# Master Server Address (where the API is hosting)
|
||||
# Example: https://wireguard.example.com
|
||||
MASTER_SERVER_ADDRESS=https://wireguard.example.com
|
||||
@@ -14,8 +14,4 @@ TOKEN=<uuid>
|
||||
# Debug Mode (optional, default False)
|
||||
DEBUG_MODE=False
|
||||
|
||||
# Compose Version (Do not change)
|
||||
COMPOSE_VERSION=03r
|
||||
|
||||
# Timezone (duplicate for compatibility if needed, but TZ is standard)
|
||||
TIMEZONE=America/Sao_Paulo
|
||||
|
||||
@@ -110,10 +110,11 @@ def cluster_settings(request):
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
messages.success(request, _('Cluster settings updated successfully.'))
|
||||
compress_dnsmasq_config()
|
||||
if cluster_settings.enabled and cluster_settings.config_version == 0:
|
||||
if cluster_settings.enabled:
|
||||
if cluster_settings.config_version == 0:
|
||||
cluster_settings.config_version += 1
|
||||
cluster_settings.save()
|
||||
compress_dnsmasq_config()
|
||||
return redirect('/cluster/')
|
||||
else:
|
||||
form = ClusterSettingsForm(instance=cluster_settings)
|
||||
|
||||
@@ -9,10 +9,7 @@ def compress_dnsmasq_config():
|
||||
output_file = "/etc/dnsmasq/dnsmasq_config.tar.gz"
|
||||
base_dir = "/etc/dnsmasq"
|
||||
cluster_settings = ClusterSettings.objects.filter(enabled=True, name='cluster_settings').first()
|
||||
if cluster_settings:
|
||||
cluster_settings.dns_version += 1
|
||||
cluster_settings.save()
|
||||
else:
|
||||
if not cluster_settings:
|
||||
if os.path.exists(output_file):
|
||||
os.remove(output_file)
|
||||
return None
|
||||
@@ -36,9 +33,14 @@ def compress_dnsmasq_config():
|
||||
if newest_conf_mtime <= tar_mtime:
|
||||
return output_file
|
||||
|
||||
# If we reach here, we need to increment DNS version and recompile the tar.gz
|
||||
cluster_settings.dns_version += 1
|
||||
cluster_settings.save()
|
||||
dns_version_file = os.path.join(base_dir, "config_version.conf")
|
||||
with open(dns_version_file, "w", encoding="utf-8") as f:
|
||||
f.write(f"DNS_VERSION={cluster_settings.dns_version}\n")
|
||||
if "config_version.conf" not in conf_files:
|
||||
conf_files.append("config_version.conf")
|
||||
|
||||
# Create tar.gz
|
||||
tmp_output = output_file + ".tmp"
|
||||
|
||||
@@ -24,7 +24,7 @@ services:
|
||||
- "8000:8000"
|
||||
# Warning: Docker will have a hard time handling large amount of ports. Expose only the ports that you need.
|
||||
# Ports for multiple WireGuard instances. (Probably, you just need one)
|
||||
- "51820-51839:51820-51839/udp"
|
||||
#- "51820-51839:51820-51839/udp"
|
||||
# Ports for port forwarding rules. Add your own ports here if you need them.
|
||||
- "8080-8089:8080-8089/tcp"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user