diff --git a/deluge/plugins/blocklist/blocklist/core.py b/deluge/plugins/blocklist/blocklist/core.py index c94577df6..c734ca0fc 100644 --- a/deluge/plugins/blocklist/blocklist/core.py +++ b/deluge/plugins/blocklist/blocklist/core.py @@ -291,7 +291,9 @@ class Core(CorePluginBase): self.auto_detect(blocklist) self.auto_detected = True - d = threads.deferToThread(self.reader(blocklist).read(on_read_ip_range)) + log.debug("Importing using reader: %s",self.reader) + log.debug("Reader type: %s compression: %s", self.config["list_type"], self.config["list_compression"]) + d = threads.deferToThread(self.reader(blocklist).read, on_read_ip_range) d.addCallback(on_finish_read) return d @@ -345,6 +347,9 @@ class Core(CorePluginBase): """ self.config["list_compression"] = detect_compression(blocklist) self.config["list_type"] = detect_format(blocklist, self.config["list_compression"]) + log.debug("Auto-detected type: %s compression: %s", self.config["list_type"], self.config["list_compression"]) if not self.config["list_type"]: self.config["list_compression"] = "" raise UnknownFormatError + else: + self.reader = create_reader(self.config["list_type"], self.config["list_compression"]) diff --git a/deluge/plugins/blocklist/blocklist/detect.py b/deluge/plugins/blocklist/blocklist/detect.py index fa28afd9b..c25ca49e7 100644 --- a/deluge/plugins/blocklist/blocklist/detect.py +++ b/deluge/plugins/blocklist/blocklist/detect.py @@ -37,9 +37,9 @@ from decompressers import Zipped, GZipped, BZipped2 from readers import EmuleReader, SafePeerReader, PeerGuardianReader COMPRESSION_TYPES = { - "PK" : "zip", - "\x1f\x8b" : "gzip", - "BZ" : "bzip2" + "PK" : "Zip", + "\x1f\x8b" : "GZip", + "BZ" : "BZ ip2" } DECOMPRESSERS = { diff --git a/deluge/plugins/blocklist/blocklist/gtkui.py b/deluge/plugins/blocklist/blocklist/gtkui.py index 80064b942..7af53cd49 100644 --- a/deluge/plugins/blocklist/blocklist/gtkui.py +++ b/deluge/plugins/blocklist/blocklist/gtkui.py @@ -116,7 +116,7 @@ class GtkUI(GtkPluginBase): deluge.common.fsize(status["file_size"])) self.glade.get_widget("label_modified").set_text( str(status["file_date"])) - + self.glade.get_widget("label_type").set_text(status["file_type"]) self.glade.get_widget("label_url").set_text( status["file_url"]) diff --git a/deluge/plugins/blocklist/blocklist/readers.py b/deluge/plugins/blocklist/blocklist/readers.py index 75ed42d0b..ddfea004c 100644 --- a/deluge/plugins/blocklist/blocklist/readers.py +++ b/deluge/plugins/blocklist/blocklist/readers.py @@ -36,6 +36,26 @@ from deluge.log import LOG as log from common import raiseError +def remove_zeros(ip): + """ + Removes unneeded zeros from ip addresses. + + Example: 000.000.000.003 -> 0.0.0.3 + + :param ip: the ip address + :type ip: string + + :returns: the ip address without the unneeded zeros + :rtype: string + + """ + new_ip = [] + for part in ip.split("."): + while part[0] == "0" and len(part) > 1: + part = part[1:] + new_ip.append(part) + return ".".join(new_ip) + class ReaderParseError(Exception): pass @@ -56,7 +76,7 @@ class BaseReader(object): def read(self, callback): """Calls callback on each ip range in the file""" for start, end in self.readranges(): - callback(start, end) + callback(remove_zeros(start), remove_zeros(end)) def is_ignored(self, line): """Ignore commented lines and blank lines"""