mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +00:00
Serializers for reverse DNS
This commit is contained in:
parent
ea2799eef1
commit
eb3f453106
4 changed files with 41 additions and 0 deletions
|
@ -888,6 +888,26 @@ class DNSZonesSerializer(serializers.ModelSerializer):
|
||||||
'mx_records', 'txt_records', 'srv_records', 'a_records',
|
'mx_records', 'txt_records', 'srv_records', 'a_records',
|
||||||
'aaaa_records', 'cname_records')
|
'aaaa_records', 'cname_records')
|
||||||
|
|
||||||
|
|
||||||
|
class DNSReverseZonesSerializer(serializers.ModelSerializer):
|
||||||
|
"""Serialize the data about DNS Zones.
|
||||||
|
"""
|
||||||
|
soa = SOARecordSerializer(source='extension.soa')
|
||||||
|
extension = serializers.CharField(source='extension.name', read_only=True)
|
||||||
|
cidrs = serializers.CharField(source='ip_set_cidrs_as_str', read_only=True)
|
||||||
|
ns_records = NSRecordSerializer(many=True, source='extension.ns_set')
|
||||||
|
mx_records = MXRecordSerializer(many=True, source='extension.mx_set')
|
||||||
|
txt_records = TXTRecordSerializer(many=True, source='extension.txt_set')
|
||||||
|
ptr_records = ARecordSerializer(many=True, source='get_associated_ptr_records')
|
||||||
|
ptr_v6_records = AAAARecordSerializer(many=True, source='get_associated_ptr_v6_records')
|
||||||
|
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = machines.IpType
|
||||||
|
fields = ('type', 'extension', 'soa', 'ns_records', 'mx_records',
|
||||||
|
'txt_records', 'ptr_records', 'ptr_v6_records', 'cidrs')
|
||||||
|
|
||||||
|
|
||||||
#REMINDER
|
#REMINDER
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,7 @@ router.register_view(r'reminder/get-users', views.ReminderView),
|
||||||
router.register_view(r'firewall/subnet-ports', views.SubnetPortsOpenView),
|
router.register_view(r'firewall/subnet-ports', views.SubnetPortsOpenView),
|
||||||
# DNS
|
# DNS
|
||||||
router.register_view(r'dns/zones', views.DNSZonesView),
|
router.register_view(r'dns/zones', views.DNSZonesView),
|
||||||
|
router.register_view(r'dns/reverse-zones', views.DNSReverseZonesView),
|
||||||
# MAILING
|
# MAILING
|
||||||
router.register_view(r'mailing/standard', views.StandardMailingView),
|
router.register_view(r'mailing/standard', views.StandardMailingView),
|
||||||
router.register_view(r'mailing/club', views.ClubMailingView),
|
router.register_view(r'mailing/club', views.ClubMailingView),
|
||||||
|
|
|
@ -563,6 +563,15 @@ class DNSZonesView(generics.ListAPIView):
|
||||||
.all())
|
.all())
|
||||||
serializer_class = serializers.DNSZonesSerializer
|
serializer_class = serializers.DNSZonesSerializer
|
||||||
|
|
||||||
|
class DNSReverseZonesView(generics.ListAPIView):
|
||||||
|
"""Exposes the detailed information about each extension (hostnames,
|
||||||
|
IPs, DNS records, etc.) in order to build the DNS zone files.
|
||||||
|
"""
|
||||||
|
queryset = (machines.IpType.objects.all())
|
||||||
|
serializer_class = serializers.DNSReverseZonesSerializer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# MAILING
|
# MAILING
|
||||||
|
|
||||||
|
|
|
@ -460,6 +460,17 @@ class IpType(RevMixin, AclMixin, models.Model):
|
||||||
):
|
):
|
||||||
ipv6.check_and_replace_prefix(prefix=self.prefix_v6)
|
ipv6.check_and_replace_prefix(prefix=self.prefix_v6)
|
||||||
|
|
||||||
|
def get_associated_ptr_records(self):
|
||||||
|
from re2o.utils import all_active_assigned_interfaces
|
||||||
|
return (all_active_assigned_interfaces()
|
||||||
|
.filter(type__ip_type=self)
|
||||||
|
.filter(ipv4__isnull=False))
|
||||||
|
|
||||||
|
def get_associated_ptr_v6_records(self):
|
||||||
|
from re2o.utils import all_active_interfaces
|
||||||
|
return (all_active_interfaces(full=True)
|
||||||
|
.filter(type__ip_type=self))
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
""" Nettoyage. Vérifie :
|
""" Nettoyage. Vérifie :
|
||||||
- Que ip_stop est après ip_start
|
- Que ip_stop est après ip_start
|
||||||
|
|
Loading…
Reference in a new issue