mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
Serializers for reverse DNS
This commit is contained in:
parent
cd5d0f562c
commit
1a46f3110f
4 changed files with 39 additions and 0 deletions
|
@ -817,6 +817,24 @@ class DNSZonesSerializer(serializers.ModelSerializer):
|
||||||
'aaaa_records', 'cname_records', 'sshfp_records')
|
'aaaa_records', 'cname_records', 'sshfp_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')
|
||||||
|
|
||||||
# MAILING
|
# MAILING
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,7 @@ router.register_view(r'localemail/users', views.LocalEmailUsersView),
|
||||||
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),
|
||||||
|
|
|
@ -555,6 +555,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
|
||||||
|
|
||||||
|
|
|
@ -353,6 +353,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