]> git.mxchange.org Git - friendica.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Fri, 20 Jan 2023 00:49:11 +0000 (01:49 +0100)
committerRoland Häder <roland@mxchange.org>
Fri, 20 Jan 2023 00:50:55 +0000 (01:50 +0100)
- some trolls managed to flood gserver with useless URLs. They can be blocked
  by domain blocking them, but still it floods gserver table with dead entries
- this hack tries to change that so they won't enter gserver at all. Let's hope
  these trolls as `activitypub-trolls.cf` learn a lesson (and get adults soon)

Signed-off-by: Roland Häder <roland@mxchange.org>
src/Model/GServer.php

index 54e4d7220e875ce503f271a6c2e0e26aafea3160..468978d10c3ae867275de1ef88a834a49ad75656 100644 (file)
@@ -458,19 +458,30 @@ class GServer
         */
        public static function setFailureByUrl(string $url)
        {
-               $gserver = DBA::selectFirst('gserver', [], ['nurl' => Strings::normaliseLink($url)]);
+               $nurl = Strings::normaliseLink($url);
+
+               if (Network::isUrlBlocked($url)) {
+                       Logger::info('Server domain is blocked', ['url' => $url]);
+                       return;
+               } elseif (Network::isUrlBlocked($nurl)) {
+                       Logger::info('Server domain is blocked', ['nurl' => $nurl]);
+                       return;
+               }
+
+               $gserver = DBA::selectFirst('gserver', [], ['nurl' => $nurl]);
                if (DBA::isResult($gserver)) {
                        $next_update = self::getNextUpdateDate(false, $gserver['created'], $gserver['last_contact']);
                        self::update(['url' => $url, 'failed' => true, 'blocked' => Network::isUrlBlocked($url), 'last_failure' => DateTimeFormat::utcNow(),
                        'next_contact' => $next_update, 'network' => Protocol::PHANTOM, 'detection-method' => null],
-                       ['nurl' => Strings::normaliseLink($url)]);
+                       ['nurl' => $nurl]);
                        Logger::info('Set failed status for existing server', ['url' => $url]);
                        if (self::isDefunct($gserver)) {
                                self::archiveContacts($gserver['id']);
                        }
                        return;
                }
-               self::insert(['url' => $url, 'nurl' => Strings::normaliseLink($url),
+
+               self::insert(['url' => $url, 'nurl' => $nurl,
                        'network' => Protocol::PHANTOM, 'created' => DateTimeFormat::utcNow(),
                        'failed' => true, 'last_failure' => DateTimeFormat::utcNow()]);
                Logger::info('Set failed status for new server', ['url' => $url]);
@@ -560,6 +571,9 @@ class GServer
                                self::detect($url, $network, $only_nodeinfo);
                        }
                        return false;
+               } elseif (Network::isUrlBlocked($url)) {
+                       Logger::info('Server domain is blocked', ['url' => $url]);
+                       return false;
                }
 
                $valid_url = Network::isUrlValid($url);