]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - qwebirc/dns.py
add dynamic configuration support
[irc/quakenet/qwebirc.git] / qwebirc / dns.py
index 60d6cb2e0b5f56648634c35835c74bdbc0858558..357a8d9ccb3d83ef4561ea0a9297cf3c9d6c50cb 100644 (file)
@@ -17,10 +17,12 @@ def lookupPTR(ip, *args, **kwargs):
   return client.lookupPointer(ptr, **kwargs).addCallback(callback)
 
 def expandIPv6(ip):
-  expand_start, expand_end = ["".join(["{:0>4}".format(group)
+  expand_sections = ["".join(["{:0>4}".format(group)
       for group in section.split(":")])
-        for section in ip.split("::")]
-  return expand_start + (32-len(expand_start)-len(expand_end))*"0" + expand_end
+        for section in ip.split("::", 1)]
+  if len(expand_sections) == 1:
+      return expand_sections[0]
+  return expand_sections[0] + "".join((32-sum([len(x) for x in expand_sections]))*"0") + expand_sections[1]
 
 def lookupPTRv6(ip, *args, **kwargs):
   def callback(result):