Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LibreTranslate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Riße, Matthias
LibreTranslate
Commits
66f62efc
Commit
66f62efc
authored
3 years ago
by
Piero Toffanin
Browse files
Options
Downloads
Patches
Plain Diff
Tweak ban logic, update config description
parent
3a7527c4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/flood.py
+3
-2
3 additions, 2 deletions
app/flood.py
app/main.py
+1
-1
1 addition, 1 deletion
app/main.py
with
4 additions
and
3 deletions
app/flood.py
+
3
−
2
View file @
66f62efc
...
...
@@ -9,6 +9,7 @@ threshold = -1
def
forgive_banned
():
global
banned
global
threshold
clear_list
=
[]
...
...
@@ -16,7 +17,7 @@ def forgive_banned():
if
banned
[
ip
]
<=
0
:
clear_list
.
append
(
ip
)
else
:
banned
[
ip
]
-
=
1
banned
[
ip
]
=
min
(
threshold
,
banned
[
ip
])
-
1
for
ip
in
clear_list
:
del
banned
[
ip
]
...
...
@@ -29,7 +30,7 @@ def setup(violations_threshold=100):
threshold
=
violations_threshold
scheduler
=
BackgroundScheduler
()
scheduler
.
add_job
(
func
=
forgive_banned
,
trigger
=
"
interval
"
,
minutes
=
5
)
scheduler
.
add_job
(
func
=
forgive_banned
,
trigger
=
"
interval
"
,
minutes
=
60
)
scheduler
.
start
()
# Shut down the scheduler when exiting the app
...
...
This diff is collapsed.
Click to expand it.
app/main.py
+
1
−
1
View file @
66f62efc
...
...
@@ -40,7 +40,7 @@ def main():
default
=
DEFARGS
[
'
REQ_FLOOD_THRESHOLD
'
],
type
=
int
,
metavar
=
"
<number>
"
,
help
=
"
Set the maximum number of request limit offences
per 4 weeks
that a client can exceed before being banned. (%(default)s)
"
,
help
=
"
Set the maximum number of request limit offences that a client can exceed before being banned. (%(default)s)
"
,
)
parser
.
add_argument
(
"
--batch-limit
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment