From 397e05b3cc1b8efad6bf824ef178029cb5c1e91c Mon Sep 17 00:00:00 2001 From: "AB from home.homenet" Date: Fri, 8 Aug 2025 09:08:18 +0300 Subject: [PATCH] Fixed cert generation . --- vpn/signals.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/vpn/signals.py b/vpn/signals.py index a23ccac..c6a7241 100644 --- a/vpn/signals.py +++ b/vpn/signals.py @@ -265,13 +265,19 @@ def certificate_updated(sender, instance, created, **kwargs): if not created and instance.certificate_pem: # Only on updates when cert is available logger.info(f"Certificate {instance.domain} updated, redeploying dependent inbounds") - # Find all inbounds that use this certificate - inbounds = Inbound.objects.filter(certificate=instance) - servers = get_active_xray_servers() + # Find all ServerInbound deployments that use this certificate + from vpn.models_xray import ServerInbound + server_inbounds = ServerInbound.objects.filter(certificate=instance).select_related('server', 'inbound') - for inbound in inbounds: + # Group by server for efficient syncing + servers_to_sync = set() + for server_inbound in server_inbounds: + servers_to_sync.add(server_inbound.server) + + # Schedule sync for each affected server + for server in servers_to_sync: transaction.on_commit( - lambda inb=inbound: schedule_inbound_sync_for_servers(inb, servers) + lambda srv=server: srv.sync_inbounds() )