fix: optimize IP key handling and enable decode responses for Redis client

This commit is contained in:
Théophile Diot 2024-11-25 17:11:59 +01:00
parent 82a98317ea
commit eee1e191e0
No known key found for this signature in database
GPG key ID: FA995104A0BA376A
2 changed files with 10 additions and 2 deletions

View file

@ -22,7 +22,7 @@ def bans_page():
bans = []
if redis_client:
for key in redis_client.scan_iter("bans_ip_*"):
ip = key.decode("utf-8").replace("bans_ip_", "")
ip = key.replace("bans_ip_", "")
data = redis_client.get(key)
if not data:
continue

View file

@ -394,7 +394,14 @@ def get_redis_client():
socket_keepalive=True,
max_connections=redis_keepalive_pool,
)
redis_client = sentinel.slave_for(sentinel_master, db=redis_db, username=username, password=password)
redis_client = sentinel.slave_for(
sentinel_master,
db=redis_db,
username=username,
password=password,
decode_responses=True,
)
else:
redis_client = Redis(
host=redis_host,
@ -407,6 +414,7 @@ def get_redis_client():
socket_keepalive=True,
max_connections=redis_keepalive_pool,
ssl=redis_ssl,
decode_responses=True,
)
try: