Fetch platform and version of nomad implementations
This commit is contained in:
parent
5f52981255
commit
afe1a59345
|
@ -755,6 +755,10 @@ class GServer
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($serverdata['version']) && in_array($serverdata['platform'], ['osada']) && in_array($serverdata['detection-method'], [self::DETECT_CONTACTS, self::DETECT_BODY])) {
|
||||||
|
$serverdata['version'] = self::getNomadVersion($url);
|
||||||
|
}
|
||||||
|
|
||||||
// Detect the directory type
|
// Detect the directory type
|
||||||
$serverdata['directory-type'] = self::DT_NONE;
|
$serverdata['directory-type'] = self::DT_NONE;
|
||||||
|
|
||||||
|
@ -1499,14 +1503,15 @@ class GServer
|
||||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||||
$serverdata['site_name'] = JsonLD::fetchElement($actor, 'as:name', '@value');
|
$serverdata['site_name'] = JsonLD::fetchElement($actor, 'as:name', '@value');
|
||||||
$serverdata['info'] = JsonLD::fetchElement($actor, 'as:summary', '@value');
|
$serverdata['info'] = JsonLD::fetchElement($actor, 'as:summary', '@value');
|
||||||
if (!empty($actor['as:generator'])) {
|
if (self::isNomad($actor)) {
|
||||||
|
$serverdata['platform'] = self::getNomadName($actor['@id']);
|
||||||
|
$serverdata['version'] = self::getNomadVersion($actor['@id']);
|
||||||
|
$serverdata['detection-method'] = self::DETECT_SYSTEM_ACTOR;
|
||||||
|
} elseif (!empty($actor['as:generator'])) {
|
||||||
$generator = explode(' ', JsonLD::fetchElement($actor['as:generator'], 'as:name', '@value'));
|
$generator = explode(' ', JsonLD::fetchElement($actor['as:generator'], 'as:name', '@value'));
|
||||||
$serverdata['platform'] = strtolower(array_shift($generator));
|
$serverdata['platform'] = strtolower(array_shift($generator));
|
||||||
|
$serverdata['version'] = self::getNomadVersion($actor['@id']);
|
||||||
$serverdata['detection-method'] = self::DETECT_SYSTEM_ACTOR;
|
$serverdata['detection-method'] = self::DETECT_SYSTEM_ACTOR;
|
||||||
if (self::isNomad($actor)) {
|
|
||||||
$serverdata['version'] = $serverdata['platform'];
|
|
||||||
$serverdata['platform'] = 'nomad';
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$serverdata['detection-method'] = self::DETECT_AP_ACTOR;
|
$serverdata['detection-method'] = self::DETECT_AP_ACTOR;
|
||||||
}
|
}
|
||||||
|
@ -1550,6 +1555,49 @@ class GServer
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the name of Nomad implementation
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private static function getNomadName(string $url): string
|
||||||
|
{
|
||||||
|
$name = 'nomad';
|
||||||
|
$curlResult = DI::httpClient()->get($url . '/manifest', 'application/manifest+json');
|
||||||
|
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = json_decode($curlResult->getBody(), true);
|
||||||
|
if (empty($data)) {
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data['name'] ?? $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the version of the Nomad installation
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private static function getNomadVersion(string $url): string
|
||||||
|
{
|
||||||
|
$version = '';
|
||||||
|
$curlResult = DI::httpClient()->get($url . '/api/z/1.0/version', HttpClientAccept::JSON);
|
||||||
|
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
||||||
|
return $version;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = json_decode($curlResult->getBody(), true);
|
||||||
|
if (empty($data)) {
|
||||||
|
return $version;
|
||||||
|
}
|
||||||
|
return $data ?? $version;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the server contains a valid host meta file
|
* Checks if the server contains a valid host meta file
|
||||||
*
|
*
|
||||||
|
|
|
@ -111,7 +111,7 @@ class Federation extends BaseAdmin
|
||||||
|
|
||||||
if (in_array($gserver['platform'], ['Red Matrix', 'redmatrix', 'red'])) {
|
if (in_array($gserver['platform'], ['Red Matrix', 'redmatrix', 'red'])) {
|
||||||
$version['version'] = 'Red ' . $version['version'];
|
$version['version'] = 'Red ' . $version['version'];
|
||||||
} elseif (in_array($gserver['platform'], ['osada', 'mistpark', 'roadhouse', 'zap', 'macgirvin', 'mkultra'])) {
|
} elseif (in_array($gserver['platform'], ['osada', 'mistpark', 'roadhouse', 'streams', 'zap'])) {
|
||||||
$version['version'] = $gserver['platform'] . ' ' . $version['version'];
|
$version['version'] = $gserver['platform'] . ' ' . $version['version'];
|
||||||
} elseif (in_array($gserver['platform'], ['activityrelay', 'pub-relay', 'selective-relay', 'aoderelay'])) {
|
} elseif (in_array($gserver['platform'], ['activityrelay', 'pub-relay', 'selective-relay', 'aoderelay'])) {
|
||||||
$version['version'] = $gserver['platform'] . '-' . $version['version'];
|
$version['version'] = $gserver['platform'] . '-' . $version['version'];
|
||||||
|
@ -127,7 +127,7 @@ class Federation extends BaseAdmin
|
||||||
$platform = 'friendica';
|
$platform = 'friendica';
|
||||||
} elseif (in_array($platform, ['red matrix', 'redmatrix', 'red'])) {
|
} elseif (in_array($platform, ['red matrix', 'redmatrix', 'red'])) {
|
||||||
$platform = 'hubzilla';
|
$platform = 'hubzilla';
|
||||||
} elseif (in_array($platform, ['nomad', 'osada', 'mistpark', 'roadhouse', 'zap', 'macgirvin', 'mkultra'])) {
|
} elseif (in_array($platform, ['osada', 'mistpark', 'roadhouse', 'streams', 'zap'])) {
|
||||||
$platform = 'nomad';
|
$platform = 'nomad';
|
||||||
} elseif(stristr($platform, 'pleroma')) {
|
} elseif(stristr($platform, 'pleroma')) {
|
||||||
$platform = 'pleroma';
|
$platform = 'pleroma';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user