]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 8 Jun 2023 16:50:52 +0000 (18:50 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 8 Jun 2023 17:04:51 +0000 (19:04 +0200)
- also tidyup reason after fetching from instance
- moved validating domain to upper if/elif blocks
- re-color website to more friendlier colors
- rewrote some debug lines

fba/commands.py
fba/federation/pleroma.py
templates/base.html

index 408eadd52a669f35494b7b4e193b77a2984dc936..6df7cd962c0f7cfb00fe50cc8e36d3bd2a6d9445 100644 (file)
@@ -105,6 +105,7 @@ def fetch_bkali(args: argparse.Namespace):
 def fetch_blocks(args: argparse.Namespace):
     # DEBUG: print(f"DEBUG: args[]={type(args)} - CALLED!")
     if args.domain != None and args.domain != "":
+        # DEBUG: print(f"DEBUG: args.domain='{args.domain}' - checking ...")
         if not validators.domain(args.domain):
             print(f"WARNING: domain='{args.domain}' is not valid.")
             return
@@ -118,10 +119,12 @@ def fetch_blocks(args: argparse.Namespace):
     boot.acquire_lock()
 
     if args.domain != None and args.domain != "":
+        # Re-check single domain
         fba.cursor.execute(
             "SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'gotosocial', 'bookwyrm', 'takahe') AND domain = ?", [args.domain]
         )
     else:
+        # Re-check after "timeout" (aka. minimum interval)
         fba.cursor.execute(
             "SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'gotosocial', 'bookwyrm', 'takahe') AND (last_blocked IS NULL OR last_blocked < ?) ORDER BY rowid DESC", [time.time() - config.get("recheck_block")]
         )
@@ -170,9 +173,10 @@ def fetch_blocks(args: argparse.Namespace):
                     # DEBUG: print(f"DEBUG: Checking {len(blocklist)} entries from blocker='{blocker}',software='{software}',block_level='{block_level}' ...")
                     for block in blocklist:
                         blocked, reason = block.values()
-                        # DEBUG: print("DEBUG: BEFORE blocked:", blocked)
+                        # DEBUG: print(f"DEBUG: blocked='{blocked}',reason='{reason}' - BEFORE!")
                         blocked = fba.tidyup_domain(blocked)
-                        # DEBUG: print("DEBUG: AFTER blocked:", blocked)
+                        reason  = fba.tidyup_reason(reason)
+                        # DEBUG: print(f"DEBUG: blocked='{blocked}',reason='{reason}' - AFTER!")
 
                         if blocked == "":
                             print("WARNING: blocked is empty:", blocker)
index 3e47c01c2c19031ebfc9a2d888fd8608ddfdde71..7094ae462106e161dedb887463393a1d5758c8ce 100644 (file)
@@ -23,7 +23,7 @@ from fba import fba
 from fba import instances
 
 def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
-    print(f"DEBUG: domain='{domain}',origin='{origin}',nodeinfo_url='{nodeinfo_url}' - CALLED!")
+    # DEBUG: print(f"DEBUG: domain='{domain}',origin='{origin}',nodeinfo_url='{nodeinfo_url}' - CALLED!")
     if type(domain) != str:
         raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
     elif domain == "":
@@ -150,13 +150,17 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
 
                 # DEBUG: print(f"DEBUG: Checking {len(info.items())} entries from domain='{domain}',software='pleroma',block_level='{block_level}' ...")
                 for blocked, reason in info.items():
-                    # DEBUG: print("DEBUG: BEFORE blocked:", blocked)
+                    # DEBUG: print(f"DEBUG: blocked='{blocked}',reason='{reason}' - BEFORE!")
                     blocked = fba.tidyup_domain(blocked)
-                    # DEBUG: print("DEBUG: AFTER blocked:", blocked)
+                    reason = fba.tidyup_reason(reason)
+                    # DEBUG: print(f"DEBUG: blocked='{blocked}',reason='{reason}' - AFTER!")
 
                     if blocked == "":
                         print("WARNING: blocked is empty after fba.tidyup_domain():", domain, block_level)
                         continue
+                    elif not validators.domain(blocked):
+                        print(f"WARNING: blocked='{blocked}',software='pleroma' is not a valid domain name - skipped!")
+                        continue
                     elif blacklist.is_blacklisted(blocked):
                         # DEBUG: print(f"DEBUG: blocked='{blocked}' is blacklisted - skipping!")
                         continue
@@ -174,15 +178,9 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                         blocked = searchres[0]
                         origin = searchres[1]
                         nodeinfo_url = searchres[2]
-                    elif not validators.domain(blocked):
-                        print(f"WARNING: blocked='{blocked}',software='pleroma' is not a valid domain name - skipped!")
-                        continue
 
                     # DEBUG: print("DEBUG: Looking up instance by domain:", blocked)
-                    if not validators.domain(blocked):
-                        print(f"WARNING: blocked='{blocked}',software='pleroma' is not a valid domain name - skipped!")
-                        continue
-                    elif not instances.is_registered(blocked):
+                    if not instances.is_registered(blocked):
                         # DEBUG: print(f"DEBUG: Domain blocked='{blocked}' wasn't found, adding ..., domain='{domain}',origin='{origin}',nodeinfo_url='{nodeinfo_url}'")
                         instances.add(blocked, domain, inspect.currentframe().f_code.co_name, nodeinfo_url)
 
index 6933f3e744d5c825193fba5405998f7c52ce74a7..07700d2540e20a3e7d306e4ec68b071daf171f47 100644 (file)
@@ -2,64 +2,86 @@
 <head>
     <title>fedi-block-api - {% block title %}{% endblock %}</title>
     {% block rss %}
-    <link rel="alternate" type="application/rss+xml" title="RSS Feed for latest blocked instances" href="{{base_url}}/rss" />
+        <link rel="alternate" type="application/rss+xml" title="RSS Feed for latest blocked instances" href="{{base_url}}/rss" />
     {% endblock %}
     <style>
         body {
-            background-color: #000022;
-            color: #ffffff;
+            background-color: #ffffff;
+            color: #000022;
             text-align: center;
             font-family: sans;
         }
-        .block_level {
-            background-color: #1c1c3c;
-            width: 100%;
-            margin: auto;
-            margin-top: 10px;
+
+        #header {
+            margin-bottom: 20px;
         }
+
+        h1 {
+            background-color: #f0f0f0;
+            border-radius: 5px;
+            padding-left: 5px;
+            padding-right: 5px;
+            width: auto;
+        }
+
+        #content {
+            margin-bottom: 20px;
+        }
+
         table {
             width: 100%;
-            background-color: #2d2d4d;
             border-spacing: 0px;
         }
