From b40d54cd1030250d1dac943bf8f245fb74d3928a Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Thu, 2 Aug 2007 18:20:24 +0000 Subject: [PATCH] separate add rule and set filter to speed things up --- plugins/BlocklistImport/__init__.py | 2 +- src/core.py | 3 +++ src/deluge_core.cpp | 14 +++++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/BlocklistImport/__init__.py b/plugins/BlocklistImport/__init__.py index 7ca4425d7..595a36350 100644 --- a/plugins/BlocklistImport/__init__.py +++ b/plugins/BlocklistImport/__init__.py @@ -122,8 +122,8 @@ class BlocklistImport: self.gtkprog.stop() reader.close() return - + self.core.set_ip_filter() reader.close() self.nimported = curr self.gtkprog.end_import() diff --git a/src/core.py b/src/core.py index f13368979..f7aaa4244 100644 --- a/src/core.py +++ b/src/core.py @@ -916,6 +916,9 @@ class Manager: def add_range_to_ip_filter(self, start, end): return deluge_core.add_range_to_IP_filter(start, end) + def set_ip_filter(self): + return deluge_core.set_IP_filter() + def proxy_settings(self, server, login, paswd, portnum, proxytype, proxy): return deluge_core.proxy_settings(server, login, paswd, portnum, proxytype, proxy) diff --git a/src/deluge_core.cpp b/src/deluge_core.cpp index 9ad826346..03509ef5c 100644 --- a/src/deluge_core.cpp +++ b/src/deluge_core.cpp @@ -1484,10 +1484,21 @@ static PyObject *torrent_add_range_to_IP_filter(PyObject *self, PyObject *args) address_v4 inet_start = address_v4::from_string(start); address_v4 inet_end = address_v4::from_string(end); M_the_filter->add_rule(inet_start, inet_end, ip_filter::blocked); - M_ses->set_ip_filter(*M_the_filter); + Py_INCREF(Py_None); return Py_None; } +static PyObject *torrent_set_IP_filter(PyObject *self, PyObject *args) +{ + if (M_the_filter == NULL) { + RAISE_PTR(DelugeError, "No filter defined, use reset_IP_filter"); + } + M_ses->set_ip_filter(*M_the_filter); + + Py_INCREF(Py_None); return Py_None; +} + + static PyObject *torrent_use_upnp(PyObject *self, PyObject *args) { python_long action; @@ -1854,6 +1865,7 @@ static PyMethodDef deluge_core_methods[] = {"create_torrent", torrent_create_torrent, METH_VARARGS, "."}, {"reset_IP_filter", torrent_reset_IP_filter, METH_VARARGS, "."}, {"add_range_to_IP_filter", torrent_add_range_to_IP_filter, METH_VARARGS, "."}, + {"set_IP_filter", torrent_set_IP_filter, METH_VARARGS, "."}, {"use_upnp", torrent_use_upnp, METH_VARARGS, "."}, {"use_natpmp", torrent_use_natpmp, METH_VARARGS, "."}, {"use_utpex", torrent_use_utpex, METH_VARARGS, "."},