Commit 57bd312c by Bach Dániel Committed by Bach Dániel

firewall: replace prefix_to_mask() with IPNetwork.netmask

parent 3d3bfaae
...@@ -376,16 +376,6 @@ def dns(): ...@@ -376,16 +376,6 @@ def dns():
return DNS return DNS
def prefix_to_mask(prefix):
t = [0, 0, 0, 0]
for i in range(0, 4):
if prefix > i * 8 + 7:
t[i] = 255
elif i * 8 < prefix and prefix <= (i + 1) * 8:
t[i] = 256 - (2 ** ((i + 1) * 8 - prefix))
return ".".join([str(i) for i in t])
def dhcp(): def dhcp():
vlans = models.Vlan.objects.all() vlans = models.Vlan.objects.all()
regex = re.compile(r'^([0-9]+)\.([0-9]+)\.[0-9]+\.[0-9]+\s+' regex = re.compile(r'^([0-9]+)\.([0-9]+)\.[0-9]+\.[0-9]+\s+'
...@@ -411,8 +401,8 @@ def dhcp(): ...@@ -411,8 +401,8 @@ def dhcp():
filename \"pxelinux.0\"; filename \"pxelinux.0\";
allow bootp; allow booting; allow bootp; allow booting;
}''' % { }''' % {
'net': i_vlan.net4, 'net': str(i_vlan.network4.network),
'netmask': prefix_to_mask(i_vlan.prefix4), 'netmask': str(i_vlan.network4.netmask),
'domain': i_vlan.domain, 'domain': i_vlan.domain,
'router': i_vlan.ipv4, 'router': i_vlan.ipv4,
'ntp': i_vlan.ipv4, 'ntp': i_vlan.ipv4,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment