2021-12-03 03:01:39 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/** @file */
|
2016-05-20 02:42:45 +00:00
|
|
|
|
|
|
|
namespace Zotlabs\Daemon;
|
|
|
|
|
2018-06-01 02:42:13 +00:00
|
|
|
use Zotlabs\Lib\Libzot;
|
2018-08-28 02:09:48 +00:00
|
|
|
use Zotlabs\Lib\Webfinger;
|
|
|
|
use Zotlabs\Lib\Zotfinger;
|
2016-05-20 02:42:45 +00:00
|
|
|
|
|
|
|
// performs zot_finger on $argv[1], which is a hex_encoded webbie/reddress
|
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
class Gprobe
|
|
|
|
{
|
|
|
|
|
|
|
|
public static function run($argc, $argv)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if ($argc != 2) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$url = hex2bin($argv[1]);
|
|
|
|
$protocols = [];
|
|
|
|
|
|
|
|
if (! strpos($url, '@')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$r = q(
|
|
|
|
"select * from hubloc where hubloc_addr = '%s'",
|
|
|
|
dbesc($url)
|
|
|
|
);
|
|
|
|
|
|
|
|
if ($r) {
|
|
|
|
foreach ($r as $rv) {
|
|
|
|
if ($rv['hubloc_network'] === 'activitypub') {
|
|
|
|
$protocols[] = 'activitypub';
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ($rv['hubloc_network'] === 'zot6') {
|
|
|
|
$protocols[] = 'zot6';
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! in_array('zot6', $protocols)) {
|
|
|
|
$href = Webfinger::zot_url(punify($url));
|
2021-03-01 00:33:20 +00:00
|
|
|
if ($href) {
|
2021-12-03 03:01:39 +00:00
|
|
|
$zf = Zotfinger::exec($href, $channel);
|
2018-06-01 02:42:13 +00:00
|
|
|
}
|
2021-12-03 03:01:39 +00:00
|
|
|
if (is_array($zf) && array_path_exists('signature/signer', $zf) && $zf['signature']['signer'] === $href && intval($zf['signature']['header_valid']) && isset($zf['data']) && $zf['data']) {
|
2018-08-28 02:09:48 +00:00
|
|
|
$xc = Libzot::import_xchan($zf['data']);
|
2021-12-03 03:01:39 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-20 02:42:45 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-05-20 02:42:45 +00:00
|
|
|
}
|