addd exports path configuration variable and default values, restored old filename
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user