-        table tr:nth-of-type(2n) {
-            background-color: #1c1c3c;
+
+        th {
+            padding-top: 4px;
+            padding-bottom: 4px;
+        }
+
+        table tr:nth-of-type(2n), thead {
+            background-color: #f0f0f0;
         }
+
         table td {
             padding: 4px;
         }
+
+        .block_level {
+            width: 100%;
+            margin: auto;
+            margin-top: 10px;
+        }
         .block_level table td:nth-of-type(1), .block_level table td:nth-of-type(2),
         .block_level table td:nth-of-type(4), .block_level table td:nth-of-type(5) {
             white-space: nowrap;
         }
         .block {
-            background-color: #2d2d4d;
             padding: 5px;
             margin: 5px;
         }
+
         a {
-            color: #ffffff;
+            color: #000000;
         }
         a.listlink {
             text-decoration: none;
             font-size: 0.8em;
         }
+        a:hover {
+            color: #f00000;
+        }
+
         input[type="text"], input[type="submit"] {
             padding: 5px;
             border-radius: 5px;
-            color: white;
-            background: #445;
             font-size: 16px;
         }
-
         input[type="text"]:hover {
-            border-color: #f08;
+            border-color: #f00000;
         }
-
         input[type="submit"] {
             cursor: pointer;
         }
-
         input[type="submit"]:hover {
             border-color: #f08;
         }
             text-decoration: underline dotted;
         }
 
-        #content {
-            margin-bottom: 20px;
-        }
-
-        #header {
-            margin-bottom: 20px;
-        }
-
         .scoreboard {
             margin-left: auto;
             margin-right: auto;
@@ -84,6 +98,7 @@
         }
     </style>
 </head>
+
 <body>
     <div id="header">
         {% block header %}<h1>Page has no header</h1>{% endblock %}
 
     <div id="footer">
         {% block footer %}
-            source code: <a href="https://git.mxchange.org/?p=fba.git;a=summary" rel="source" target="_blank">git.mxchange.org</a><br /><br />
+            source code:
+            <a href="https://git.mxchange.org/?p=fba.git;a=summary" rel="source" target="_blank">git.mxchange.org</a><br /><br />
             {% if info %}
                 {{info.slogan}}
             {% elif slogan %}