IP blocklist support patch

Suggestions and discussion of future versions
tarka
Member
Member
Posts: 22
Joined: Sat Jun 09, 2007 6:49 am

IP blocklist support patch

Post by tarka »

I've just dropped some basic IP blocklist filtering here: http://dev.deluge-torrent.org/ticket/185

This version includes the core patches and the plugin rework. It only works with Peerguardian *.p2b.gz files. There's the start of a download/import progress gui but it doesn't work at the moment. The config dialog looks like crap, input welcome.
shirish
Seeder
Seeder
Posts: 163
Joined: Fri May 25, 2007 4:01 am
Location: South Asia, India

Re: IP blocklist support patch

Post by shirish »

Would love to see it at work, good showing tarka :)
Debian Sid, Intel Dual-Core, 512 kbps DL , 64 Kbps UL, deluge-1.3.5, pieces plugin, GNOME 3.4.x

All posts under creative commons http://creativecommons.org/licenses/by-nc/3.0/
tarka
Member
Member
Posts: 22
Joined: Sat Jun 09, 2007 6:49 am

Re: IP blocklist support patch

Post by tarka »

This should be in SVN now. As mentioned before it only supports *.p2b.gz. At the moment it's unclear if these are maintained. If anyone has a current source of blocklists can they msg me, as my source appears to be out of date.
shirish
Seeder
Seeder
Posts: 163
Joined: Fri May 25, 2007 4:01 am
Location: South Asia, India

Re: IP blocklist support patch

Post by shirish »

instead of doing p2b.gz it would be cool if we could do just .gz there is http://www.bluetack.co.uk/forums/index.php & I esp. like either this http://www.bluetack.co.uk/config/pipfilter.dat.gz (I'm slightly paranoid :P) or this one http://www.bluetack.co.uk/config/nipfilter.dat.gz (not paranoid) . I dunno of any other site which manages to stay other, there is phoenixlabs also http://phoenixlabs.org/ but quite a bit of their stuff seems to be in beta http://test.blocklist.org/

Another link http://en.wikipedia.org/wiki/PeerGuardian which tells the state of where PeerGuardian is heading to :P

Hope we can do something useful. Let us know what u think?
Debian Sid, Intel Dual-Core, 512 kbps DL , 64 Kbps UL, deluge-1.3.5, pieces plugin, GNOME 3.4.x

All posts under creative commons http://creativecommons.org/licenses/by-nc/3.0/
tarka
Member
Member
Posts: 22
Joined: Sat Jun 09, 2007 6:49 am

Re: IP blocklist support patch

Post by tarka »

Hmm, I'm seeing that problem with "endpoint not connected". Looks like it's due to resetting the IP filter before loading the blocklist. I'll have to look at this tomorrow.
tarka
Member
Member
Posts: 22
Joined: Sat Jun 09, 2007 6:49 am

Re: IP blocklist support patch

Post by tarka »

tarka wrote:Hmm, I'm seeing that problem with "endpoint not connected". Looks like it's due to resetting the IP filter before loading the blocklist. I'll have to look at this tomorrow.
OK, this appears to be a problem with libtorrent. At the time the blocklist is loaded there are cached connections that haven't been connected yet, and we're trying to filter them, which causes libtorrent to chuck an 'endpoint not connected' exception. Try the following:

Code: Select all

Index: libtorrent/src/session_impl.cpp
===================================================================
--- libtorrent/src/session_impl.cpp     (revision 599)
+++ libtorrent/src/session_impl.cpp     (working copy)
@@ -599,7 +599,13 @@
                for (session_impl::connection_map::iterator i
                        = m_connections.begin(); i != m_connections.end();)
                {
-                       tcp::endpoint sender = i->first->remote_endpoint();
+                       tcp::endpoint sender;
+                       try {
+                               sender = i->first->remote_endpoint();
+                       } catch (asio::system_error& e) {
+                               continue;
+                       }
+ 
                        if (m_ip_filter.access(sender.address()) & ip_filter::blocked)
                        {
 #if defined(TORRENT_VERBOSE_LOGGING)
tarka
Member
Member
Posts: 22
Joined: Sat Jun 09, 2007 6:49 am

Re: IP blocklist support patch

Post by tarka »

Oops, infinite loop. Try this:

Code: Select all

Index: libtorrent/src/session_impl.cpp
===================================================================
--- libtorrent/src/session_impl.cpp     (revision 599)
+++ libtorrent/src/session_impl.cpp     (working copy)
@@ -599,7 +599,15 @@
                for (session_impl::connection_map::iterator i
                        = m_connections.begin(); i != m_connections.end();)
                {
-                       tcp::endpoint sender = i->first->remote_endpoint();
+                       tcp::endpoint sender;
+                       try {
+                               sender = i->first->remote_endpoint();
+                       } catch (asio::system_error& e) {
+                               // May be a cached connection
+                               i++;
+                               continue;
+                       }
+ 
                        if (m_ip_filter.access(sender.address()) & ip_filter::blocked)
                        {
 #if defined(TORRENT_VERBOSE_LOGGING)
markybob
Compulsive Poster
Compulsive Poster
Posts: 1230
Joined: Thu May 24, 2007 11:27 pm
Location: Chicago, IL, USA
Contact:

Re: IP blocklist support patch

Post by markybob »

tarka wrote:Oops, infinite loop. Try this:

Code: Select all

Index: libtorrent/src/session_impl.cpp
===================================================================
--- libtorrent/src/session_impl.cpp     (revision 599)
+++ libtorrent/src/session_impl.cpp     (working copy)
@@ -599,7 +599,15 @@
                for (session_impl::connection_map::iterator i
                        = m_connections.begin(); i != m_connections.end();)
                {
-                       tcp::endpoint sender = i->first->remote_endpoint();
+                       tcp::endpoint sender;
+                       try {
+                               sender = i->first->remote_endpoint();
+                       } catch (asio::system_error& e) {
+                               // May be a cached connection
+                               i++;
+                               continue;
+                       }
+ 
                        if (m_ip_filter.access(sender.address()) & ip_filter::blocked)
                        {
 #if defined(TORRENT_VERBOSE_LOGGING)
i've just applied this to svn and it did fix not being able to unload the blocklist plugin. thanks.
scrapmetal
Leecher
Leecher
Posts: 59
Joined: Mon May 28, 2007 12:03 pm

Re: IP blocklist support patch

Post by scrapmetal »

what kinda format should the end file be in if loaded from disk?
ive got a script that downlaods the blocklists im interested in, extracts them and cats them into ipfilter.dat for amule and blocklist.cache for azureus and moves the files to their appropriate dirs. this way i only need to download the files once instead of once per application
so what format should the end file be for deluge? and can it load from disk instead of url?
can it be scheduled to reload the file at a certain time?
ubuntu intrepid amd64
tarka
Member
Member
Posts: 22
Joined: Sat Jun 09, 2007 6:49 am

Re: IP blocklist support patch

Post by tarka »

scrapmetal wrote:what kinda format should the end file be in if loaded from disk?
It currently handles P2B format v1 and v2, gzipped: http://wiki.phoenixlabs.org/wiki/P2B_Format

I assume ipfilter.dat/blocklist.cache are v3, I plan to look at that next. The problem is that by default the v3 files are 7zipped and there's no built-in support for 7zip in Python. There's an external library available but I haven't tested it yet.

BTW, can you msg me your blocklist sources, I'm gathering data.
Post Reply