Here's my non-working patch
Code: Select all
diff -ruN deluge-1.3.11-old/deluge/plugins/blocklist/blocklist/peerguardian.py deluge-1.3.11-new/deluge/plugins/blocklist/blocklist/peerguardian.py
--- deluge-1.3.11-old/deluge/plugins/blocklist/blocklist/peerguardian.py 2014-11-30 22:53:46.000000000 +0100
+++ deluge-1.3.11-new/deluge/plugins/blocklist/blocklist/peerguardian.py 2015-09-01 12:26:31.000000000 +0000
@@ -12,8 +12,8 @@
class PGException(Exception):
pass
-# Incrementally reads PeerGuardian blocklists v1 and v2.
-# See http://wiki.phoenixlabs.org/wiki/P2B_Format
+# Incrementally reads PeerGuardian blocklists v1, v2 and v3.
+# See http://sourceforge.net/p/peerguardian/wiki/dev-blocklist-format-p2b/
class PGReader:
def __init__(self, filename):
@@ -36,9 +36,33 @@
buf = self.fd.read(1)
ver = ord(buf)
- if ver != 1 and ver != 2:
+ if ver < 1 or ver > 3:
raise PGException(_("Invalid version") + " %d" % ver)
+ if ver == 3:
+ num = self.fd.read(4)
+ while num > 0:
+ num -= 1
+ buf = -1
+ while buf != 0:
+ buf = self.fd.read(1)
+ if buf == "": # EOF
+ raise PGException(_("Unexpected end of file"))
+ buf = ord(buf)
+ ranges = self.fd.read(4)
+
+ def next3(self): #how to call this for "ranges" times?
+
+ # Skip over the string index
+ buf = self.fd.read(4)
+
+ buf = self.fd.read(4)
+ start = socket.inet_ntoa(buf)
+
+ buf = self.fd.read(4)
+ end = socket.inet_ntoa(buf)
+
+ return (start, end)
def next(self):