aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/hubloc.php28
-rw-r--r--include/import.php45
-rw-r--r--include/network.php5
-rw-r--r--include/zot.php4
4 files changed, 39 insertions, 43 deletions
diff --git a/include/hubloc.php b/include/hubloc.php
index 6b896c627..6ab426a10 100644
--- a/include/hubloc.php
+++ b/include/hubloc.php
@@ -288,30 +288,18 @@ function locations_by_netid($netid) {
function ping_site($url) {
- $ret = array('success' => false);
+ $ret = array('success' => false);
- $sys = get_sys_channel();
+ $r = Zotlabs\Lib\Zotfinger::exec($url);
- $m = zot_build_packet($sys, 'ping');
- $r = zot_zot($url . '/post', $m);
- if(! $r['success']) {
- $ret['message'] = 'no answer from ' . $url;
- return $ret;
- }
- $packet_result = json_decode($r['body'], true);
- if(! $packet_result['success']) {
- $ret['message'] = 'packet failure from ' . $url;
- return $ret;
- }
+ if(! $r['data']) {
+ $ret['message'] = 'no answer from ' . $url;
+ return $ret;
+ }
- if($packet_result['success']) {
- $ret['success'] = true;
- }
- else {
- $ret['message'] = 'unknown error from ' . $url;
- }
+ $ret['success'] = true;
+ return $ret;
- return $ret;
}
diff --git a/include/import.php b/include/import.php
index 910cb8be7..82c23e116 100644
--- a/include/import.php
+++ b/include/import.php
@@ -210,17 +210,24 @@ function import_hublocs($channel, $hublocs, $seize, $moving = false) {
if($channel && $hublocs) {
foreach($hublocs as $hubloc) {
- $hash = make_xchan_hash($hubloc['hubloc_guid'],$hubloc['hubloc_guid_sig']);
- if($hubloc['hubloc_network'] === 'zot' && $hash !== $hubloc['hubloc_hash']) {
- logger('forged hubloc: ' . print_r($hubloc,true));
- continue;
- }
+ // verify the hash. We can only do this if we already stored the xchan corresponding to this hubloc
+ // as we need the public key from there
- if(! array_key_exists('hubloc_primary',$hubloc)) {
- $hubloc['hubloc_primary'] = (($hubloc['hubloc_flags'] & 0x0001) ? 1 : 0);
- $hubloc['hubloc_orphancheck'] = (($hubloc['hubloc_flags'] & 0x0004) ? 1 : 0);
- $hubloc['hubloc_error'] = (($hubloc['hubloc_status'] & 0x0003) ? 1 : 0);
- $hubloc['hubloc_deleted'] = (($hubloc['hubloc_flags'] & 0x1000) ? 1 : 0);
+ if ($hubloc['hubloc_network'] === 'zot6') {
+ $x = q("select xchan_pubkey from xchan where xchan_guid = '%s' and xchan_hash = '%s'",
+ dbesc($hubloc['hubloc_guid']),
+ dbesc($hubloc['hubloc_hash'])
+ );
+
+ if (! $x) {
+ logger('hubloc could not be verified. ' . print_r($hubloc,true));
+ continue;
+ }
+ $hash = Libzot::make_xchan_hash($hubloc['hubloc_guid'],$x[0]['xchan_pubkey']);
+ if ($hash !== $hubloc['hubloc_hash']) {
+ logger('forged hubloc: ' . print_r($hubloc,true));
+ continue;
+ }
}
if($moving && $hubloc['hubloc_hash'] === $channel['channel_hash'] && $hubloc['hubloc_url'] !== z_root()) {
@@ -228,17 +235,17 @@ function import_hublocs($channel, $hublocs, $seize, $moving = false) {
}
$arr = [
- 'guid' => $hubloc['hubloc_guid'],
- 'guid_sig' => $hubloc['hubloc_guid_sig'],
- 'url' => $hubloc['hubloc_url'],
- 'url_sig' => $hubloc['hubloc_url_sig'],
- 'sitekey' => ((array_key_exists('hubloc_sitekey',$hubloc)) ? $hubloc['hubloc_sitekey'] : '')
+ 'id' => $hubloc['hubloc_guid'],
+ 'id_sig' => $hubloc['hubloc_guid_sig'],
+ 'location' => $hubloc['hubloc_url'],
+ 'location_sig' => $hubloc['hubloc_url_sig']
];
- if(($hubloc['hubloc_hash'] === $channel['channel_hash']) && intval($hubloc['hubloc_primary']) && ($seize))
+ if (($hubloc['hubloc_hash'] === $channel['channel_hash']) && intval($hubloc['hubloc_primary']) && ($seize)) {
$hubloc['hubloc_primary'] = 0;
+ }
- if(($x = zot_gethub($arr,false)) === false) {
+ if (($x = Libzot::gethub($arr,false)) === false) {
unset($hubloc['hubloc_id']);
hubloc_store_lowlevel($hubloc);
}
@@ -1333,7 +1340,7 @@ function sync_files($channel, $files) {
'time' => $time,
'resource' => $att['hash'],
'revision' => 0,
- 'signature' => base64url_encode(rsa_sign($channel['channel_hash'] . '.' . $time, $channel['channel_prvkey']))
+ 'signature' => Libzot::sign($channel['channel_hash'] . '.' . $time, $channel['channel_prvkey'])
);
$store_path = $newfname;
@@ -1419,7 +1426,7 @@ function sync_files($channel, $files) {
'time' => $time,
'resource' => $p['resource_id'],
'revision' => 0,
- 'signature' => base64url_encode(rsa_sign($channel['channel_hash'] . '.' . $time, $channel['channel_prvkey'])),
+ 'signature' => Libzot::sign($channel['channel_hash'] . '.' . $time, $channel['channel_prvkey']),
'resolution' => intval($p['imgscale'])
);
diff --git a/include/network.php b/include/network.php
index 9d4c00ee8..bcd66cf85 100644
--- a/include/network.php
+++ b/include/network.php
@@ -2,6 +2,7 @@
use Zotlabs\Lib\Zotfinger;
use Zotlabs\Lib\Libzot;
+use Zotlabs\Lib\Queue;
/**
* @file include/network.php
@@ -1437,10 +1438,10 @@ function do_delivery($deliveries, $force = false) {
$x = q("select count(outq_hash) as total from outq where outq_delivered = 0");
- if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300)) && (! $force)) {
+ if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',3000)) && (! $force)) {
logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO);
foreach($deliveries as $d) {
- update_queue_item($d);
+ Queue::update($d);
}
return;
}
diff --git a/include/zot.php b/include/zot.php
index 8a2177de7..d61873ba2 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -3452,7 +3452,7 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
$x = q("select count(outq_hash) as total from outq where outq_delivered = 0");
- if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300))) {
+ if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',3000))) {
logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO);
update_queue_item($hash);
continue;
@@ -4286,7 +4286,7 @@ function zot_reply_message_request($data) {
$x = q("select count(outq_hash) as total from outq where outq_delivered = 0");
- if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300))) {
+ if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',3000))) {
logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO);
update_queue_item($hash);
continue;