[mod] isolation of botdetection from SearXNG core

In PR-2894[1] we isolated botdetection from the limiter, this PR isolates the
botdetection from the SearXNG core code.

This PR also fixes the issue [2] that the ``server.public_instance`` option
needs to activate the limiter.

- [1] https://github.com/searxng/searxng/pull/2894
- [2] https://github.com/searxng/searxng/issues/2975

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2023-11-01 14:18:44 +01:00
parent c0b97c6543
commit 523a875f1e
20 changed files with 555 additions and 373 deletions

View file

@ -3,7 +3,6 @@
from searx import (
plugins,
limiter,
botdetection,
)
from mock import Mock
@ -51,8 +50,10 @@ class SelfIPTest(SearxTestCase):
plugin = plugins.load_and_initialize_plugin('searx.plugins.self_info', False, (None, {}))
store = plugins.PluginStore()
store.register(plugin)
cfg = limiter.get_cfg()
botdetection.init(cfg, None)
from searx import webapp # pylint disable=import-outside-toplevel
limiter.initialize(webapp.app, webapp.settings)
self.assertTrue(len(store.plugins) == 1)

View file

@ -6,6 +6,7 @@ from mock import Mock
from searx.results import Timing
import searx.search.processors
from searx import limiter
from searx.search import Search
from searx.preferences import Preferences
from tests import SearxTestCase
@ -21,6 +22,8 @@ class ViewsTestCase(SearxTestCase):
from searx import webapp # pylint disable=import-outside-toplevel
limiter.initialize(webapp.app, webapp.settings)
webapp.app.config['TESTING'] = True # to get better error messages
self.app = webapp.app.test_client()