# DEBUG: print(f"DEBUG: Adding domain='{entry['domain']}' ...")
domains.append(entry["domain"])
- except BaseException as exception:
+ except (requests.exceptions.Timeout, requests.exceptions.ConnectionError) as exception:
print(f"ERROR: Cannot fetch graphql,exception[{type(exception)}]:'{str(exception)}'")
sys.exit(255)
mastodon.fetch_blocks(blocker, origin, nodeinfo_url)
elif software == "friendica" or software == "misskey":
print(f"INFO: blocker='{blocker}',software='{software}'")
+
+ blocking = list()
if software == "friendica":
- blocks = friendica.fetch_blocks(blocker)
+ blocking = friendica.fetch_blocks(blocker)
elif software == "misskey":
- blocks = misskey.fetch_blocks(blocker)
+ blocking = misskey.fetch_blocks(blocker)
- print(f"INFO: Checking {len(blocks.items())} entries from blocker='{blocker}',software='{software}' ...")
- for block_level, blocklist in blocks.items():
+ print(f"INFO: Checking {len(blocking.items())} entries from blocker='{blocker}',software='{software}' ...")
+ for block_level, blocklist in blocking.items():
# DEBUG: print("DEBUG: blocker,block_level,blocklist():", blocker, block_level, len(blocklist))
block_level = tidyup.domain(block_level)
# DEBUG: print("DEBUG: AFTER-block_level:", block_level)
print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!")
continue
- blocked = searchres[0]
- origin = searchres[1]
+ blocked = searchres[0]
+ origin = searchres[1]
nodeinfo_url = searchres[2]
elif blocked.count("?") > 0:
# Some obscure them with question marks, not sure if that's dependent on version or not
print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!")
continue
- blocked = searchres[0]
- origin = searchres[1]
+ blocked = searchres[0]
+ origin = searchres[1]
nodeinfo_url = searchres[2]
elif not validators.domain(blocked):
print(f"WARNING: blocked='{blocked}',software='{software}' is not a valid domain name - skipped!")
import re
import json
import sqlite3
-import sys
import time
from urllib.parse import urlparse
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
-import sys
-
import bs4
import validators
# DEBUG: print("DEBUG: Added instance(s) to peers")
else:
print("WARNING: JSON response does not contain 'federated_instances':", domain)
- instances.update_last_error(domain, response)
+ instances.update_last_error(domain, data)
else:
# DEBUG: print("DEBUG: Querying API was successful:", domain, len(data))
peers = data["json"]
# DEBUG: print(f"DEBUG: data['{type(data)}']='{data}'")
if "error_message" in data:
print("WARNING: Could not reach any JSON API:", domain)
- instances.update_last_error(domain, response)
+ instances.update_last_error(domain, data)
elif "federated_instances" in data["json"]:
# DEBUG: print(f"DEBUG: Found federated_instances for domain='{domain}'")
peers = peers + federation.add_peers(data["json"]["federated_instances"])
import inspect
import bs4
+import requests
import validators
from fba import blacklist
try:
# json endpoint for newer mastodongs
blockdict = list()
- try:
- rows = {
- "reject" : [],
- "media_removal" : [],
- "followers_only": [],
- "report_removal": [],
- }
+ rows = {
+ "reject" : [],
+ "media_removal" : [],
+ "followers_only": [],
+ "report_removal": [],
+ }
- # DEBUG: print("DEBUG: Querying API domain_blocks:", domain)
- data = network.get_json_api(
- domain,
- "/api/v1/instance/domain_blocks",
- (config.get("connection_timeout"), config.get("read_timeout"))
- )
-
- if "error_message" in data:
- print(f"WARNING: Was not able to fetch domain_blocks from domain='{domain}': status_code='{data['status_code']}',error_message='{data['error_message']}'")
- instances.update_last_error(domain, data)
+ # DEBUG: print("DEBUG: Querying API domain_blocks:", domain)
+ data = network.get_json_api(
+ domain,
+ "/api/v1/instance/domain_blocks",
+ (config.get("connection_timeout"), config.get("read_timeout"))
+ )
+ if "error_message" in data:
+ print(f"WARNING: Was not able to fetch domain_blocks from domain='{domain}': status_code='{data['status_code']}',error_message='{data['error_message']}'")
+ instances.update_last_error(domain, data)
+ else:
+ # Getting blocklist
blocklist = data["json"]
+
+ if len(blocklist) > 0:
print(f"INFO: Checking {len(blocklist)} entries from domain='{domain}',software='mastodon' ...")
for block in blocklist:
+ # Map block -> entry
entry = {
- 'domain': block['domain'],
- 'hash' : block['digest'],
- 'reason': block['comment']
+ "domain": block["domain"],
+ "hash" : block["digest"],
+ "reason": block["comment"]
}
# DEBUG: print("DEBUG: severity,domain,hash,comment:", block['severity'], block['domain'], block['digest'], block['comment'])
rows['report_removal'].append(entry)
else:
print("WARNING: Unknown severity:", block['severity'], block['domain'])
-
- except BaseException as exception:
- # DEBUG: print(f"DEBUG: Failed, trying mastodon-specific fetches: domain='{domain}',exception[{type(exception)}]={str(exception)}")
+ else:
+ # DEBUG: print(f"DEBUG: domain='{domain}' has returned zero rows, trying /about/more page ...")
rows = fetch_blocks_from_about(domain)
print(f"INFO: Checking {len(rows.items())} entries from domain='{domain}',software='mastodon' ...")
# DEBUG: print("DEBUG: Committing changes ...")
fba.connection.commit()
- except BaseException as exception:
+ except (requests.exceptions.Timeout, requests.exceptions.ConnectionError) as exception:
print(f"ERROR: domain='{domain}',software='mastodon',exception[{type(exception)}]:'{str(exception)}'")
# DEBUG: print("DEBUG: EXIT!")
import json
+import requests
+
from fba import blacklist
from fba import config
from fba import instances
# DEBUG: print("DEBUG: API is no more returning new instances, aborting loop!")
break
- except BaseException as exception:
- print("WARNING: Caught error, exiting loop:", domain, exception)
+ except (requests.exceptions.Timeout, requests.exceptions.ConnectionError) as exception:
+ print(f"WARNING: Caught error, exiting loop: domain='{domain}',exception[{type(exception)}]='{str(exception)}'")
instances.update_last_error(domain, exception)
offset = 0
break
# DEBUG: print("DEBUG: API is no more returning new instances, aborting loop!")
break
- except BaseException as exception:
- print("ERROR: Exception during POST:", domain, exception)
+ except (requests.exceptions.Timeout, requests.exceptions.ConnectionError) as exception:
+ print(f"WARNING: Caught error, exiting loop: domain='{domain}',exception[{type(exception)}]='{str(exception)}'")
instances.update_last_error(domain, exception)
offset = 0
break