Commit df2e6481 by Bach Dániel

firewall: use IPAddress.words instead of regex matching in convert_ipv4_to_ipv6()

parent de1ac429
...@@ -263,10 +263,8 @@ def val_mx(value): ...@@ -263,10 +263,8 @@ def val_mx(value):
def convert_ipv4_to_ipv6(ipv6_template, ipv4): def convert_ipv4_to_ipv6(ipv6_template, ipv4):
"""Convert IPv4 address string to IPv6 address string.""" """Convert IPv4 address string to IPv6 address string."""
ipv4 = str(ipv4) m = ipv4.words
val_ipv4(ipv4) return IPAddress(ipv6_template % {'a': int(m[0]),
m = ipv4_re.match(ipv4) 'b': int(m[1]),
return IPAddress(ipv6_template % {'a': int(m.group(1)), 'c': int(m[2]),
'b': int(m.group(2)), 'd': int(m[3])})
'c': int(m.group(3)),
'd': int(m.group(4))})
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