X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNetwork%2FProbe.php;h=008106ec3f41f6f60fd2b56d23286219465c803b;hb=a60a440c9af0caf5127c47bb59531138c906ea75;hp=deec3cf2dcb22f3bb0d51b6ee7a08c9492bf1caa;hpb=e9b7b812325b541836e2166ba54575692afc60d9;p=friendica.git diff --git a/src/Network/Probe.php b/src/Network/Probe.php index deec3cf2dc..008106ec3f 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -35,6 +35,7 @@ use DomXPath; class Probe { private static $baseurl; + private static $istimeout; /** * @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']); if ($curlResult->isTimeout()) { Logger::log("Probing timeout for " . $url, Logger::DEBUG); + self::$istimeout = true; return false; } $xml = $curlResult->getBody(); @@ -156,7 +158,7 @@ class Probe continue; } - if (($attributes["rel"] == "lrdd") && !empty($attributes["template"])) { + if (!empty($attributes["rel"]) && $attributes["rel"] == "lrdd" && !empty($attributes["template"])) { $type = (empty($attributes["type"]) ? '' : $attributes["type"]); $lrdd[$type] = $attributes["template"]; @@ -334,16 +336,24 @@ class Probe $uid = local_user(); } + self::$istimeout = false; + if ($network != Protocol::ACTIVITYPUB) { $data = self::detect($uri, $network, $uid); } else { $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)) { - $data = $ap_profile; + if (!empty($ap_profile) && empty($network) && (defaults($data, 'network', '') != Protocol::DFRN)) { + $data = $ap_profile; + } + } else { + Logger::notice('Time out detected. AP will not be probed.', ['uri' => $uri]); } if (!isset($data['url'])) { @@ -756,6 +766,7 @@ class Probe $curlResult = Network::curl($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => $type]); if ($curlResult->isTimeout()) { + self::$istimeout = true; return false; } $data = $curlResult->getBody(); @@ -824,6 +835,7 @@ class Probe { $curlResult = Network::curl($noscrape_url); if ($curlResult->isTimeout()) { + self::$istimeout = true; return false; } $content = $curlResult->getBody(); @@ -1075,6 +1087,7 @@ class Probe { $curlResult = Network::curl($hcard_url); if ($curlResult->isTimeout()) { + self::$istimeout = true; return false; } $content = $curlResult->getBody(); @@ -1327,6 +1340,7 @@ class Probe } elseif (Strings::normaliseLink($pubkey) == 'http://') { $curlResult = Network::curl($pubkey); if ($curlResult->isTimeout()) { + self::$istimeout = true; return false; } $pubkey = $curlResult->getBody(); @@ -1359,6 +1373,7 @@ class Probe // Fetch all additional data from the feed $curlResult = Network::curl($data["poll"]); if ($curlResult->isTimeout()) { + self::$istimeout = true; return false; } $feed = $curlResult->getBody(); @@ -1573,6 +1588,7 @@ class Probe { $curlResult = Network::curl($url); if ($curlResult->isTimeout()) { + self::$istimeout = true; return false; } $feed = $curlResult->getBody();