From 0e4101a9a3b17d383479ef79cf72ea79acde2468 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sat, 1 Dec 2012 02:21:01 +0000 Subject: [PATCH] Add windows support to is_ip --- deluge/common.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/deluge/common.py b/deluge/common.py index 467265433..63c364d6c 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -553,15 +553,23 @@ def is_ip(ip): import socket #first we test ipv4 try: - if socket.inet_pton(socket.AF_INET, "%s" % (ip)): - return True + if windows_check(): + if socket.inet_aton("%s" % (ip)): + return True + else: + if socket.inet_pton(socket.AF_INET, "%s" % (ip)): + return True except socket.error: if not socket.has_ipv6: return False #now test ipv6 try: - if socket.inet_pton(socket.AF_INET6, "%s" % (ip)): + if windows_check(): + log.warning("ipv6 check unavailable on windows") return True + else: + if socket.inet_pton(socket.AF_INET6, "%s" % (ip)): + return True except socket.error: return False