modified: netbox_dns_bridge/request_handler.py

modified:   netbox_dns_bridge/signals/netbox_dns_zones.py

1. On zone deletion the catalog zone serial was not incremented, causing clients
   not to delete the zone until another zone is created/modified. Fixed using
   post_delete signal.

2. Even with the notify_clients feature disabled, the client IPs were still
   being tracked. This disables the unnecessary behavior.

3. _track_seen_client function in DNSBaseRequestHandler did not have the 'self'
   reference parameter, causing calls to fail. Fixed.
This commit is contained in:
Sven Luethi committed 2026-06-13 00:19:45 +02:00
1 parent b78ae930e7
commit 2a89f4ae75
2 files changed
+15 -4

No files matched your search

+3 -2
View File
@@ -17,7 +17,7 @@ from netbox_dns_bridge import catalog_zone_manager as catzm
from .models import SeenTransferClients
logger = get_logger(__name__)
SETTINGS = settings.PLUGINS_CONFIG["netbox_dns_bridge"]
class DNSBaseRequestHandler(socketserver.BaseRequestHandler):
def __init__(self, request, client_address, server) -> None:
@@ -144,7 +144,8 @@ class DNSBaseRequestHandler(socketserver.BaseRequestHandler):
wire = response.to_wire(multi=False)
self._send_response(wire)
def _track_seen_client(source_ip: str, view: View) -> None:
def _track_seen_client(self, source_ip: str, view: View) -> None:
if SETTINGS.get("notify_clients", False):
SeenTransferClients.objects.update_or_create(
source_ip=source_ip,
view=view,
+12 -2
View File
@@ -1,4 +1,4 @@
from django.db.models.signals import pre_save, post_save
from django.db.models.signals import pre_save, post_save, post_delete
from django.dispatch import receiver
from django.db import transaction
from django.conf import settings
@@ -25,13 +25,17 @@ def zone_pre_save(sender, instance, **kwargs):
@receiver(post_save, sender=Zone)
def zone_post_save(sender, instance, created, **kwargs):
zone = instance
# Quit if this is not the first signal in this session for this zone.
request = current_request.get()
if request is not None:
handled_zones = getattr(request, "_handled_zones", set())
if zone.pk in handled_zones:
return
handled_zones.add(zone.pk)
request._handled_zones = handled_zones
# On commit, increment soa serial and if notify is enabled, schedule bg job.
def _on_commit():
catzm.increment_soa_serial()
@@ -41,8 +45,14 @@ def zone_post_save(sender, instance, created, **kwargs):
transaction.on_commit(_on_commit)
if created:
# If zone was created, create catz member identifier record for this zone.
catzm.update_member_identifier(zone)
else:
# Check if zone name has changed and change the catz member identifier if so.
old_name = getattr(zone, "_old_name", None)
if old_name != zone.name:
if old_name and zone.name != old_name:
catzm.update_member_identifier(zone)
@receiver(post_delete, sender=Zone)
def zone_post_delete(sender, instance, **kwargs):
catzm.increment_soa_serial()