diff --git a/searx/botdetection/ip_limit.py b/searx/botdetection/ip_limit.py index 70863265e..5ff3c87ca 100644 --- a/searx/botdetection/ip_limit.py +++ b/searx/botdetection/ip_limit.py @@ -47,6 +47,7 @@ from ipaddress import ( import flask import werkzeug from searx.tools import config +from searx import settings from searx import redisdb from searx.redislib import incr_sliding_window, drop_counter @@ -109,7 +110,7 @@ def filter_request( if c > API_MAX: return too_many_requests(network, "too many request in API_WINDOW") - if cfg['botdetection.ip_limit.link_token']: + if settings['server']['public_instance'] or cfg['botdetection.ip_limit.link_token']: suspicious = link_token.is_suspicious(network, request, True) diff --git a/searx/plugins/limiter.py b/searx/plugins/limiter.py index a8beb5e88..24b14f3b4 100644 --- a/searx/plugins/limiter.py +++ b/searx/plugins/limiter.py @@ -3,6 +3,7 @@ # pyright: basic """see :ref:`limiter src`""" +import sys import flask from searx import redisdb @@ -23,10 +24,15 @@ def pre_request(): def init(app: flask.Flask, settings) -> bool: - if not settings['server']['limiter']: + if not settings['server']['limiter'] and not settings['server']['public_instance']: return False if not redisdb.client(): - logger.error("The limiter requires Redis") + logger.error( + "The limiter requires Redis, please consult the documentation: " + + "https://docs.searxng.org/admin/searx.botdetection.html#limiter" + ) + if settings['server']['public_instance']: + sys.exit(1) return False app.before_request(pre_request) return True diff --git a/searx/settings.yml b/searx/settings.yml index 3d9bee085..d0bf3412d 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -74,6 +74,7 @@ server: # by ${SEARXNG_URL}. base_url: false # "http://example.com/location" limiter: false # rate limit the number of request on the instance, block some bots + public_instance: false # enable features designed only for public instances # If your instance owns a /etc/searxng/settings.yml file, then set the following # values there. @@ -95,7 +96,7 @@ server: redis: # URL to connect redis database. Is overwritten by ${SEARXNG_REDIS_URL}. - # https://redis-py.readthedocs.io/en/stable/connections.html#redis.client.Redis.from_url + # https://docs.searxng.org/admin/settings/settings_redis.html#settings-redis url: false ui: diff --git a/searx/settings_defaults.py b/searx/settings_defaults.py index fa39796a3..ed3d6e24b 100644 --- a/searx/settings_defaults.py +++ b/searx/settings_defaults.py @@ -174,6 +174,7 @@ SCHEMA = { 'port': SettingsValue((int, str), 8888, 'SEARXNG_PORT'), 'bind_address': SettingsValue(str, '127.0.0.1', 'SEARXNG_BIND_ADDRESS'), 'limiter': SettingsValue(bool, False), + 'public_instance': SettingsValue(bool, False), 'secret_key': SettingsValue(str, environ_name='SEARXNG_SECRET'), 'base_url': SettingsValue((False, str), False, 'SEARXNG_BASE_URL'), 'image_proxy': SettingsValue(bool, False), diff --git a/searx/webapp.py b/searx/webapp.py index 9c7dbba1b..13a31d3e5 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -1294,6 +1294,7 @@ def config(): }, 'doi_resolvers': list(settings['doi_resolvers'].keys()), 'default_doi_resolver': settings['default_doi_resolver'], + 'public_instance': settings['server']['public_instance'], } )