Update Internet.hexip to handle IPv6

Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
James Vega 2011-06-06 22:29:21 -04:00
parent d56381436c
commit b0e595fbd2

View File

@ -149,12 +149,22 @@ class Internet(callbacks.Plugin):
Returns the hexadecimal IP for that IP. Returns the hexadecimal IP for that IP.
""" """
quads = ip.split('.')
ret = "" ret = ""
for quad in quads: if utils.net.isIPV4(ip):
i = int(quad) quads = ip.split('.')
ret += '%02x' % i for quad in quads:
irc.reply(ret.upper()) i = int(quad)
ret += '%02X' % i
else:
octets = ip.split(':')
for octet in octets:
if octet:
i = int(octet, 16)
ret += '%04X' % i
else:
missing = (8 - len(octets)) * 4
ret += '0' * missing
irc.reply(ret)
hexip = wrap(hexip, ['ip']) hexip = wrap(hexip, ['ip'])