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
14bdc662
Commit
14bdc662
authored
Jul 20, 2026
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gateway: bound conntrack cleanup workers
parent
ec53d777
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
eterban_switcher.py
gateway/usr/share/eterban/eterban_switcher.py
+30
-3
No files found.
gateway/usr/share/eterban/eterban_switcher.py
View file @
14bdc662
...
@@ -10,6 +10,7 @@ import socket
...
@@ -10,6 +10,7 @@ import socket
import
ipaddress
import
ipaddress
import
threading
import
threading
import
re
import
re
import
queue
from
autoban_manager
import
AutoBanManager
from
autoban_manager
import
AutoBanManager
path_to_config
=
'/etc/eterban/settings.ini'
path_to_config
=
'/etc/eterban/settings.ini'
...
@@ -306,6 +307,33 @@ def log_redis_error(message):
...
@@ -306,6 +307,33 @@ def log_redis_error(message):
log
.
flush
()
log
.
flush
()
conntrack_queue
=
queue
.
Queue
(
maxsize
=
1024
)
def
conntrack_worker
():
while
True
:
ip
=
conntrack_queue
.
get
()
try
:
subprocess
.
run
(
[
'conntrack'
,
'-D'
,
'-s'
,
ip
],
stdout
=
subprocess
.
DEVNULL
,
stderr
=
subprocess
.
DEVNULL
,
timeout
=
5
)
except
(
OSError
,
subprocess
.
SubprocessError
)
as
error
:
log_redis_error
(
"conntrack cleanup failed for "
+
ip
+
": "
+
str
(
error
))
finally
:
conntrack_queue
.
task_done
()
def
queue_conntrack_cleanup
(
ip
):
try
:
conntrack_queue
.
put_nowait
(
ip
)
except
queue
.
Full
:
log_redis_error
(
"conntrack cleanup queue full; skipped "
+
ip
)
for
_
in
range
(
4
):
threading
.
Thread
(
target
=
conntrack_worker
,
daemon
=
True
)
.
start
()
def
get_ipset_members
(
setname
):
def
get_ipset_members
(
setname
):
"""Return valid address members from an ipset without parsing human output."""
"""Return valid address members from an ipset without parsing human output."""
try
:
try
:
...
@@ -440,7 +468,7 @@ def apply_unban(ip):
...
@@ -440,7 +468,7 @@ def apply_unban(ip):
if
not
remove_persisted_ban
(
ip
):
if
not
remove_persisted_ban
(
ip
):
return
False
return
False
subprocess
.
Popen
([
'conntrack'
,
'-D'
,
'-s'
,
ip
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
queue_conntrack_cleanup
(
ip
)
if
auto_mgr
.
enabled
:
if
auto_mgr
.
enabled
:
auto_mgr
.
on_unban
(
ip
)
auto_mgr
.
on_unban
(
ip
)
return
True
return
True
...
@@ -505,8 +533,7 @@ def process_message_inner(message):
...
@@ -505,8 +533,7 @@ def process_message_inner(message):
print
(
message
)
print
(
message
)
subprocess
.
call
(
ban
,
shell
=
True
)
subprocess
.
call
(
ban
,
shell
=
True
)
#subprocess.call (remove, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell = True)
#subprocess.call (remove, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell = True)
tcp_drop
=
'conntrack -D -s '
+
ip
queue_conntrack_cleanup
(
ip
)
subprocess
.
Popen
(
tcp_drop
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
elif
message
is
not
None
and
message
[
'type'
]
==
'message'
and
message
[
'channel'
]
==
b
'unban'
:
elif
message
is
not
None
and
message
[
'type'
]
==
'message'
and
message
[
'channel'
]
==
b
'unban'
:
print
(
message
)
print
(
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