From: Roland Häder Date: Mon, 3 Jul 2023 18:04:45 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a2aca447bbec7560e80e0fa1b8582d7808764aec;p=fba.git Continued: - renamed /api/index.json to /api/top.json - count each checked domain and calculate percentage --- diff --git a/daemon.py b/daemon.py index af6cee9..cdc6ef5 100755 --- a/daemon.py +++ b/daemon.py @@ -103,7 +103,7 @@ def api_scoreboard(mode: str, amount: int): return scores -@router.get(config.get("base_url") + "/api/index.json", response_class=JSONResponse) +@router.get(config.get("base_url") + "/api/top.json", response_class=JSONResponse) def api_index(request: Request, mode: str, value: str, amount: int): if mode is None or value is None or amount is None: raise HTTPException(status_code=500, detail="No filter specified") @@ -131,7 +131,9 @@ def api_index(request: Request, mode: str, value: str, amount: int): if mode == "domain": database.cursor.execute("SELECT blocker, blocked, block_level, reason, first_seen, last_seen \ FROM blocks \ -WHERE blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? ORDER BY first_seen ASC LIMIT ?", +WHERE blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? \ +ORDER BY block_level ASC, first_seen ASC \ +LIMIT ?", [ domain, "*." + domain, @@ -292,7 +294,7 @@ def top(request: Request, mode: str, value: str, amount: int = config.get("api_l elif mode in ["domain", "reverse"] and not utils.is_domain_wanted(value): raise HTTPException(status_code=500, detail="Invalid or blocked domain specified") - response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/index.json?mode={mode}&value={value}&amount={amount}") + response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?mode={mode}&value={value}&amount={amount}") if response is not None: blocklist = response.json() diff --git a/fba/commands.py b/fba/commands.py index 231ec4e..05970a1 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -1390,10 +1390,11 @@ def update_nodeinfo(args: argparse.Namespace) -> int: domains = database.cursor.fetchall() logger.info("Checking %d domain(s) ...", len(domains)) + cnt = 0 for row in domains: logger.debug("row[]='%s'", type(row)) try: - logger.info("Checking nodeinfo for row[domain]='%s',row[software]='%s' ...", row["domain"], row["software"]) + logger.info("Checking nodeinfo for row[domain]='%s',row[software]='%s' (%s%%) ...", row["domain"], row["software"], "{:5.1f}".format(cnt / len(domains) * 100)) software = federation.determine_software(row["domain"]) logger.debug("Determined software='%s'", software) @@ -1408,6 +1409,7 @@ def update_nodeinfo(args: argparse.Namespace) -> int: instances.set_last_nodeinfo(row["domain"]) instances.update_data(row["domain"]) + cnt = cnt + 1 logger.debug("Success! - EXIT!") return 0