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
a700dd4d
Commit
a700dd4d
authored
Jul 23, 2026
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gateway: retry stream commands idempotently
parent
39eecf67
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
15 deletions
+20
-15
autoban_manager.py
gateway/usr/share/eterban/autoban_manager.py
+3
-1
eterban_switcher.py
gateway/usr/share/eterban/eterban_switcher.py
+17
-14
No files found.
gateway/usr/share/eterban/autoban_manager.py
View file @
a700dd4d
...
@@ -140,7 +140,7 @@ class AutoBanManager:
...
@@ -140,7 +140,7 @@ class AutoBanManager:
reset_counter: Сбросить счётчик нарушений
reset_counter: Сбросить счётчик нарушений
"""
"""
if
not
self
.
enabled
:
if
not
self
.
enabled
:
return
return
True
try
:
try
:
# Удаляем из расписания и постоянных
# Удаляем из расписания и постоянных
...
@@ -151,9 +151,11 @@ class AutoBanManager:
...
@@ -151,9 +151,11 @@ class AutoBanManager:
if
reset_counter
:
if
reset_counter
:
pipeline
.
delete
(
f
"{self.META_PREFIX}{ip}"
)
pipeline
.
delete
(
f
"{self.META_PREFIX}{ip}"
)
pipeline
.
execute
()
pipeline
.
execute
()
return
True
except
Exception
as
e
:
except
Exception
as
e
:
log
.
error
(
f
"AutoBanManager.on_unban error: {e}"
)
log
.
error
(
f
"AutoBanManager.on_unban error: {e}"
)
return
False
def
get_expired_bans
(
self
):
def
get_expired_bans
(
self
):
"""
"""
...
...
gateway/usr/share/eterban/eterban_switcher.py
View file @
a700dd4d
...
@@ -574,8 +574,9 @@ def apply_unban(ip):
...
@@ -574,8 +574,9 @@ def apply_unban(ip):
return
False
return
False
queue_conntrack_cleanup
(
ip
)
queue_conntrack_cleanup
(
ip
)
if
auto_mgr
.
enabled
:
if
auto_mgr
.
enabled
and
not
auto_mgr
.
on_unban
(
ip
):
auto_mgr
.
on_unban
(
ip
)
log_redis_error
(
"Unable to update AutoBan state for unban "
+
ip
)
return
False
return
True
return
True
...
@@ -632,9 +633,9 @@ def process_message_inner(message):
...
@@ -632,9 +633,9 @@ def process_message_inner(message):
log
.
flush
()
log
.
flush
()
return
True
return
True
if
isinstance
(
ipo
,
ipaddress
.
IPv6Address
):
if
isinstance
(
ipo
,
ipaddress
.
IPv6Address
):
ban
=
[
'ipset'
,
'
-A'
,
ipset_eterban_1_ipv6
,
ip
]
ban
=
[
'ipset'
,
'
add'
,
ipset_eterban_1_ipv6
,
ip
,
'-exist'
]
else
:
else
:
ban
=
[
'ipset'
,
'
-A'
,
ipset_eterban_1
,
ip
]
ban
=
[
'ipset'
,
'
add'
,
ipset_eterban_1
,
ip
,
'-exist'
]
print
(
ban
)
print
(
ban
)
print
(
message
)
print
(
message
)
if
run_command
(
ban
)
!=
0
:
if
run_command
(
ban
)
!=
0
:
...
@@ -669,16 +670,18 @@ def process_message_inner(message):
...
@@ -669,16 +670,18 @@ def process_message_inner(message):
source
=
match
.
group
(
2
)
.
strip
()
source
=
match
.
group
(
2
)
.
strip
()
reason
=
match
.
group
(
3
)
if
match
.
group
(
3
)
else
'auto'
reason
=
match
.
group
(
3
)
if
match
.
group
(
3
)
else
'auto'
meta
=
auto_mgr
.
on_ban
(
ip
,
source
=
source
,
reason
=
reason
)
meta
=
auto_mgr
.
on_ban
(
ip
,
source
=
source
,
reason
=
reason
)
if
meta
:
if
not
meta
:
ban_duration
=
meta
.
get
(
'unban_time'
,
0
)
-
int
(
time
.
time
())
log_redis_error
(
"Unable to persist AutoBan metadata for "
+
ip
)
offense
=
meta
.
get
(
'offense_count'
,
1
)
return
False
if
ban_duration
>
0
:
ban_duration
=
meta
.
get
(
'unban_time'
,
0
)
-
int
(
time
.
time
())
auto_info
=
f
" -> offense #{offense}, auto-unban in {auto_mgr.format_duration(ban_duration)}
\n
"
offense
=
meta
.
get
(
'offense_count'
,
1
)
else
:
if
ban_duration
>
0
:
auto_info
=
f
" -> offense #{offense}, PERMANENT ban
\n
"
auto_info
=
f
" -> offense #{offense}, auto-unban in {auto_mgr.format_duration(ban_duration)}
\n
"
print
(
auto_info
)
else
:
log
.
write
(
auto_info
)
auto_info
=
f
" -> offense #{offense}, PERMANENT ban
\n
"
log
.
flush
()
print
(
auto_info
)
log
.
write
(
auto_info
)
log
.
flush
()
return
True
return
True
elif
message
is
not
None
:
elif
message
is
not
None
:
print
(
"AHTUNG!!1!"
,
message
)
print
(
"AHTUNG!!1!"
,
message
)
...
...
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