]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 21 Jun 2023 01:52:49 +0000 (03:52 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 21 Jun 2023 01:52:49 +0000 (03:52 +0200)
- move fba.blacklist to fba.helpers package

fba/blacklist.py [deleted file]
fba/commands.py
fba/fba.py
fba/federation.py
fba/helpers/blacklist.py [new file with mode: 0644]
fba/models/blocks.py
fba/models/instances.py
fba/networks/lemmy.py
fba/networks/mastodon.py
fba/networks/misskey.py
fba/networks/pleroma.py

diff --git a/fba/blacklist.py b/fba/blacklist.py
deleted file mode 100644 (file)
index bbe097b..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-# Fedi API Block - An aggregator for fetching blocking data from fediverse nodes
-# Copyright (C) 2023 Free Software Foundation
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published
-# by the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Affero General Public License for more details.
-#
-# 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/>.
-
-# Don't check these, known trolls/flooders/testing/developing
-blacklist = [
-    # Floods federation with fake nodes as "research" project
-    "activitypub-troll.cf",
-    # Similar troll
-    "gab.best",
-    # Similar troll
-    "4chan.icu",
-    # Flooder (?)
-    "social.shrimpcam.pw",
-    # Flooder (?)
-    "mastotroll.netz.org",
-    # Testing/developing installations
-    "ngrok.io",
-    "ngrok-free.app",
-    "misskeytest.chn.moe",
-    # block flooder
-    "everyoneattack.com",
-]
-
-def is_blacklisted(domain: str) -> bool:
-    # DEBUG: print(f"DEBUG: domain='{domain}' - CALLED!")
-    if not isinstance(domain, str):
-        raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'")
-    elif domain == "":
-        raise ValueError("Parameter 'domain' is empty")
-
-    blacklisted = False
-    for peer in blacklist:
-        # DEBUG: print(f"DEBUG: Checking peer='{peer}' ...")
-        if peer in domain:
-            # DEBUG: print(f"DEBUG: domain='{domain}' is blacklisted.")
-            blacklisted = True
-
-    # DEBUG: print(f"DEBUG: blacklisted='{blacklisted}' - EXIT!")
-    return blacklisted
index f276a1f26fff63541c8e902de865767f7446ae55..4dca5fde1827a72078d6a2c5d1ea2dfcc290124a 100644 (file)
@@ -26,12 +26,12 @@ import markdown
 import reqto
 import validators
 
-from fba import blacklist
 from fba import config
 from fba import federation
 from fba import fba
 from fba import network
 
+from fba.helpers import blacklist
 from fba.helpers import cookies
 from fba.helpers import locking
 from fba.helpers import tidyup
index 335028c8cf824c16bb6d25ae5b0740edba32ae1b..db37abf699125098c845f36ca93e6c53a1b745e9 100644 (file)
@@ -21,10 +21,11 @@ from urllib.parse import urlparse
 import requests
 import validators
 
-from fba import blacklist
 from fba import federation
 from fba import network
 
+from fba.helpers import blacklist
+
 from fba.models import instances
 
 # Connect to database
index 1d154509fd2d58583a041c730118bd7e8f12a599..397e63b2cebbe76311058b5e72a3661529d4e27b 100644 (file)
@@ -18,11 +18,11 @@ from urllib.parse import urlparse
 import bs4
 import validators
 
-from fba import blacklist
 from fba import config
 from fba import csrf
 from fba import network
 
+from fba.helpers import blacklist
 from fba.helpers import tidyup
 from fba.helpers import version
 
diff --git a/fba/helpers/blacklist.py b/fba/helpers/blacklist.py
new file mode 100644 (file)
index 0000000..bbe097b
--- /dev/null
@@ -0,0 +1,52 @@
+# Fedi API Block - An aggregator for fetching blocking data from fediverse nodes
+# Copyright (C) 2023 Free Software Foundation
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# 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/>.
+
+# Don't check these, known trolls/flooders/testing/developing
+blacklist = [
+    # Floods federation with fake nodes as "research" project
+    "activitypub-troll.cf",
+    # Similar troll
+    "gab.best",
+    # Similar troll
+    "4chan.icu",
+    # Flooder (?)
+    "social.shrimpcam.pw",
+    # Flooder (?)
+    "mastotroll.netz.org",
+    # Testing/developing installations
+    "ngrok.io",
+    "ngrok-free.app",
+    "misskeytest.chn.moe",
+    # block flooder
+    "everyoneattack.com",
+]
+
+def is_blacklisted(domain: str) -> bool:
+    # DEBUG: print(f"DEBUG: domain='{domain}' - CALLED!")
+    if not isinstance(domain, str):
+        raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'")
+    elif domain == "":
+        raise ValueError("Parameter 'domain' is empty")
+
+    blacklisted = False
+    for peer in blacklist:
+        # DEBUG: print(f"DEBUG: Checking peer='{peer}' ...")
+        if peer in domain:
+            # DEBUG: print(f"DEBUG: domain='{domain}' is blacklisted.")
+            blacklisted = True
+
+    # DEBUG: print(f"DEBUG: blacklisted='{blacklisted}' - EXIT!")
+    return blacklisted
index 2111164e269e4468f3c5f7273119b397028eadda..0858d523b7591a0d014c94b91b9af88b84c33eca 100644 (file)
@@ -17,8 +17,9 @@
 import time
 import validators
 
-from fba import blacklist
 from fba import fba
+
+from fba.helpers import blacklist
 from fba.helpers import tidyup
 
 def update_reason(reason: str, blocker: str, blocked: str, block_level: str):
index 0ed262ed7b2aeb09f2db5bec69b2e495be1bac3c..836a1ef7430f1c4be36e19680d4fc37eb01720ab 100644 (file)
@@ -20,12 +20,12 @@ import time
 import requests
 import validators
 
-from fba import blacklist
 from fba import config
 from fba import fba
 from fba import federation
 from fba import network
 
+from fba.helpers import blacklist
 from fba.helpers import cache
 
 from fba.models import error_log
index e05c2ccb0442a43d9d0ef9355dd4fb951601b524..541dd55e7ad0b2a4689529876e23daacb14aad41 100644 (file)
@@ -19,13 +19,13 @@ import inspect
 import bs4
 import validators
 
-from fba import blacklist
 from fba import config
 from fba import csrf
 from fba import fba
 from fba import federation
 from fba import network
 
+from fba.helpers import blacklist
 from fba.helpers import tidyup
 
 from fba.models import blocks
index 61971afbe3a13fcbe800fa654a52eb1fc7a13571..9aeec1bf087415674c823dac526ecf08a194f5c3 100644 (file)
@@ -19,12 +19,12 @@ import inspect
 import bs4
 import validators
 
-from fba import blacklist
 from fba import config
 from fba import csrf
 from fba import fba
 from fba import network
 
+from fba.helpers import blacklist
 from fba.helpers import tidyup
 
 from fba.models import blocks
index 152d97107182d17c3774b320d4df79e220f1a3a5..3b93b542eaf76ac7714c21c8570e1e517fe83078 100644 (file)
 
 import json
 
-from fba import blacklist
 from fba import config
 from fba import csrf
 from fba import network
 
+from fba.helpers import blacklist
 from fba.helpers import dicts
 from fba.helpers import tidyup
 
index 546d7c59cb3db9445dbbf0e2e6ee4750984be1c8..75dfd2bb8dc733ed65cc49a8916faa89ec93ef03 100644 (file)
@@ -19,12 +19,12 @@ import inspect
 import bs4
 import validators
 
-from fba import blacklist
 from fba import config
 from fba import fba
 from fba import federation
 from fba import network
 
+from fba.helpers import blacklist
 from fba.helpers import tidyup
 
 from fba.models import blocks