-
Notifications
You must be signed in to change notification settings - Fork 331
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -455,22 +455,34 @@ public static function setBlockedByUrl(string $url) | |||||||||||||||||||||||||||||||||||||||||||||||
* Set failed server status | ||||||||||||||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||||||||||||||
* @param string $url | ||||||||||||||||||||||||||||||||||||||||||||||||
* @return void | ||||||||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||||||||
public static function setFailureByUrl(string $url) | ||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||
$gserver = DBA::selectFirst('gserver', [], ['nurl' => Strings::normaliseLink($url)]); | ||||||||||||||||||||||||||||||||||||||||||||||||
$nurl = Strings::normaliseLink($url); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
$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), | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
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; | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
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()]); | ||||||||||||||||||||||||||||||||||||||||||||||||
Logger::info('Set failed status for new server', ['url' => $url]); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -560,6 +572,9 @@ private static function detect(string $url, string $network = '', bool $only_nod | |||||||||||||||||||||||||||||||||||||||||||||||
self::detect($url, $network, $only_nodeinfo); | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
return false; | ||||||||||||||||||||||||||||||||||||||||||||||||
} elseif (Network::isUrlBlocked($url)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
Quix0r marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||
Logger::info('Server domain is blocked', ['url' => $url]); | ||||||||||||||||||||||||||||||||||||||||||||||||
return false; | ||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+575
to
+577
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean by "parent condition"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The condition where the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I usually only make a 2nd
Otherwise, when there is no code in between these two There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me provide a more actionable suggestion.
Suggested change
These condition have nothing to do with each other because of the |
||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
$valid_url = Network::isUrlValid($url); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
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.