From 59936f52f319073324cda22707464728bcd9bbf3 Mon Sep 17 00:00:00 2001 From: James Vega Date: Mon, 6 Jun 2011 22:29:21 -0400 Subject: [PATCH] Update Internet.hexip to handle IPv6 Signed-off-by: James Vega (cherry picked from commit b0e595fbd2e9b244738f4f8b1b5b88831583ad03) Signed-off-by: Daniel Folkinshteyn --- plugins/Internet/plugin.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/Internet/plugin.py b/plugins/Internet/plugin.py index eb5354394..de94afcd9 100644 --- a/plugins/Internet/plugin.py +++ b/plugins/Internet/plugin.py @@ -149,12 +149,22 @@ class Internet(callbacks.Plugin): Returns the hexadecimal IP for that IP. """ - quads = ip.split('.') ret = "" - for quad in quads: - i = int(quad) - ret += '%02x' % i - irc.reply(ret.upper()) + if utils.net.isIPV4(ip): + quads = ip.split('.') + for quad in quads: + 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'])