Fix blocklist plugin
This commit is contained in:
parent
b680ff48e5
commit
34b25d77f1
|
@ -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"])
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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"])
|
||||
|
||||
|
|
|
@ -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"""
|
||||
|
|
Loading…
Reference in New Issue