8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-30 08:32:26 +00:00

Merge branch 'reverse_dns_zones' into 'dev'

Reverse dns zones

See merge request federez/re2o!232
This commit is contained in:
chirac 2018-08-07 11:09:44 +02:00
commit 2b4680b54d
5 changed files with 45 additions and 14 deletions

View file

@ -734,7 +734,7 @@ class NSRecordSerializer(NsSerializer):
"""Serialize `machines.models.Ns` objects with the data needed to """Serialize `machines.models.Ns` objects with the data needed to
generate a NS DNS record. generate a NS DNS record.
""" """
target = serializers.CharField(source='ns.name', read_only=True) target = serializers.CharField(source='ns', read_only=True)
class Meta(NsSerializer.Meta): class Meta(NsSerializer.Meta):
fields = ('target',) fields = ('target',)
@ -744,7 +744,7 @@ class MXRecordSerializer(MxSerializer):
"""Serialize `machines.models.Mx` objects with the data needed to """Serialize `machines.models.Mx` objects with the data needed to
generate a MX DNS record. generate a MX DNS record.
""" """
target = serializers.CharField(source='name.name', read_only=True) target = serializers.CharField(source='name', read_only=True)
class Meta(MxSerializer.Meta): class Meta(MxSerializer.Meta):
fields = ('target', 'priority') fields = ('target', 'priority')
@ -864,7 +864,7 @@ class DNSReverseZonesSerializer(serializers.ModelSerializer):
model = machines.IpType model = machines.IpType
fields = ('type', 'extension', 'soa', 'ns_records', 'mx_records', fields = ('type', 'extension', 'soa', 'ns_records', 'mx_records',
'txt_records', 'ptr_records', 'ptr_v6_records', 'cidrs', 'txt_records', 'ptr_records', 'ptr_v6_records', 'cidrs',
'prefix_v6') 'prefix_v6', 'prefix_v6_length')
# MAILING # MAILING

View file

@ -231,7 +231,7 @@ class EditIpTypeForm(IpTypeForm):
class Meta(IpTypeForm.Meta): class Meta(IpTypeForm.Meta):
fields = ['extension', 'type', 'need_infra', 'domaine_ip_network', 'domaine_ip_netmask', fields = ['extension', 'type', 'need_infra', 'domaine_ip_network', 'domaine_ip_netmask',
'prefix_v6', 'prefix_v6_length', 'prefix_v6', 'prefix_v6_length',
'vlan', 'dnssec_reverse_v4', 'dnssec_reverse_v6', 'vlan', 'reverse_v4', 'reverse_v6',
'ouverture_ports'] 'ouverture_ports']

View file

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-08-07 07:26
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('machines', '0091_auto_20180806_2310'),
]
operations = [
migrations.RenameField(
model_name='iptype',
old_name='dnssec_reverse_v4',
new_name='reverse_v4',
),
migrations.RenameField(
model_name='iptype',
old_name='dnssec_reverse_v6',
new_name='reverse_v6',
),
]

View file

@ -292,9 +292,9 @@ class IpType(RevMixin, AclMixin, models.Model):
], ],
help_text="Netmask for the ipv4 range domain" help_text="Netmask for the ipv4 range domain"
) )
dnssec_reverse_v4 = models.BooleanField( reverse_v4 = models.BooleanField(
default=False, default=False,
help_text="Activer DNSSEC sur le reverse DNS IPv4", help_text="Enable reverse DNS for IPv4",
) )
prefix_v6 = models.GenericIPAddressField( prefix_v6 = models.GenericIPAddressField(
protocol='IPv6', protocol='IPv6',
@ -308,9 +308,9 @@ class IpType(RevMixin, AclMixin, models.Model):
MinValueValidator(0) MinValueValidator(0)
] ]
) )
dnssec_reverse_v6 = models.BooleanField( reverse_v6 = models.BooleanField(
default=False, default=False,
help_text="Activer DNSSEC sur le reverse DNS IPv6", help_text="Enable reverse DNS for IPv6",
) )
vlan = models.ForeignKey( vlan = models.ForeignKey(
'Vlan', 'Vlan',
@ -450,14 +450,20 @@ class IpType(RevMixin, AclMixin, models.Model):
def get_associated_ptr_records(self): def get_associated_ptr_records(self):
from re2o.utils import all_active_assigned_interfaces from re2o.utils import all_active_assigned_interfaces
if self.reverse_v4:
return (all_active_assigned_interfaces() return (all_active_assigned_interfaces()
.filter(type__ip_type=self) .filter(type__ip_type=self)
.filter(ipv4__isnull=False)) .filter(ipv4__isnull=False))
else:
return None
def get_associated_ptr_v6_records(self): def get_associated_ptr_v6_records(self):
from re2o.utils import all_active_interfaces from re2o.utils import all_active_interfaces
if self.reverse_v6:
return (all_active_interfaces(full=True) return (all_active_interfaces(full=True)
.filter(type__ip_type=self)) .filter(type__ip_type=self))
else:
return None
def clean(self): def clean(self):
""" Nettoyage. Vérifie : """ Nettoyage. Vérifie :

View file

@ -48,7 +48,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ type.need_infra|tick }}</td> <td>{{ type.need_infra|tick }}</td>
<td>{{ type.domaine_ip_start }}-{{ type.domaine_ip_stop }}{% if type.ip_network %}<b><u> on </b></u>{{ type.ip_network }}{% endif %}</td> <td>{{ type.domaine_ip_start }}-{{ type.domaine_ip_stop }}{% if type.ip_network %}<b><u> on </b></u>{{ type.ip_network }}{% endif %}</td>
<td>{{ type.prefix_v6 }}/{{ type.prefix_v6_length }}</td> <td>{{ type.prefix_v6 }}/{{ type.prefix_v6_length }}</td>
<td>{{ type.dnssec_reverse_v4|tick }}/{{ type.dnssec_reverse_v6|tick }}</td> <td>{{ type.reverse_v4|tick }}/{{ type.reverse_v6|tick }}</td>
<td>{{ type.vlan }}</td> <td>{{ type.vlan }}</td>
<td>{{ type.ouverture_ports }}</td> <td>{{ type.ouverture_ports }}</td>
<td class="text-right"> <td class="text-right">