这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@return42
Copy link
Member

@return42 return42 commented Oct 2, 2023

This PR is an alternative to #2882

It mainly consist of two commits ...

[mod] isolation of botdetection from the limiter

This patch was inspired by the discussion around PR-2882 [2]. The goals of this
patch are:

  1. Convert plugin searx.plugin.limiter to normal code [1]
  2. isolation of botdetection from the limiter [2]
  3. searx/{tools => botdetection}/config.py and drop searx.tools
  4. in URL /config, 'limiter.enabled' is true only if the limiter is really
    enabled (Redis is available).

This patch moves all the code that belongs to botdetection into namespace
searx.botdetection and code that belongs to limiter is placed in namespace
searx.limiter.

Tthe limiter used to be a plugin at some point botdetection was added, it was
not a plugin. The modularization of these two components was long overdue.
With the clear modularization, the documentation could then also be organized
according to the architecture.

[1] #2882
[2] #2882 (comment)

[mod] document server:public_instance & remove it out of the botdetection

  • the option server:public_instance lacks some documentation
  • the processing of this option belongs in the limiter and not
    in botdetection module

To test:

@return42 return42 force-pushed the split-limiter-botdetection branch 2 times, most recently from efe8f8d to d8e906c Compare October 2, 2023 16:39
@dalf
Copy link
Contributor

dalf commented Oct 3, 2023

Supersede by #2894

@return42 return42 force-pushed the split-limiter-botdetection branch from d8e906c to 5eb3f57 Compare October 29, 2023 08:30
This patch was inspired by the discussion around PR-2882 [2].  The goals of this
patch are:

1. Convert plugin searx.plugin.limiter to normal code [1]
2. isolation of botdetection from the limiter [2]
3. searx/{tools => botdetection}/config.py and drop searx.tools
4. in URL /config, 'limiter.enabled' is true only if the limiter is really
   enabled (Redis is available).

This patch moves all the code that belongs to botdetection into namespace
searx.botdetection and code that belongs to limiter is placed in namespace
searx.limiter.

Tthe limiter used to be a plugin at some point botdetection was added, it was
not a plugin.  The modularization of these two components was long overdue.
With the clear modularization, the documentation could then also be organized
according to the architecture.

[1] searxng#2882
[2] searxng#2882 (comment)

To test:

- check the app works without the limiter, check `/config`
- check the app works with the limiter and with the token, check `/config`
- make docs.live .. and read
  - http://0.0.0.0:8000/admin/searx.limiter.html
  - http://0.0.0.0:8000/src/searx.botdetection.html#botdetection

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
…tion

- the option server:public_instance lacks some documentation
- the processing of this option belongs in the limiter and not
  in botdetection module

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
@return42 return42 force-pushed the split-limiter-botdetection branch from 5eb3f57 to 76b41d3 Compare October 29, 2023 08:49
@return42 return42 merged commit d13a8f6 into searxng:master Nov 1, 2023
@return42 return42 deleted the split-limiter-botdetection branch November 1, 2023 05:44
cfg = get_cfg()
if settings['server']['public_instance']:
# overwrite limiter.toml setting
cfg.set('botdetection.ip_limit.link_token', True)
Copy link
Contributor

@dalf dalf Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about this either at the top of this function or in settings_default.py:

    if settings['server']['public_instance']:
        # overwrite limiter.toml setting
        cfg = get_cfg()
        cfg.set('botdetection.ip_limit.link_token', True)
        # overwrite settings.yml
        settings['server']['limiter'] = True

so:

  • b05a155 can be revert
  • line 222 can check settings['server']['limiter'] and there is no need to think about server.public_instance anymore in the future.
  • the code above describes all the changes made by server.public_instance in one place.

Copy link
Member Author

@return42 return42 Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b05a155 can be revert

not yet, see the "or" ..

get_setting('server.limiter') or get_setting('server.public_instance') 

the point is, that server.public_instance does not activate the server.limiter

I wanted to prepare a PR for this, but first I needed to merge this PR / to prevent a conflict of the new PR and this PR (the new PR needs to be on top of this PR here).

Copy link
Contributor

@dalf dalf Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the point is, that server.public_instance does not activate the server.limiter

??

ping @unixfox

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new parameter for the moment activate by default both the bot limiter AND the new advanced bot limiter called link_token.

searxng/searx-instances#417

So yes it should activate server.limiter

return42 added a commit to return42/searxng that referenced this pull request Nov 1, 2023
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] searxng#2894
- [2] searxng#2975

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
return42 added a commit to return42/searxng that referenced this pull request Nov 1, 2023
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] searxng#2894
- [2] searxng#2975

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
return42 added a commit to return42/searxng that referenced this pull request Jan 9, 2024
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] searxng#2894
- [2] searxng#2975

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
return42 added a commit to return42/searxng that referenced this pull request Feb 25, 2024
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] searxng#2894
- [2] searxng#2975

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
return42 added a commit to return42/searxng that referenced this pull request Feb 26, 2024
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] searxng#2894
- [2] searxng#2975

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants