]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Fri, 30 May 2025 12:30:37 +0000 (14:30 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 30 May 2025 12:30:37 +0000 (14:30 +0200)
- fixed bad POST requests for misskey (you should run ./fba.py fetch_blocks --software=misskey)
- added more headers for security checks

fba/commands.py
fba/http/network.py
fba/networks/misskey.py

index 32935528d84b2ce99ccec5e72ef1fb725c78f947..fd5bc219783857713487560256084d16b6d05ec0 100644 (file)
@@ -299,9 +299,11 @@ def fetch_blocks(args: argparse.Namespace) -> int:
         database.cursor.execute("SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software = ? OR original_software = ? ORDER BY last_blocked ASC, total_blocks DESC", [args.software, args.software])
     elif args.only_none:
         # Check only entries with total_blocked=None
+        logger.debug("Checking only entries with total_blocked=None ...")
         database.cursor.execute("SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'lemmy', 'friendica', 'misskey', 'piefed', 'typecho') AND nodeinfo_url IS NOT NULL AND total_blocks IS NULL ORDER BY last_blocked ASC, total_blocks DESC")
     else:
         # Re-check after "timeout" (aka. minimum interval)
+        logger.debug("Checking any federating software with possible blocklist ...")
         database.cursor.execute("SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'lemmy', 'friendica', 'misskey', 'piefed', 'typecho') AND nodeinfo_url IS NOT NULL ORDER BY last_blocked ASC, total_blocks DESC")
 
     # Load all rows
index fb7a7a9b38baef25b02785bc898231cfef246f6a..9f62316aba501486216de8cc7f8ef835817f2fd8 100644 (file)
@@ -40,8 +40,11 @@ web_headers = {
 
 # HTTP headers for API requests
 _api_headers = {
-    "User-Agent"  : config.get("useragent"),
-    "Content-Type": "application/json",
+    "User-Agent"    : config.get("useragent"),
+    "Content-Type"  : "application/json",
+    "Sec-Fetch-Dest": "empty",
+    "Sec-Fetch-Mode": "cors",
+    "Sec-Fetch-Site": "same-origin",
 }
 
 # Exceptions to always catch
@@ -86,6 +89,10 @@ def post_json_api(domain: str, path: str, data: str = "", headers: dict = {}) ->
         "status_code": 200,
     }
 
+    # Add domain as referer and origin
+    headers["Referer"] = f"https://{domain}/"
+    headers["Origin"]  = f"https://{domain}/"
+
     try:
         logger.debug("Sending POST to domain='%s',path='%s',data='%s',headers(%d)='%s'", domain, path, data, len(headers), headers)
         start = time.perf_counter()
index 5630cdbf5916b69940cbde1952d32828243210ff..6d56b454468e27ad10fcf3e17f8ad5ec59984d16 100644 (file)
@@ -165,19 +165,17 @@ def fetch_blocks(domain: str) -> list:
         try:
             logger.debug("Fetching offset=%d from domain='%s' ...", offset, domain)
             if offset == 0:
-                logger.debug("Sending JSON API request to domain='%s',step=%d,offset=%d", domain, step, offset)
+                logger.debug("Sending JSON API request to domain='%s',step=%d ...", domain, step)
                 fetched = network.post_json_api(domain, "/api/federation/instances", json.dumps({
-                    "sort"     : "+pubAt",
+                    "sort"     : "+pubSub",
                     "host"     : None,
-                    "suspended": True,
                     "limit"    : step
                 }), headers)
             else:
-                logger.debug("Sending JSON API request to domain='%s',step=%d,offset=%d", domain, step, offset)
+                logger.debug("Sending JSON API request to domain='%s',step=%d,offset=%d ...", domain, step, offset)
                 fetched = network.post_json_api(domain, "/api/federation/instances", json.dumps({
-                    "sort"     : "+pubAt",
+                    "sort"     : "+pubSub",
                     "host"     : None,
-                    "suspended": True,
                     "limit"    : step,
                     "offset"   : offset - 1
                 }), headers)