mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-27 07:02:26 +00:00
Serialisation des ipv6 et export des ouvertures de ports
This commit is contained in:
parent
185fa6068a
commit
56e88cfe97
2 changed files with 19 additions and 9 deletions
|
@ -37,7 +37,8 @@ from machines.models import (
|
|||
Service_link,
|
||||
Ns,
|
||||
OuverturePortList,
|
||||
OuverturePort
|
||||
OuverturePort,
|
||||
Ipv6List
|
||||
)
|
||||
|
||||
|
||||
|
@ -57,6 +58,12 @@ class IpListSerializer(serializers.ModelSerializer):
|
|||
fields = ('ipv4', 'ip_type')
|
||||
|
||||
|
||||
class Ipv6ListSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Ipv6List
|
||||
fields = ('ipv6', 'slaac_ip')
|
||||
|
||||
|
||||
class InterfaceSerializer(serializers.ModelSerializer):
|
||||
"""Serialisation d'une interface, ipv4, domain et extension sont
|
||||
des foreign_key, on les override et on les evalue avec des fonctions
|
||||
|
@ -81,8 +88,9 @@ class InterfaceSerializer(serializers.ModelSerializer):
|
|||
|
||||
|
||||
class FullInterfaceSerializer(serializers.ModelSerializer):
|
||||
"""Serialisation complete d'une interface avec l'ipv6 en plus"""
|
||||
"""Serialisation complete d'une interface avec les ipv6 en plus"""
|
||||
ipv4 = IpListSerializer(read_only=True)
|
||||
ipv6 = Ipv6ListSerializer(read_only=True, many=True)
|
||||
mac_address = serializers.SerializerMethodField('get_macaddress')
|
||||
domain = serializers.SerializerMethodField('get_dns')
|
||||
extension = serializers.SerializerMethodField('get_interface_extension')
|
||||
|
|
|
@ -1268,14 +1268,16 @@ def ouverture_ports(request):
|
|||
d["udp_in"] = d.get("udp_in",set()).union(pl["udp_in"])
|
||||
d["udp_out"] = d.get("udp_out",set()).union(pl["udp_out"])
|
||||
r['ipv4'][i.ipv4.ipv4] = d
|
||||
if i.ipv6_object:
|
||||
d = r['ipv6'].get(i.ipv6.first(), {})
|
||||
d["tcp_in"] = d.get("tcp_in",set()).union(pl["tcp_in"])
|
||||
d["tcp_out"] = d.get("tcp_out",set()).union(pl["tcp_out"])
|
||||
d["udp_in"] = d.get("udp_in",set()).union(pl["udp_in"])
|
||||
d["udp_out"] = d.get("udp_out",set()).union(pl["udp_out"])
|
||||
r['ipv6'][i.ipv6] = d
|
||||
if i.ipv6():
|
||||
for ipv6 in i.ipv6():
|
||||
d = r['ipv6'].get(ipv6.ipv6, {})
|
||||
d["tcp_in"] = d.get("tcp_in",set()).union(pl["tcp_in"])
|
||||
d["tcp_out"] = d.get("tcp_out",set()).union(pl["tcp_out"])
|
||||
d["udp_in"] = d.get("udp_in",set()).union(pl["udp_in"])
|
||||
d["udp_out"] = d.get("udp_out",set()).union(pl["udp_out"])
|
||||
r['ipv6'][ipv6.ipv6] = d
|
||||
return JSONResponse(r)
|
||||
|
||||
@csrf_exempt
|
||||
@login_required
|
||||
@permission_required('machines.serveur')
|
||||
|
|
Loading…
Reference in a new issue