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
39eecf67
Commit
39eecf67
authored
Jul 23, 2026
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gateway: restore ban sets atomically from Redis
parent
09671cd3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
eterban_switcher.py
gateway/usr/share/eterban/eterban_switcher.py
+12
-3
No files found.
gateway/usr/share/eterban/eterban_switcher.py
View file @
39eecf67
...
...
@@ -483,13 +483,22 @@ def restore_bans_from_redis():
grouped
[
setname
]
.
append
(
str
(
address
))
for
setname
,
addresses
in
grouped
.
items
():
temporary
=
setname
+
'_restore'
try
:
subprocess
.
run
([
'ipset'
,
'flush'
,
setname
],
check
=
True
,
timeout
=
10
)
run_command
([
'ipset'
,
'destroy'
,
temporary
],
stdout
=
subprocess
.
DEVNULL
,
stderr
=
subprocess
.
DEVNULL
)
create_command
=
[
'ipset'
,
'create'
,
temporary
,
'hash:ip'
,
'maxelem'
,
str
(
maxelem
)]
if
setname
==
ipset_eterban_1_ipv6
:
create_command
.
extend
([
'family'
,
'inet6'
])
subprocess
.
run
(
create_command
,
check
=
True
,
timeout
=
10
)
for
ip
in
addresses
:
subprocess
.
run
([
'ipset'
,
'add'
,
setname
,
ip
,
'-exist'
],
check
=
True
,
timeout
=
10
)
subprocess
.
run
([
'ipset'
,
'add'
,
temporary
,
ip
,
'-exist'
],
check
=
True
,
timeout
=
10
)
subprocess
.
run
([
'ipset'
,
'swap'
,
setname
,
temporary
],
check
=
True
,
timeout
=
10
)
except
(
OSError
,
subprocess
.
SubprocessError
)
as
error
:
log_redis_error
(
"Unable to restore "
+
setname
+
" from Redis: "
+
str
(
error
))
continue
finally
:
run_command
([
'ipset'
,
'destroy'
,
temporary
],
stdout
=
subprocess
.
DEVNULL
,
stderr
=
subprocess
.
DEVNULL
)
log_redis_error
(
"Restored "
+
str
(
sum
(
len
(
addresses
)
for
addresses
in
grouped
.
values
()))
+
" ban entries from Redis"
)
...
...
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