Merge pull request #6862 from annando/probe-timeout
Fix for falsely detected AP profile in case of timeout
This commit is contained in:
commit
2ae5c2287a
|
@ -35,6 +35,7 @@ use DomXPath;
|
||||||
class Probe
|
class Probe
|
||||||
{
|
{
|
||||||
private static $baseurl;
|
private static $baseurl;
|
||||||
|
private static $istimeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Rearrange the array so that it always has the same order
|
* @brief Rearrange the array so that it always has the same order
|
||||||
|
@ -124,6 +125,7 @@ class Probe
|
||||||
$curlResult = Network::curl($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
|
$curlResult = Network::curl($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
Logger::log("Probing timeout for " . $url, Logger::DEBUG);
|
Logger::log("Probing timeout for " . $url, Logger::DEBUG);
|
||||||
|
self::$istimeout = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$xml = $curlResult->getBody();
|
$xml = $curlResult->getBody();
|
||||||
|
@ -334,16 +336,24 @@ class Probe
|
||||||
$uid = local_user();
|
$uid = local_user();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self::$istimeout = false;
|
||||||
|
|
||||||
if ($network != Protocol::ACTIVITYPUB) {
|
if ($network != Protocol::ACTIVITYPUB) {
|
||||||
$data = self::detect($uri, $network, $uid);
|
$data = self::detect($uri, $network, $uid);
|
||||||
} else {
|
} else {
|
||||||
$data = null;
|
$data = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ap_profile = ActivityPub::probeProfile($uri);
|
// When the previous detection process had got a time out
|
||||||
|
// we could falsely detect a Friendica profile as AP profile.
|
||||||
|
if (!self::$istimeout) {
|
||||||
|
$ap_profile = ActivityPub::probeProfile($uri);
|
||||||
|
|
||||||
if (!empty($ap_profile) && empty($network) && (defaults($data, 'network', '') != Protocol::DFRN)) {
|
if (!empty($ap_profile) && empty($network) && (defaults($data, 'network', '') != Protocol::DFRN)) {
|
||||||
$data = $ap_profile;
|
$data = $ap_profile;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Logger::notice('Time out detected. AP will not be probed.', ['url' => $url]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($data['url'])) {
|
if (!isset($data['url'])) {
|
||||||
|
@ -756,6 +766,7 @@ class Probe
|
||||||
|
|
||||||
$curlResult = Network::curl($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
|
$curlResult = Network::curl($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
|
self::$istimeout = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$data = $curlResult->getBody();
|
$data = $curlResult->getBody();
|
||||||
|
@ -824,6 +835,7 @@ class Probe
|
||||||
{
|
{
|
||||||
$curlResult = Network::curl($noscrape_url);
|
$curlResult = Network::curl($noscrape_url);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
|
self::$istimeout = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$content = $curlResult->getBody();
|
$content = $curlResult->getBody();
|
||||||
|
@ -1075,6 +1087,7 @@ class Probe
|
||||||
{
|
{
|
||||||
$curlResult = Network::curl($hcard_url);
|
$curlResult = Network::curl($hcard_url);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
|
self::$istimeout = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$content = $curlResult->getBody();
|
$content = $curlResult->getBody();
|
||||||
|
@ -1327,6 +1340,7 @@ class Probe
|
||||||
} elseif (Strings::normaliseLink($pubkey) == 'http://') {
|
} elseif (Strings::normaliseLink($pubkey) == 'http://') {
|
||||||
$curlResult = Network::curl($pubkey);
|
$curlResult = Network::curl($pubkey);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
|
self::$istimeout = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$pubkey = $curlResult->getBody();
|
$pubkey = $curlResult->getBody();
|
||||||
|
@ -1359,6 +1373,7 @@ class Probe
|
||||||
// Fetch all additional data from the feed
|
// Fetch all additional data from the feed
|
||||||
$curlResult = Network::curl($data["poll"]);
|
$curlResult = Network::curl($data["poll"]);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
|
self::$istimeout = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$feed = $curlResult->getBody();
|
$feed = $curlResult->getBody();
|
||||||
|
@ -1573,6 +1588,7 @@ class Probe
|
||||||
{
|
{
|
||||||
$curlResult = Network::curl($url);
|
$curlResult = Network::curl($url);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
|
self::$istimeout = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$feed = $curlResult->getBody();
|
$feed = $curlResult->getBody();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user