-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Convert plugin searx.plugin.limiter to normal code #2882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The limiter plugin is not a plugin: * the user can't enable or disable the plugin and there is no point to allow that * the limiter does use any of the features provides by the plugin framework This commit convert the limiter plugin into normal code
c5b0d86 to
bee313c
Compare
return42
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't tested .. but left some comments in the code to make it a little bit more readable .. what do you think?
You now, that the limiter can be enabled without redis? .. the methods that probe HTTP headers do not need a redis. |
This is misleading, the variable is True only when the limiter is actually installed (Redis installed or not). searxng/searx/botdetection/install.py Lines 29 to 43 in bee313c
You can see that |
not sure .. there are also some title or chapter naming that might be better changed from "botdetection" to "limiter" .. lets focus on the code in this PR .. and in a follow up we can discuss how to reorder the documentation. |
In the past we had said the limiter is a simple builtin that limits request from an IP. My intention was real bot-detection as an (optional) addition to the builtin limiter. The Bot detection is a task that has nothing to do with the core of SearXNG, this should also be clearly visible on namespace level. The "module" botdetection should in principle be interchangeable and the limiter is the integration in SearXNG. The modularization of limiter and botdetection should keep the possibility open for us to integrate external modules or components into the limiter in the future. The only thing that would be missing at the moment is the definition of an interface between the limiter and the (external) bot detection. The currently existing modularization in the code would make this very easy. If we now merge the limiter with the botdetection this will not be so easy in the future. TL;DR; just imagine that today's namespace --> this is also the reason why this module has its own configuration .. 🤔 OK we can discuss if |
|
So the name is There is no need to solve this in this PR: here, the purpose is just to remove the plugin [*] does not make sense. [*] plugin as they are defined now. |
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] 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) Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
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>
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>
|
Supersede by #2894 |
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>
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>
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)
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>
What does this PR do?
The limiter plugin is not a plugin:
This commit convert the limiter plugin into normal code
Additional change: in
/config,limiter.enabledistrueonly if the limiter is really enabled (Redis is available).Why is this change important?
The limiter is shown as a plugin here and there and this is confusing.
How to test this PR locally?
/config/configAuthor's checklist
The initialization code is in
searx/botdetection/install.py, it can be insearx/botdetection/__init__.pyin the same way thatsearx.searchandsearx.redisdb.Alternative : move the code from
install.pytolimiter.py, but this lead to the next topic: naming ambiguity .There are two names to reference the same thing:
searx.botdetectionIs there a difference between the botdetection and the limiter ?
Since limiter is the known public name, I suggest:
searx.botdetectionintosearx.limitersearx/botdetection/limiter.pyandsearx/botdetection/install.pytosearx/limiter/__init__.py.Related issues
[EDIT] sorry for the numerous edits.