addd exports path configuration variable and default values, restored old filename

This commit is contained in:
carnivuth
2026-02-02 14:19:40 +01:00
parent 09b986f1b0
commit 35c8a90013
3 changed files with 13 additions and 4 deletions

View File

@@ -25,6 +25,9 @@ dashboard:
# secret_path: super-secret-dashboard-path
secret_path: test
exports:
path: "exports"
database:
path: "data/krawl.db"
retention_days: 30
@@ -43,4 +46,4 @@ analyzer:
crawl:
infinite_pages_for_malicious: true
max_pages_limit: 250
ban_duration_seconds: 600
ban_duration_seconds: 600

View File

@@ -37,6 +37,8 @@ class Config:
infinite_pages_for_malicious: bool = True # Infinite pages for malicious crawlers
ban_duration_seconds: int = 600 # Ban duration in seconds for IPs exceeding limits
# exporter settings
exports_path: str = "exports"
# Database settings
database_path: str = "data/krawl.db"
database_retention_days: int = 30

View File

@@ -11,6 +11,7 @@ from firewall.fwtype import FWType
from firewall.iptables import Iptables
from firewall.raw import Raw
config = get_config()
app_logger = get_app_logger()
# ----------------------
@@ -24,7 +25,7 @@ TASK_CONFIG = {
}
EXPORTS_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "exports")
OUTPUT_FILE = os.path.join(EXPORTS_DIR, "malicious_ips.txt")
EXPORTS_DIR = config.exports_path
# ----------------------
@@ -52,7 +53,6 @@ def main():
)
# Filter out local/private IPs and the server's own IP
config = get_config()
server_ip = config.get_server_ip()
public_ips = [
@@ -71,7 +71,11 @@ def main():
fw = FWType.create(fwname)
banlist = fw.getBanlist(public_ips)
output_file = os.path.join(EXPORTS_DIR, f"{fwname}.txt")
output_file = os.path.join(EXPORTS_DIR, f"{fwname}_banlist.txt")
if fwname == "raw":
output_file = os.path.join(EXPORTS_DIR, f"malicious_ips.txt")
with open(output_file, "w") as f:
f.write(f"{banlist}\n")