mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00

while PR #2357 [1] was being implemented the question came up:
would be better to change the PING resource from CSS to an image so that
some terminal based browser may still able to pass the test [1]
This patch implements a POC in where a <img src=token> tag is loaded instaed a
CSS.
To test this patch activate limiter and link_token method [3] and start a
developer instance::
make run
In your terminal browser open http://127.0.0.1:8888/search?q=foo
If the browser is suitable for the link_token method, it loads the image and the
following messages appear::
DEBUG searx.botdetection.limiter : OK 127.0.0.1/32: /clientft61aak7fzyu6o6v.svg ...
DEBUG searx.botdetection.link_token : token is valid --> True
DEBUG searx.botdetection.link_token : store ping_key for (client) network 127.0.0.1/32 (IP 127.0.0.1) -> SearXNG_limiter.ping[...]
Browsers that do not load images will be blocked: If you try by example::
lynx http://127.0.0.1:8888/search?q=foo
you will see a WARNING message like::
WARNING searx.botdetection.link_token : missing ping (IP: 127.0.0.1/32) / request: SearXNG_limiter.ping[...]
Modern terminal WEB browser do support `<img>` tag as well as CSS:
browsh http://127.0.0.1:8888/search?q=foo
----
[1] 80aaef6c95
[2] https://github.com/searxng/searxng/pull/2357#issuecomment-1574898834
[3] activate limiter and link_token method
```diff
diff --git a/searx/botdetection/limiter.toml b/searx/botdetection/limiter.toml
index 71a231e8f..7e1dba755 100644
--- a/searx/botdetection/limiter.toml
+++ b/searx/botdetection/limiter.toml
@@ -17,6 +17,6 @@ ipv6_prefix = 48
filter_link_local = false
# acrivate link_token method in the ip_limit method
-link_token = false
+link_token = true
diff --git a/searx/settings.yml b/searx/settings.yml
index a82a3432d..e7b983afc 100644
--- a/searx/settings.yml
+++ b/searx/settings.yml
@@ -73,7 +73,7 @@ server:
# public URL of the instance, to ensure correct inbound links. Is overwritten
# by ${SEARXNG_URL}.
base_url: false # "http://example.com/location"
- limiter: false # rate limit the number of request on the instance, block some bots
+ limiter: true # rate limit the number of request on the instance, block some bots
# If your instance owns a /etc/searxng/settings.yml file, then set the following
# values there.
```
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
90 lines
4.5 KiB
HTML
90 lines
4.5 KiB
HTML
<!DOCTYPE html>
|
||
<html class="no-js theme-{{ preferences.get_value('simple_style') or 'auto' }} center-aligment-{{ preferences.get_value('center_alignment') and 'yes' or 'no' }}" lang="{{ locale_rfc5646 }}" {% if rtl %} dir="rtl"{% endif %}>
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="description" content="SearXNG — a privacy-respecting, open metasearch engine">
|
||
<meta name="keywords" content="SearXNG, search, search engine, metasearch, meta search">
|
||
<meta name="generator" content="searxng/{{ searx_version }}">
|
||
<meta name="referrer" content="no-referrer">
|
||
<meta name="robots" content="noarchive">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<meta name="HandheldFriendly" content="True">
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
|
||
<title>{% block title %}{% endblock %}{{ instance_name }}</title>
|
||
{% block meta %}{% endblock %}
|
||
{% if rtl %}
|
||
<link rel="stylesheet" href="{{ url_for('static', filename='css/searxng-rtl.min.css') }}" type="text/css" media="screen">
|
||
{% else %}
|
||
<link rel="stylesheet" href="{{ url_for('static', filename='css/searxng.min.css') }}" type="text/css" media="screen">
|
||
{% endif %}
|
||
{% block styles %}{% endblock %}
|
||
<!--[if gte IE 9]>-->
|
||
<script src="{{ url_for('static', filename='js/searxng.head.min.js') }}" client_settings="{{ client_settings }}"></script>
|
||
<!--<![endif]-->
|
||
{% block head %}
|
||
<link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ opensearch_url }}">
|
||
{% endblock %}
|
||
<link rel="icon" href="{{ url_for('static', filename='img/favicon.png') }}" sizes="any">
|
||
<link rel="icon" href="{{ url_for('static', filename='img/favicon.svg') }}" type="image/svg+xml">
|
||
<link rel="apple-touch-icon" href="{{ url_for('static', filename='img/favicon.png') }}">
|
||
</head>
|
||
<body class="{{ endpoint }}_endpoint" >
|
||
<main id="main_{{ self._TemplateReference__context.name|replace("simple/", "")|replace(".html", "") }}" class="{{body_class}}">
|
||
{% if errors %}
|
||
<div class="dialog-error" role="alert">
|
||
<a href="#" class="close" aria-label="close" title="close">×</a>
|
||
<ul>
|
||
{% for message in errors %}
|
||
<li>{{ message }}</li>
|
||
{% endfor %}
|
||
</ul>
|
||
</div>
|
||
{% endif %}
|
||
|
||
<nav id="links_on_top">
|
||
{%- from 'simple/icons.html' import icon_big -%}
|
||
{%- block linkto_about -%}
|
||
<a href="{{ url_for('info', pagename='about') }}" class="link_on_top_about">{{ icon_big('information-circle-outline') }}<span>{{ _('About') }}</span></a>
|
||
{%- endblock -%}
|
||
{%- block linkto_donate -%}
|
||
{%- if donation_url -%}
|
||
<a href="{{ donation_url }}" class="link_on_top_donate">{{ icon_big('heart-outline') }}<span>{{ _('Donate') }}</span></a>
|
||
{%- endif -%}
|
||
{%- endblock -%}
|
||
{%- block linkto_preferences -%}
|
||
<a href="{{ url_for('preferences') }}" class="link_on_top_preferences">{{ icon_big('menu-outline') }}<span>{{ _('Preferences') }}</span></a>
|
||
{%- endblock -%}
|
||
</nav>
|
||
{% block header %}
|
||
{% endblock %}
|
||
{% block content %}
|
||
{% endblock %}
|
||
</main>
|
||
<footer>
|
||
<p>
|
||
{{ _('Powered by') }} <a href="{{ url_for('info', pagename='about') }}">searxng</a> - {{ searx_version }} — {{ _('a privacy-respecting, open metasearch engine') }}<br>
|
||
<a href="{{ searx_git_url }}">{{ _('Source code') }}</a>
|
||
| <a href="{{ get_setting('brand.issue_url') }}">{{ _('Issue tracker') }}</a>
|
||
{% if enable_metrics %}| <a href="{{ url_for('stats') }}">{{ _('Engine stats') }}</a>{% endif %}
|
||
{% if get_setting('brand.public_instances') %}
|
||
| <a href="{{ get_setting('brand.public_instances') }}">{{ _('Public instances') }}</a>
|
||
{% endif %}
|
||
{% if get_setting('general.privacypolicy_url') %}
|
||
| <a href="{{ get_setting('general.privacypolicy_url') }}">{{ _('Privacy policy') }}</a>
|
||
{% endif %}
|
||
{% if get_setting('general.contact_url') %}
|
||
| <a href="{{ get_setting('general.contact_url') }}">{{ _('Contact instance maintainer') }}</a>
|
||
{% endif %}
|
||
{% for title, link in get_setting('brand.custom.links').items() %}
|
||
| <a href="{{ link }}">{{ _(title) }}</a>
|
||
{% endfor %}
|
||
</p>
|
||
</footer>
|
||
<!--[if gte IE 9]>-->
|
||
<script src="{{ url_for('static', filename='js/searxng.min.js') }}"></script>
|
||
<!--<![endif]-->
|
||
{%- if get_setting('server.limiter') -%}
|
||
<img class='invisible' src="{{ url_for('client_token', token=link_token) }}">
|
||
{%- endif -%}
|
||
</body>
|
||
</html>
|