Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocked domains flood gserver entries #12700

Merged
merged 3 commits into from
Jan 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/Model/GServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,19 +455,12 @@ public static function setBlockedByUrl(string $url)
* Set failed server status
*
* @param string $url
* @return void
*/
public static function setFailureByUrl(string $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']);
Expand All @@ -481,6 +474,14 @@ public static function setFailureByUrl(string $url)
return;
}

if (Network::isUrlBlocked($url)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block here is not needed. AFAIK we don't call this function at all for blocked servers. If we should, then we had to check earlier for blocked servers and should call the appropriate function from there.

Logger::info('Server domain is blocked', ['url' => $url]);
return;
} elseif (Network::isUrlBlocked($nurl)) {
Logger::info('Server domain is blocked', ['nurl' => $nurl]);
return;
}
Quix0r marked this conversation as resolved.
Show resolved Hide resolved

self::insert(['url' => $url, 'nurl' => $nurl,
'network' => Protocol::PHANTOM, 'created' => DateTimeFormat::utcNow(),
'failed' => true, 'last_failure' => DateTimeFormat::utcNow()]);
Expand Down
2 changes: 1 addition & 1 deletion src/Worker/UpdateServerPeers.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static function execute(string $url)
}

++$total;
if (DBA::exists('gserver', ['nurl' => Strings::normaliseLink('https://' . $peer)])) {
if (DBA::exists('gserver', ['nurl' => 'http://' . $peer])) {
Quix0r marked this conversation as resolved.
Show resolved Hide resolved
// We already know this server
continue;
}
Expand Down