Can we see somewhere what instances block us?

  • InternetPirate@lemmy.fmhy.ml
    link
    fedilink
    arrow-up
    15
    ·
    edit-2
    1 year ago

    To accomplish this task, you can use the lemmy-stats-crawler tool available on GitHub.

    ❯ git clone https://github.com/LemmyNet/lemmy-stats-crawler
    ❯ cd lemmy-stats-crawler
    ❯ cargo run -- --json > stats.json
    ❯ python3 instance_blocking_checker.py
    Enter the instance to find blocking instances: lemmy.fmhy.ml
    Instances blocking lemmy.fmhy.ml : ['feddit.de', 'civilloquy.com', 'thesimplecorner.org']
    

    To extract the list of instances blocking a given instance from a stats.json file similar to the one you provided, you can use the json module in Python. Here’s a script that takes user input and returns the list of instances blocking the given instance:

    instance_blocking_checker.py

    import json
    
    with open("stats.json", "r") as file:
        data = json.load(file)
    
    def find_blocking_instances(target_instance, data):
        blocking_instances = []
    
        for instance in data["instance_details"]:
            federated_instances = instance["site_info"]["federated_instances"]
            if federated_instances is not None and target_instance in (federated_instances.get("blocked") or []):
                blocking_instances.append(instance["domain"])
    
        return blocking_instances
    
    user_input = input("Enter the instance to find blocking instances: ")
    result = find_blocking_instances(user_input, data)
    print("Instances blocking", user_input, ":", result)
    

    When you run this script and input lemmy.fmhy.ml, it will output:

    Instances blocking lemmy.fmhy.ml : ['lemmy.ml']
    

    This script first loads the JSON data into a Python dictionary using json.loads() [1]. Then, it iterates through the instance_details list and checks if the given instance is in the blocked list of each instance. If it is, the domain of the blocking instance is added to the blocking_instances list. Finally, the script prints the list of instances blocking the given instance.

    Citations:

    [1] https://pynative.com/python/json/

    • inventa@lemmy.fmhy.mlOP
      link
      fedilink
      arrow-up
      4
      arrow-down
      2
      ·
      1 year ago

      Thanks for this. It’s a bit too complicated, hopefully at some point the info will be just available

        • InternetPirate@lemmy.fmhy.ml
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          1 year ago
          ❯ git clone https://github.com/LemmyNet/lemmy-stats-crawler
          ❯ cd lemmy-stats-crawler
          ❯ cargo run -- --json > stats.json
          ❯ python instance_analysis.py
          Enter the instance to find blocking instances: lemmy.fmhy.ml
          
          Instances blocking lemmy.fmhy.ml :
          feddit.de (642 users/day, 1317 users/week, 1397 users/month, 1441 users/half_year)
          civilloquy.com (1 users/day, 1 users/week, 2 users/month, 2 users/half_year)
          thesimplecorner.org (1 users/day, 1 users/week, 1 users/month, 1 users/half_year)
          
          Total users from blocking instances:
          644 users/day
          1319 users/week
          1400 users/month
          1444 users/half_year
          
          Instances blocked by lemmy.fmhy.ml :
          lemmygrad.ml (198 users/day, 388 users/week, 481 users/month, 726 users/half_year)
          
          Total users from blocked instances:
          198 users/day
          388 users/week
          481 users/month
          726 users/half_year
          

          instance_analysis.py

          import json
          
          with open("stats.json", "r") as file:
              data = json.load(file)
          
          def find_blocking_instances(target_instance, data):
              blocking_instances = []
              blocked_instances = []
          
              for instance in data["instance_details"]:
                  federated_instances = instance["site_info"]["federated_instances"]
                  if federated_instances is not None:
                      if target_instance in (federated_instances.get("blocked") or []):
                          blocking_instances.append(instance["domain"])
                      if instance["domain"] == target_instance:
                          blocked_instances.extend(federated_instances.get("blocked") or [])
          
              return blocking_instances, blocked_instances
          
          def get_instance_user_counts(instance):
              counts = instance["site_info"]["site_view"]["counts"]
              return {
                  "users_active_day": counts["users_active_day"],
                  "users_active_week": counts["users_active_week"],
                  "users_active_month": counts["users_active_month"],
                  "users_active_half_year": counts["users_active_half_year"],
              }
          
          def print_instance_activity(instance):
              domain = instance["domain"]
              counts = instance["site_info"]["site_view"]["counts"]
          
              print(f"{domain} ({counts['users_active_day']} users/day, {counts['users_active_week']} users/week, {counts['users_active_month']} users/month, {counts['users_active_half_year']} users/half_year)")
          
          total_blocking_users = {
              "users_active_day": 0,
              "users_active_week": 0,
              "users_active_month": 0,
              "users_active_half_year": 0,
          }
          
          total_blocked_users = {
              "users_active_day": 0,
              "users_active_week": 0,
              "users_active_month": 0,
              "users_active_half_year": 0,
          }
          
          user_input = input("Enter the instance to find blocking instances: ")
          blocking_instances, blocked_instances = find_blocking_instances(user_input, data)
          
          print("\nInstances blocking", user_input, ":")
          for domain in blocking_instances:
              for instance in data["instance_details"]:
                  if instance["domain"] == domain:
                      print_instance_activity(instance)
                      user_counts = get_instance_user_counts(instance)
                      for key in total_blocking_users:
                          total_blocking_users[key] += user_counts[key]
          
          print("\nTotal users from blocking instances:")
          print(f"{total_blocking_users['users_active_day']} users/day")
          print(f"{total_blocking_users['users_active_week']} users/week")
          print(f"{total_blocking_users['users_active_month']} users/month")
          print(f"{total_blocking_users['users_active_half_year']} users/half_year")
          
          print("\nInstances blocked by", user_input, ":")
          for domain in blocked_instances:
              for instance in data["instance_details"]:
                  if instance["domain"] == domain:
                      print_instance_activity(instance)
                      user_counts = get_instance_user_counts(instance)
                      for key in total_blocked_users:
                          total_blocked_users[key] += user_counts[key]
          
          print("\nTotal users from blocked instances:")
          print(f"{total_blocked_users['users_active_day']} users/day")
          print(f"{total_blocked_users['users_active_week']} users/week")
          print(f"{total_blocked_users['users_active_month']} users/month")
          print(f"{total_blocked_users['users_active_half_year']} users/half_year")
          
  • justooon@lemmy.fmhy.mlB
    link
    fedilink
    arrow-up
    13
    ·
    1 year ago

    If someone blocks fmhy, do they block “us” as in we can’t see their server or do they just block the posts originating from fmhy?

    • Kritical@lemmy.fmhy.ml
      link
      fedilink
      arrow-up
      5
      ·
      1 year ago

      Hmm, I wonder what lemmygrad did to deserve the ban here? I see they are a pretty hardcore Marxist instance, but curious if it’s just an ideology thingy with the admins here or if they did something to piss them off? It doesn’t appear to be mutual lemmygrad shares this instance, and they have a TON of others banned lol

      • damn@lemmy.fmhy.ml
        link
        fedilink
        arrow-up
        16
        arrow-down
        1
        ·
        1 year ago

        it’s not that they’re hardcore marxists but that they are tankies, you can find a lot of discussions about this out there

        • buckykat@lemmy.fmhy.ml
          link
          fedilink
          arrow-up
          4
          ·
          1 year ago

          Ideologically consistent Marxists, even tankies, wouldn’t support the capitalist imperialism of modern Russia.

          • zzzeyez@lemmy.fmhy.ml
            link
            fedilink
            arrow-up
            1
            ·
            1 year ago

            are they Marxist-Leninists (MLs)? like flagging Stalin etc and Communist Party stuff?

            i’m a Marxist anarchist and i’m just wondering if fmhy is a good server for my social circle. banning Marxists is not a good look (upon first reaction)

            • buckykat@lemmy.fmhy.ml
              link
              fedilink
              arrow-up
              1
              ·
              1 year ago

              I mean, you can go look at lemmygrad. I did when deciding which server to make an account on and found a bunch of people posting in support of current day not communist at all Russia. That goes beyond Marxism-Leninism into just supporting a neoliberal imperialist regime because it’s not the American neoliberal imperialist regime.

  • nullishcat@lemmy.fmhy.ml
    link
    fedilink
    arrow-up
    4
    ·
    1 year ago

    Not sure, I think the only way to know is to be an admin on the other instance (or if they say what instances are blocked)

    • montar@lemmy.fmhy.ml
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      Most instances publish their blocklists. Admins would be very angry if i would send a crawler to get lists of federated and blocked instances? It wouldn’t load single instance too much. Just two files.

  • InternetPirate@lemmy.fmhy.ml
    link
    fedilink
    arrow-up
    1
    arrow-down
    8
    ·
    edit-2
    1 year ago

    This is wrong but if you ask a chatbot multiple times perhaps it gives the correct answer:

    To accomplish this task, you can use the lemmy-stats-crawler tool available on GitHub. First, clone the repository using git clone https://github.com/LemmyNet/lemmy-stats-crawler.git. Then, navigate to the cloned directory using cd lemmy-stats-crawler and run the command cargo run -- --json > stats.json to generate a JSON file containing the stats.

    Next, you can create a script to extract the instances that are blocking lemmy.fmhy.ml. To do this, you can use the jq command-line tool to filter the JSON file based on the desired criteria. Here’s an example script that extracts the instances that are blocking lemmy.fmhy.ml:

    #!/bin/bash
    
    # Load the JSON file into a variable
    stats=$(cat stats.json)
    
    # Extract the instances that are blocking lemmy.fmhy.ml
    blocked_instances=$(echo "$stats" | jq '.[] | select(.blocking | contains(["lemmy.fmhy.ml"])) | .instance')
    
    # Print the results
    echo "Instances blocking lemmy.fmhy.ml:"
    echo "$blocked_instances"
    

    This script loads the JSON file into a variable, uses jq to filter the instances that are blocking lemmy.fmhy.ml, and prints the results. You can modify the script to extract other information from the JSON file as needed.

    Note that there is also a separate GitHub repository called lemmy-instance-stats that uses lemmy-stats-crawler to generate a JSON file of Lemmy instance statistics[1]. You may find this repository useful as well.

    Citations: [1] https://github.com/LemmyNet/lemmy-instance-stats