Fix IP filter
This commit is contained in:
parent
170e430b8c
commit
0365ae00c0
|
@ -183,6 +183,12 @@ class Core(
|
||||||
self.settings.send_redundant_have = True
|
self.settings.send_redundant_have = True
|
||||||
self.session.set_settings(self.settings)
|
self.session.set_settings(self.settings)
|
||||||
|
|
||||||
|
# Create an ip filter
|
||||||
|
self.ip_filter = lt.ip_filter()
|
||||||
|
# This keeps track of the timer to set the ip filter.. We do this a few
|
||||||
|
# seconds aftering adding a rule so that 'batch' adding of rules isn't slow.
|
||||||
|
self._set_ip_filter_timer = None
|
||||||
|
|
||||||
# Load metadata extension
|
# Load metadata extension
|
||||||
self.session.add_extension(lt.create_metadata_plugin)
|
self.session.add_extension(lt.create_metadata_plugin)
|
||||||
self.session.add_extension(lt.create_ut_metadata_plugin)
|
self.session.add_extension(lt.create_ut_metadata_plugin)
|
||||||
|
@ -633,11 +639,12 @@ class Core(
|
||||||
|
|
||||||
def export_block_ip_range(self, range):
|
def export_block_ip_range(self, range):
|
||||||
"""Block an ip range"""
|
"""Block an ip range"""
|
||||||
try:
|
self.ip_filter.add_rule(range[0], range[1], 1)
|
||||||
self.ip_filter.add_rule(range[0], range[1], 1)
|
|
||||||
except AttributeError:
|
# Start a 2 second timer (and remove the previous one if it exists)
|
||||||
self.export_reset_ip_filter()
|
if self._set_ip_filter_timer:
|
||||||
self.ip_filter.add_rule(range[0], range[1], 1)
|
gobject.source_remove(self._set_ip_filter_timer)
|
||||||
|
self._set_ip_filter_timer = gobject.timeout_add(2000, self.session.set_ip_filter, self.ip_filter)
|
||||||
|
|
||||||
def export_reset_ip_filter(self):
|
def export_reset_ip_filter(self):
|
||||||
"""Clears the ip filter"""
|
"""Clears the ip filter"""
|
||||||
|
@ -707,6 +714,10 @@ class Core(
|
||||||
list of (index, filename) pairs."""
|
list of (index, filename) pairs."""
|
||||||
self.torrents[torrent_id].rename_files(filenames)
|
self.torrents[torrent_id].rename_files(filenames)
|
||||||
|
|
||||||
|
def export_rename_folder(self, torrent_id, folder, new_folder):
|
||||||
|
"""Renames the 'folder' to 'new_folder' in 'torrent_id'."""
|
||||||
|
self.torrents[torrent_id].rename_folder(folder, new_folder)
|
||||||
|
|
||||||
## Queueing functions ##
|
## Queueing functions ##
|
||||||
def export_queue_top(self, torrent_ids):
|
def export_queue_top(self, torrent_ids):
|
||||||
log.debug("Attempting to queue %s to top", torrent_ids)
|
log.debug("Attempting to queue %s to top", torrent_ids)
|
||||||
|
|
Loading…
Reference in New Issue