Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eterban
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eterban
Commits
95bbf460
Commit
95bbf460
authored
Jul 20, 2026
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
autoban: preserve permanent ban state
parent
ecfb3cae
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
autoban_manager.py
gateway/usr/share/eterban/autoban_manager.py
+9
-4
No files found.
gateway/usr/share/eterban/autoban_manager.py
View file @
95bbf460
...
@@ -79,6 +79,7 @@ class AutoBanManager:
...
@@ -79,6 +79,7 @@ class AutoBanManager:
# Получаем существующие метаданные
# Получаем существующие метаданные
existing
=
self
.
r
.
hgetall
(
meta_key
)
existing
=
self
.
r
.
hgetall
(
meta_key
)
is_permanent
=
self
.
r
.
sismember
(
self
.
PERMANENT_KEY
,
ip
)
if
existing
:
if
existing
:
offense_count
=
int
(
existing
.
get
(
b
'offense_count'
,
0
))
offense_count
=
int
(
existing
.
get
(
b
'offense_count'
,
0
))
...
@@ -90,7 +91,9 @@ class AutoBanManager:
...
@@ -90,7 +91,9 @@ class AutoBanManager:
offense_count
+=
1
offense_count
+=
1
else
:
else
:
offense_count
=
1
# Permanent state is authoritative even if old metadata was
# removed by a previous release's TTL or an admin reset.
offense_count
=
self
.
max_offense_level
+
1
if
is_permanent
else
1
# Рассчитываем время бана
# Рассчитываем время бана
ban_duration
=
self
.
calculate_ban_duration
(
offense_count
)
ban_duration
=
self
.
calculate_ban_duration
(
offense_count
)
...
@@ -107,14 +110,16 @@ class AutoBanManager:
...
@@ -107,14 +110,16 @@ class AutoBanManager:
}
}
self
.
r
.
hset
(
meta_key
,
mapping
=
metadata
)
self
.
r
.
hset
(
meta_key
,
mapping
=
metadata
)
# Устанавливаем TTL для очистки (1 год после последнего нарушения)
self
.
r
.
expire
(
meta_key
,
self
.
reset_period_seconds
)
# Добавляем в расписание авто-разбана или в постоянные
# Добавляем в расписание авто-разбана или в постоянные
if
unban_time
>
0
:
if
unban_time
>
0
:
# Temporary ban history can be reset after a clean period.
self
.
r
.
expire
(
meta_key
,
self
.
reset_period_seconds
)
self
.
r
.
zadd
(
self
.
SCHEDULE_KEY
,
{
ip
:
unban_time
})
self
.
r
.
zadd
(
self
.
SCHEDULE_KEY
,
{
ip
:
unban_time
})
self
.
r
.
srem
(
self
.
PERMANENT_KEY
,
ip
)
# На случай если был permanent
self
.
r
.
srem
(
self
.
PERMANENT_KEY
,
ip
)
# На случай если был permanent
else
:
else
:
# Permanent state must not disappear when temporary metadata
# would otherwise reach its one-year TTL.
self
.
r
.
persist
(
meta_key
)
self
.
r
.
sadd
(
self
.
PERMANENT_KEY
,
ip
)
self
.
r
.
sadd
(
self
.
PERMANENT_KEY
,
ip
)
self
.
r
.
zrem
(
self
.
SCHEDULE_KEY
,
ip
)
# Убираем из расписания
self
.
r
.
zrem
(
self
.
SCHEDULE_KEY
,
ip
)
# Убираем из расписания
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment