aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2018-12-09 16:37:15 -0800
committerzotlabs <mike@macgirvin.com>2018-12-09 16:37:15 -0800
commit214b81e49174b98f09382eec3ef2bd7ecf24ad01 (patch)
treef1d16273140bbc0f54438a27d124459573916931
parente60fb175242516382d1e1a61fce327c38515f3ee (diff)
downloadvolse-hubzilla-214b81e49174b98f09382eec3ef2bd7ecf24ad01.tar.gz
volse-hubzilla-214b81e49174b98f09382eec3ef2bd7ecf24ad01.tar.bz2
volse-hubzilla-214b81e49174b98f09382eec3ef2bd7ecf24ad01.zip
rmagic discovery for z6 networks
-rw-r--r--Zotlabs/Module/Rmagic.php18
-rwxr-xr-xboot.php1
-rw-r--r--include/network.php29
3 files changed, 48 insertions, 0 deletions
diff --git a/Zotlabs/Module/Rmagic.php b/Zotlabs/Module/Rmagic.php
index 33a6689ca..8c1e5cdab 100644
--- a/Zotlabs/Module/Rmagic.php
+++ b/Zotlabs/Module/Rmagic.php
@@ -14,6 +14,15 @@ class Rmagic extends \Zotlabs\Web\Controller {
$r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1",
dbesc($me)
);
+ if(! $r) {
+ $w = discover_by_webbie($me);
+ if($w) {
+ $r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1",
+ dbesc($me)
+ );
+ }
+ }
+
if($r) {
if($r[0]['hubloc_url'] === z_root())
goaway(z_root() . '/login');
@@ -49,7 +58,16 @@ class Rmagic extends \Zotlabs\Web\Controller {
$r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1",
dbesc($address)
);
+ if(! $r) {
+ $w = discover_by_webbie($address);
+ if($w) {
+ $r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1",
+ dbesc($address)
+ );
+ }
+ }
}
+
if($r) {
$url = $r[0]['hubloc_url'];
}
diff --git a/boot.php b/boot.php
index e49134a55..4087ec006 100755
--- a/boot.php
+++ b/boot.php
@@ -439,6 +439,7 @@ define ( 'TERM_OBJ_APP', 7 );
* various namespaces we may need to parse
*/
define ( 'PROTOCOL_ZOT', 'http://purl.org/zot/protocol' );
+define ( 'PROTOCOL_ZOT6', 'http://purl.org/zot/protocol/6.0' );
define ( 'NAMESPACE_ZOT', 'http://purl.org/zot' );
define ( 'NAMESPACE_DFRN' , 'http://purl.org/macgirvin/dfrn/1.0' );
define ( 'NAMESPACE_THREAD' , 'http://purl.org/syndication/thread/1.0' );
diff --git a/include/network.php b/include/network.php
index 183a47105..cd352e7db 100644
--- a/include/network.php
+++ b/include/network.php
@@ -1,4 +1,8 @@
<?php
+
+use Zotlabs\Lib\Zotfinger;
+use Zotlabs\Lib\Libzot;
+
/**
* @file include/network.php
* @brief Network related functions.
@@ -1196,6 +1200,31 @@ function discover_by_webbie($webbie, $protocol = '') {
}
}
}
+
+ foreach($x['links'] as $link) {
+ if(array_key_exists('rel',$link)) {
+ if($link['rel'] === PROTOCOL_ZOT6 && ((! $protocol) || (strtolower($protocol) === 'zot6'))) {
+ logger('zot6 found for ' . $webbie, LOGGER_DEBUG);
+ $record = Zotfinger::exec($link['href']);
+
+ // Check the HTTP signature
+
+ $hsig = $record['signature'];
+ if($hsig && ($hsig['signer'] === $url || $hsig['signer'] === $link['href']) && $hsig['header_valid'] === true && $hsig['content_valid'] === true)
+ $hsig_valid = true;
+
+ if(! $hsig_valid) {
+ logger('http signature not valid: ' . print_r($hsig,true));
+ continue;
+ }
+
+ $x = Libzot::import_xchan($record['data']);
+ if($x['success']) {
+ return $x['hash'];
+ }
+ }
+ }
+ }
}
logger('webfinger: ' . print_r($x,true), LOGGER_DATA, LOG_INFO);