Add block_ip_range() in core and expose it in client.

This commit is contained in:
Andrew Resch 2008-02-17 05:46:51 +00:00
parent 0940f9072e
commit c9caab1b4d
2 changed files with 13 additions and 1 deletions

View File

@ -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"""

View File

@ -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)