]> 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 blacklist
20 from fba.helpers import domain as domain_helper
21
22 logging.basicConfig(level=logging.INFO)
23 logger = logging.getLogger(__name__)
24 #logger.setLevel(logging.DEBUG)
25
26 # Blocklists hosted by oliphant
27 oliphant_blocklists = (
28     {
29         "blocker": "artisan.chat",
30         "csv_url": "mastodon/artisan.chat.csv",
31     },{
32         "blocker": "colorid.es",
33         "csv_url": "mastodon/colorid.es.csv",
34     },{
35         "blocker": "indiepocalypse.social",
36         "csv_url": "mastodon/indiepocalypse.social.csv",
37     },{
38         "blocker": "mastodon.art",
39         "csv_url": "mastodon/mastodon.art.csv",
40     },{
41         "blocker": "pleroma.envs.net",
42         "csv_url": "mastodon/pleroma.envs.net.csv",
43     },{
44         "blocker": "oliphant.social",
45         "csv_url": "mastodon/_unified_tier3_blocklist.csv",
46     },{
47         "blocker": "mastodon.online",
48         "csv_url": "mastodon/mastodon.online.csv",
49     },{
50         "blocker": "mastodon.social",
51         "csv_url": "mastodon/mastodon.social.csv",
52     },{
53         "blocker": "mastodon.social",
54         "csv_url": "other/missing-tier0-mastodon.social.csv",
55     },{
56         "blocker": "rage.love",
57         "csv_url": "mastodon/rage.love.csv",
58     },{
59         "blocker": "sunny.garden",
60         "csv_url": "mastodon/sunny.garden.csv",
61     },{
62         "blocker": "sunny.garden",
63         "csv_url": "mastodon/gardenfence.csv",
64     },{
65         "blocker": "solarpunk.moe",
66         "csv_url": "mastodon/solarpunk.moe.csv",
67     },{
68         "blocker": "toot.wales",
69         "csv_url": "mastodon/toot.wales.csv",
70     },{
71         "blocker": "union.place",
72         "csv_url": "mastodon/union.place.csv",
73     },{
74         "blocker": "oliphant.social",
75         "csv_url": "mastodon/birdsite.csv",
76     },
77 )
78
79 # Static URLs
80 txt_files = (
81     {
82         "blocker": "seirdy.one",
83         "url"    : "https://seirdy.one/pb/bsl.txt",
84     },{
85         "blocker": "seirdy.one",
86         "url"    : "https://seirdy.one/pb/FediNuke.txt",
87     },{
88         "blocker": "seirdy.one",
89         "url"    : "https://seirdy.one/pb/spammy-subdomains.txt",
90     }
91 )
92
93 # Other CSV files
94 csv_files = (
95     {
96         "blocker": "tooters.org",
97         "csv_url": "https://raw.githubusercontent.com/victorwynne/victorwynne/tooters/federation/tooters_defederations.csv",
98     },{
99         "blocker": "pleroma.envs.net",
100         "csv_url": "https://seirdy.one/pb/pleroma.envs.net.csv",
101     }
102 )
103
104 def has(domain: str) -> bool:
105     logger.debug("domain='%s' - CALLED!")
106     domain_helper.raise_on(domain)
107
108     if blacklist.is_blacklisted(domain):
109         raise ValueError(f"domain='{domain}' is blacklisted but function was invoked")
110
111     # Default is not found
112     found = False
113     for row in oliphant_blocklists + csv_files:
114         logger.debug("row[blocker]='%s',domain='%s'", row["blocker"], domain)
115         if row["blocker"] == domain:
116             found = True
117             logger.debug("domain='%s' is found and excluded from regular fetch_blocks command - BREAK!", domain)
118             break
119
120     logger.debug("found='%s' - EXIT!", found)
121     return found