]> git.mxchange.org Git - fba.git/blob - fba/helpers/blocklists.py
Continued:
[fba.git] / fba / helpers / blocklists.py
1 # Fedi API Block - An aggregator for fetching blocking data from fediverse nodes
2 # Copyright (C) 2023 Free Software Foundation
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published
6 # by the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU Affero General Public License for more details.
13 #
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
16
17 import logging
18
19 from fba.helpers import domain as domain_helper
20
21 logging.basicConfig(level=logging.INFO)
22 logger = logging.getLogger(__name__)
23 #logger.setLevel(logging.DEBUG)
24
25 # Blocklists hosted by oliphant
26 oliphant_blocklists = (
27     {
28         "blocker": "artisan.chat",
29         "csv_url": "mastodon/artisan.chat.csv",
30     },{
31         "blocker": "colorid.es",
32         "csv_url": "mastodon/colorid.es.csv",
33     },{
34         "blocker": "indiepocalypse.social",
35         "csv_url": "mastodon/indiepocalypse.social.csv",
36     },{
37         "blocker": "mastodon.art",
38         "csv_url": "mastodon/mastodon.art.csv",
39     },{
40         "blocker": "pleroma.envs.net",
41         "csv_url": "mastodon/pleroma.envs.net.csv",
42     },{
43         "blocker": "oliphant.social",
44         "csv_url": "mastodon/_unified_tier3_blocklist.csv",
45     },{
46         "blocker": "mastodon.online",
47         "csv_url": "mastodon/mastodon.online.csv",
48     },{
49         "blocker": "mastodon.social",
50         "csv_url": "mastodon/mastodon.social.csv",
51     },{
52         "blocker": "mastodon.social",
53         "csv_url": "other/missing-tier0-mastodon.social.csv",
54     },{
55         "blocker": "rage.love",
56         "csv_url": "mastodon/rage.love.csv",
57     },{
58         "blocker": "sunny.garden",
59         "csv_url": "mastodon/sunny.garden.csv",
60     },{
61         "blocker": "sunny.garden",
62         "csv_url": "mastodon/gardenfence.csv",
63     },{
64         "blocker": "solarpunk.moe",
65         "csv_url": "mastodon/solarpunk.moe.csv",
66     },{
67         "blocker": "toot.wales",
68         "csv_url": "mastodon/toot.wales.csv",
69     },{
70         "blocker": "union.place",
71         "csv_url": "mastodon/union.place.csv",
72     },{
73         "blocker": "oliphant.social",
74         "csv_url": "mastodon/birdsite.csv",
75     },
76 )
77
78 # Static URLs
79 txt_files = ({
80     "blocker": "seirdy.one",
81     "url"    : "https://seirdy.one/pb/bsl.txt",
82 },{
83     "blocker": "seirdy.one",
84     "url"    : "https://seirdy.one/pb/FediNuke.txt",
85 })
86
87 # Other CSV files
88 csv_files = (
89     {
90         "blocker": "tooters.org",
91         "csv_url": "https://raw.githubusercontent.com/victorwynne/victorwynne/tooters/federation/tooters_defederations.csv",
92     },{
93         "blocker": "pleroma.envs.net",
94         "csv_url": "https://seirdy.one/pb/pleroma.envs.net.csv",
95     }
96 )
97
98 def has(domain: str) -> bool:
99     logger.debug("domain='%s' - CALLED!")
100     domain_helper.raise_on(domain)
101
102     # Default is not found
103     found = False
104     for row in oliphant_blocklists + csv_files:
105         logger.debug("row[blocker]='%s',domain='%s'", row["blocker"], domain)
106         if row["blocker"] == domain:
107             found = True
108             logger.debug("domain='%s' is found and excluded from regular fetch_blocks command - BREAK!", domain)
109             break
110
111     logger.debug("found='%s' - EXIT!", found)
112     return found