|
|
@@ -90,7 +90,9 @@ def _sync_quota_squid_rules(enabled: bool):
|
|
|
return
|
|
|
|
|
|
blocked_path = "/etc/squid/usuarios_bloqueados.txt"
|
|
|
- print(f"[DEBUG] _sync_quota_squid_rules: blocked_path={blocked_path}, enabled={enabled}")
|
|
|
+ print(
|
|
|
+ f"[DEBUG] _sync_quota_squid_rules: blocked_path={blocked_path}, enabled={enabled}"
|
|
|
+ )
|
|
|
_ensure_blocked_file(blocked_path)
|
|
|
|
|
|
def _normalize_line(line: str) -> str:
|
|
|
@@ -150,7 +152,9 @@ def _sync_quota_squid_rules(enabled: bool):
|
|
|
if enabled:
|
|
|
if not any(_matches_acl_entry(line) for line in acl_lines):
|
|
|
if use_src:
|
|
|
- print(f"[DEBUG] _apply_changes: modo src detectado, insertar include {acl_line}")
|
|
|
+ print(
|
|
|
+ f"[DEBUG] _apply_changes: modo src detectado, insertar include {acl_line}"
|
|
|
+ )
|
|
|
# include va al principio del bloque
|
|
|
acl_lines.insert(0, acl_line)
|
|
|
else:
|
|
|
@@ -181,7 +185,9 @@ def _sync_quota_squid_rules(enabled: bool):
|
|
|
|
|
|
if enabled:
|
|
|
if not any(_is_http_line(line) for line in http_lines):
|
|
|
- print("[DEBUG] _apply_changes: insertando http_access deny usuarios_bloqueados")
|
|
|
+ print(
|
|
|
+ "[DEBUG] _apply_changes: insertando http_access deny usuarios_bloqueados"
|
|
|
+ )
|
|
|
inserted = False
|
|
|
for i, line in enumerate(http_lines):
|
|
|
if line.strip().startswith("http_access "):
|
|
|
@@ -480,16 +486,22 @@ def register_quota_scheduler_tasks(scheduler):
|
|
|
new_blocked.append(user)
|
|
|
|
|
|
if new_blocked:
|
|
|
- print(f"[DEBUG] check_quota_users: {len(new_blocked)} nuevos bloqueos; use_src={use_src}")
|
|
|
+ print(
|
|
|
+ f"[DEBUG] check_quota_users: {len(new_blocked)} nuevos bloqueos; use_src={use_src}"
|
|
|
+ )
|
|
|
with open(file_path, "a", encoding="utf-8") as f:
|
|
|
for user in new_blocked:
|
|
|
if use_src:
|
|
|
line = f"acl usuarios_bloqueados src {user.username}\n"
|
|
|
- print(f"[DEBUG] appending to blocked file (src): {line.strip()}")
|
|
|
+ print(
|
|
|
+ f"[DEBUG] appending to blocked file (src): {line.strip()}"
|
|
|
+ )
|
|
|
f.write(line)
|
|
|
else:
|
|
|
line = f"{user.username}\n"
|
|
|
- print(f"[DEBUG] appending to blocked file (proxy_auth): {line.strip()}")
|
|
|
+ print(
|
|
|
+ f"[DEBUG] appending to blocked file (proxy_auth): {line.strip()}"
|
|
|
+ )
|
|
|
f.write(line)
|
|
|
_sync_blocked_file_to_docker(file_path)
|
|
|
|