]> git.mxchange.org Git - fba.git/blobdiff - fba/commands.py
Continued:
[fba.git] / fba / commands.py
index bd755b73bba4faaac5120cf4bc9e2ecb204f3866..af246757c2fd9561a12419cb490e231c70ff1887 100644 (file)
@@ -72,6 +72,29 @@ def check_instance(args: argparse.Namespace) -> int:
     logger.debug("status=%d - EXIT!", status)
     return status
 
+def check_nodeinfo(args: argparse.Namespace) -> int:
+    logger.debug("args[]='%s' - CALLED!", type(args))
+
+    # Fetch rows
+    database.cursor.execute("SELECT domain, nodeinfo_url FROM instances WHERE nodeinfo_url IS NOT NULL ORDER BY domain ASC")
+
+    cnt = 0
+    for row in database.cursor.fetchall():
+        logger.debug("Checking row[domain]='%s',row[nodeinfo_url]='%s' ...", row["domain"], row["nodeinfo_url"])
+        punycode = row["domain"].encode("idna").decode("utf-8")
+
+        if row["nodeinfo_url"].startswith("/"):
+            logger.debug("row[nodeinfo_url]='%s' is a relative URL and always matches", row["nodeinfo_url"])
+            continue
+        elif row["nodeinfo_url"].find(punycode) == -1 and row["nodeinfo_url"].find(row["domain"]) == -1:
+            logger.warning("punycode='%s' is not found in row[nodeinfo_url]='%s'", punycode, row["nodeinfo_url"])
+            cnt = cnt + 1
+
+    logger.info("Found %d row(s)", cnt)
+
+    logger.debug("EXIT!")
+    return 0
+
 def fetch_pixelfed_api(args: argparse.Namespace) -> int:
     logger.debug("args[]='%s' - CALLED!", type(args))