Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.

Commit 9dc795d

Browse files
committed
don't connect to fascists
1 parent 9c733d6 commit 9dc795d

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# lists.d Mastodon Blocklist (c) 2022 Greyhat Academy LICENSED UNDER: CC-BY-NC-SA 4.0
2+
# https://raw.githubusercontent.com/greyhat-academy/lists.d/main/mastodon.domains.block.list.tsv
3+
# This list contains domains of toxic mastodon instances
4+
# Last-Modified: 1672044500
5+
6+
# gab - a neonazi social network
7+
gab.ai
8+
gab.com
9+
gab.protohype.net
10+
11+
# consequence-free speech
12+
social.unzensiert.to
13+
freeatlantis.com
14+
15+
# reactionary bigotry and hatespeech against magrinalized groups
16+
poa.st
17+
freespeechextremist.com
18+
rdrama.cc
19+
outpoa.st
20+
anime.website
21+
gameliberty.club
22+
social.byoblu.com
23+
yggdrasil.social
24+
smuglo.li
25+
dogeposting.social
26+
unsafe.space
27+
freezepeach.xyz
28+
29+
# + CSAM
30+
rojogato.com
31+
32+
# antivaxxer shitposting & fearmongering
33+
shadowsocial.org
34+
35+
# Kiwifarms
36+
kiwifarms.net
37+
kiwifarms.cc
38+
kiwifarms.is
39+
kiwifarms.pleroma.net

mastodon/src/main/java/org/joinmastodon/android/api/MastodonAPIController.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
import com.google.gson.JsonSyntaxException;
1313

1414
import org.joinmastodon.android.BuildConfig;
15+
import org.joinmastodon.android.MastodonApp;
1516
import org.joinmastodon.android.api.gson.IsoInstantTypeAdapter;
1617
import org.joinmastodon.android.api.gson.IsoLocalDateTypeAdapter;
1718
import org.joinmastodon.android.api.session.AccountSession;
1819

20+
import java.io.BufferedReader;
1921
import java.io.IOException;
22+
import java.io.InputStreamReader;
2023
import java.io.Reader;
2124
import java.time.Instant;
2225
import java.time.LocalDate;
@@ -47,18 +50,34 @@ public class MastodonAPIController{
4750
private static OkHttpClient httpClient=new OkHttpClient.Builder().build();
4851

4952
private AccountSession session;
53+
private static List<String> badDomains = new ArrayList<>();
5054

5155
static{
5256
thread.start();
57+
try {
58+
final BufferedReader reader = new BufferedReader(new InputStreamReader(
59+
MastodonApp.context.getAssets().open("blocks.tsv")
60+
));
61+
String line;
62+
while ((line = reader.readLine()) != null) {
63+
if (line.isBlank() || line.startsWith("#")) continue;
64+
badDomains.add(line.toLowerCase().trim());
65+
}
66+
} catch (IOException e) {
67+
e.printStackTrace();
68+
}
5369
}
5470

5571
public MastodonAPIController(@Nullable AccountSession session){
5672
this.session=session;
5773
}
5874

5975
public <T> void submitRequest(final MastodonAPIRequest<T> req){
76+
final String host = req.getURL().getHost().toLowerCase();
77+
final boolean isBad = badDomains.stream().anyMatch(host::endsWith);
6078
thread.postRunnable(()->{
6179
try{
80+
if (isBad) throw new IllegalArgumentException();
6281
if(req.canceled)
6382
return;
6483
Request.Builder builder=new Request.Builder()

0 commit comments

Comments
 (0)