mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-26 22:52:26 +00:00
Gestion de l'ouverture en entrée et en sortie.
This commit is contained in:
parent
d0a0a70e6e
commit
87a5800b31
4 changed files with 53 additions and 11 deletions
|
@ -230,9 +230,10 @@ class DelVlanForm(Form):
|
|||
vlan = forms.ModelMultipleChoiceField(queryset=Vlan.objects.all(), label="Vlan actuels", widget=forms.CheckboxSelectMultiple)
|
||||
|
||||
class EditPortListForm(ModelForm):
|
||||
tcp_ports = forms.CharField(required=False, label="Ports TCP")
|
||||
udp_ports = forms.CharField(required=False, label="Ports UDP")
|
||||
# interfaces = forms.ModelMultipleChoiceField(queryset=Interface.objects.filter(Q(has_public_ip=True)), label="Interface", widget=forms.CheckboxSelectMultiple)
|
||||
tcp_ports_in = forms.CharField(required=False, label="Ports TCP (entrée)")
|
||||
udp_ports_in = forms.CharField(required=False, label="Ports UDP (entrée)")
|
||||
tcp_ports_out = forms.CharField(required=False, label="Ports TCP (sortie)")
|
||||
udp_ports_out = forms.CharField(required=False, label="Ports UDP (sortie)")
|
||||
class Meta:
|
||||
model = PortList
|
||||
fields = ['name']
|
||||
|
|
20
machines/migrations/0060_port_io.py
Normal file
20
machines/migrations/0060_port_io.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2017-10-01 09:30
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('machines', '0059_port_protocole'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='port',
|
||||
name='io',
|
||||
field=models.CharField(choices=[('I', 'IN'), ('O', 'OUT')], default='O', max_length=1),
|
||||
),
|
||||
]
|
|
@ -417,11 +417,18 @@ class PortList(models.Model):
|
|||
def __str__(self):
|
||||
return ', '.join(map(str, self.port_set.all()))
|
||||
|
||||
def tcp_ports(self):
|
||||
return self.port_set.filter(protocole=Port.TCP)
|
||||
def tcp_ports_in(self):
|
||||
return self.port_set.filter(protocole=Port.TCP, io=Port.IN)
|
||||
|
||||
def udp_ports(self):
|
||||
return self.port_set.filter(protocole=Port.UDP)
|
||||
def udp_ports_in(self):
|
||||
return self.port_set.filter(protocole=Port.UDP, io=Port.IN)
|
||||
|
||||
def tcp_ports_out(self):
|
||||
return self.port_set.filter(protocole=Port.TCP, io=Port.OUT)
|
||||
|
||||
def udp_ports_out(self):
|
||||
return self.port_set.filter(protocole=Port.UDP, io=Port.OUT)
|
||||
|
||||
|
||||
class Port(models.Model):
|
||||
"""
|
||||
|
@ -432,6 +439,8 @@ class Port(models.Model):
|
|||
"""
|
||||
TCP = 'T'
|
||||
UDP = 'U'
|
||||
IN = 'I'
|
||||
OUT = 'O'
|
||||
begin = models.IntegerField()
|
||||
end = models.IntegerField()
|
||||
port_list = models.ForeignKey('PortList', on_delete=models.CASCADE)
|
||||
|
@ -443,6 +452,14 @@ class Port(models.Model):
|
|||
),
|
||||
default=TCP,
|
||||
)
|
||||
io = models.CharField(
|
||||
max_length=1,
|
||||
choices=(
|
||||
(IN, 'IN'),
|
||||
(OUT, 'OUT'),
|
||||
),
|
||||
default=OUT,
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
if self.begin == self.end :
|
||||
|
|
|
@ -11,16 +11,20 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>Nom</th>
|
||||
<th>TCP</th>
|
||||
<th>UDP</th>
|
||||
<th>TCP (entrée)</th>
|
||||
<th>TCP (sortie)</th>
|
||||
<th>UDP (entrée)</th>
|
||||
<th>UDP (sortie)</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for pl in port_list %}
|
||||
<tr>
|
||||
<td>{{pl.name}}</td>
|
||||
<td>{% for p in pl.tcp_ports%}{{p.show_port}}, {%endfor%}</td>
|
||||
<td>{% for p in pl.udp_ports%}{{p.show_port}}, {%endfor%}</td>
|
||||
<td>{% for p in pl.tcp_ports_in %}{{p.show_port}}, {%endfor%}</td>
|
||||
<td>{% for p in pl.tcp_ports_out %}{{p.show_port}}, {%endfor%}</td>
|
||||
<td>{% for p in pl.udp_ports_in %}{{p.show_port}}, {%endfor%}</td>
|
||||
<td>{% for p in pl.udp_ports_out %}{{p.show_port}}, {%endfor%}</td>
|
||||
<td class="text-right">
|
||||
{%comment%}
|
||||
{% include 'buttons/suppr.html' href='machines:del-portlist' id=pl.id %}
|
||||
|
|
Loading…
Reference in a new issue