diff --git a/deluge/core/core.py b/deluge/core/core.py index ed73938d5..67512e09a 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -187,6 +187,10 @@ class Core( self.settings = lt.session_settings() self.settings.user_agent = "Deluge %s" % deluge.common.get_version() + # Create the IP Filter + self.ip_filter = lt.ip_filter() + self.session.set_ip_filter(self.ip_filter) + # Set lazy bitfield self.settings.lazy_bitfields = 1 self.session.set_settings(self.settings) @@ -498,7 +502,11 @@ class Core( def export_set_torrent_file_priorities(self, torrent_id, priorities): """Sets a torrents file priorities""" return self.torrents[torrent_id].set_file_priorities(priorities) - + + def export_block_ip_range(self, range): + """Block an ip range""" + self.ip_filter.add_rule(range[0], range[1], 1) + # Signals def torrent_added(self, torrent_id): """Emitted when a new torrent is added to the core""" diff --git a/deluge/ui/client.py b/deluge/ui/client.py index 247c525a5..03cd05252 100644 --- a/deluge/ui/client.py +++ b/deluge/ui/client.py @@ -367,3 +367,7 @@ def set_torrent_private_flag(torrent_id, value): def set_torrent_file_priorities(torrent_id, priorities): """Sets a torrents file priorities""" get_core().call("set_torrent_file_priorities", None, torrent_id, priorities) + +def block_ip_range(range): + """Blocks a ip range.. (start, end)""" + get_core().call("block_ip_range", None, range)