mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-11-27 07:06:03 +01:00
Make the cluster's primary WireGuard option stop the primary server and its gateway in mirror mode
This commit is contained in:
@@ -41,6 +41,13 @@ class ApplicationForm(forms.ModelForm):
|
||||
if self.cluster_enabled:
|
||||
self.fields['workers'].queryset = Worker.objects.order_by('name')
|
||||
self.fields['workers'].help_text = _('Select specific workers, or leave empty when serving on all cluster workers.')
|
||||
if not self.instance.pk:
|
||||
self.initial.setdefault('all_workers', True)
|
||||
if not ClusterSettings.primary_serves_clients():
|
||||
self.fields['serve_on_primary'].help_text = _(
|
||||
'WireGuard is disabled on the primary server in the cluster settings, so it does not publish '
|
||||
'applications until it is enabled again.'
|
||||
)
|
||||
cluster_rows = [
|
||||
HTML(f'<hr><h5>{_("Cluster")}</h5><p class="text-muted">{_("Servers that publish this application.")}</p>'),
|
||||
Div(
|
||||
|
||||
@@ -94,7 +94,8 @@ class Application(models.Model):
|
||||
if not ClusterSettings.cluster_enabled():
|
||||
return worker is None
|
||||
if worker is None:
|
||||
return self.serve_on_primary
|
||||
# Only WireGuard WebAdmin is published while the primary server does not serve clients
|
||||
return self.serve_on_primary and (self.name == RESERVED_APP_NAME or ClusterSettings.primary_serves_clients())
|
||||
return self.all_workers or self.workers.filter(pk=worker.pk).exists()
|
||||
|
||||
class Meta:
|
||||
|
||||
Reference in New Issue
Block a user