From 373dd2c695a04e5801444764e02c5ee78be2ae3e Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Mon, 5 Jan 2009 10:14:12 +0000 Subject: [PATCH] Fix the display of the tracker host when it's an IP address and not a hostname --- deluge/core/torrent.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index e6078f8a8..cccfadafb 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -518,6 +518,16 @@ class Torrent: url = urlparse(tracker) if hasattr(url, "hostname"): host = (url.hostname or 'DHT') + # Check if hostname is an IP address and just return it if that's the case + import socket + try: + socket.inet_aton(url.hostname) + except socket.error: + pass + else: + # This is an IP address because an exception wasn't raised + return url.hostname + parts = host.split(".") if len(parts) > 2: if parts[-2] in ("co", "com"):