Merge pull request #12700 from Quix0r/features/blocklist-gserver
Blocked domains flood gserver entries
This commit is contained in:
commit
0681f94334
|
@ -455,22 +455,34 @@ class GServer
|
||||||
* Set failed server status
|
* Set failed server status
|
||||||
*
|
*
|
||||||
* @param string $url
|
* @param string $url
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function setFailureByUrl(string $url)
|
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)) {
|
if (DBA::isResult($gserver)) {
|
||||||
$next_update = self::getNextUpdateDate(false, $gserver['created'], $gserver['last_contact']);
|
$next_update = self::getNextUpdateDate(false, $gserver['created'], $gserver['last_contact']);
|
||||||
self::update(['url' => $url, 'failed' => true, 'blocked' => Network::isUrlBlocked($url), 'last_failure' => DateTimeFormat::utcNow(),
|
self::update(['url' => $url, 'failed' => true, 'blocked' => Network::isUrlBlocked($url), 'last_failure' => DateTimeFormat::utcNow(),
|
||||||
'next_contact' => $next_update, 'network' => Protocol::PHANTOM, 'detection-method' => null],
|
'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]);
|
Logger::info('Set failed status for existing server', ['url' => $url]);
|
||||||
if (self::isDefunct($gserver)) {
|
if (self::isDefunct($gserver)) {
|
||||||
self::archiveContacts($gserver['id']);
|
self::archiveContacts($gserver['id']);
|
||||||
}
|
}
|
||||||
return;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
self::insert(['url' => $url, 'nurl' => $nurl,
|
||||||
'network' => Protocol::PHANTOM, 'created' => DateTimeFormat::utcNow(),
|
'network' => Protocol::PHANTOM, 'created' => DateTimeFormat::utcNow(),
|
||||||
'failed' => true, 'last_failure' => DateTimeFormat::utcNow()]);
|
'failed' => true, 'last_failure' => DateTimeFormat::utcNow()]);
|
||||||
Logger::info('Set failed status for new server', ['url' => $url]);
|
Logger::info('Set failed status for new server', ['url' => $url]);
|
||||||
|
@ -560,6 +572,9 @@ class GServer
|
||||||
self::detect($url, $network, $only_nodeinfo);
|
self::detect($url, $network, $only_nodeinfo);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
} elseif (Network::isUrlBlocked($url)) {
|
||||||
|
Logger::info('Server domain is blocked', ['url' => $url]);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$valid_url = Network::isUrlValid($url);
|
$valid_url = Network::isUrlValid($url);
|
||||||
|
|
|
@ -57,13 +57,13 @@ class UpdateServerPeers
|
||||||
$total = 0;
|
$total = 0;
|
||||||
$added = 0;
|
$added = 0;
|
||||||
foreach ($peers as $peer) {
|
foreach ($peers as $peer) {
|
||||||
if (Network::isUrlBlocked('http://' . $peer)) {
|
if (Network::isUrlBlocked('https://' . $peer)) {
|
||||||
// Ignore blocked systems as soon as possible in the loop to avoid being slowed down by tar pits
|
// Ignore blocked systems as soon as possible in the loop to avoid being slowed down by tar pits
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
++$total;
|
++$total;
|
||||||
if (DBA::exists('gserver', ['nurl' => Strings::normaliseLink('http://' . $peer)])) {
|
if (DBA::exists('gserver', ['nurl' => 'http://' . $peer])) {
|
||||||
// We already know this server
|
// We already know this server
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue