protected function notaryDiscovery(string $url) : array
{
$state = State::instance();
if (IDE_HACKS) {
$state->hail = new Hail(new Client());
}
$body = $state->hail->getReturnBody($url);
$pos = \strpos($body, '<meta name="airship-notary" content="');
if ($pos === false) {
// Notary not enabled:
return [];
}
$body = Util::subString($body, $pos + 37);
$end = \strpos($body, '"');
if (!$end) {
// Invalid
return [];
}
$tag = \explode('; ', Util::subString($body, 0, $end));
$channel = null;
$notary_url = null;
foreach ($tag as $t) {
list($k, $v) = \explode('=', $t);
if ($k === 'channel') {
$channel = $v;
} elseif ($k === 'url') {
$notary_url = $v;
}
}
return ['public_key' => $tag[0], 'channel' => $channel, 'url' => $notary_url];
}