need better peer verification due to re-install issue, this is temporary
This commit is contained in:
parent
e09b49288f
commit
2fbfc2a8f1
@ -292,7 +292,8 @@ function channel_remove($channel_id, $local = true, $unset_session=true) {
|
|||||||
intval($channel_id)
|
intval($channel_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
logger('deleting hublocs',LOGGER_DEBUG);
|
||||||
|
|
||||||
$r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'",
|
$r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'",
|
||||||
dbesc($channel['channel_hash'])
|
dbesc($channel['channel_hash'])
|
||||||
);
|
);
|
||||||
@ -349,6 +350,8 @@ function channel_remove($channel_id, $local = true, $unset_session=true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
logger('deleting hublocs',LOGGER_DEBUG);
|
||||||
|
|
||||||
$r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s' and hubloc_url = '%s' ",
|
$r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s' and hubloc_url = '%s' ",
|
||||||
dbesc($channel['channel_hash']),
|
dbesc($channel['channel_hash']),
|
||||||
dbesc(z_root())
|
dbesc(z_root())
|
||||||
|
@ -2373,6 +2373,7 @@ function sync_locations($sender, $arr, $absolute = false) {
|
|||||||
$changed = true;
|
$changed = true;
|
||||||
}
|
}
|
||||||
elseif((! intval($r[0]['hubloc_deleted'])) && (intval($location['deleted']))) {
|
elseif((! intval($r[0]['hubloc_deleted'])) && (intval($location['deleted']))) {
|
||||||
|
logger('deleting hubloc: ' . $r[0]['hubloc_addr']);
|
||||||
$n = q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id = %d",
|
$n = q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id = %d",
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
intval($r[0]['hubloc_id'])
|
intval($r[0]['hubloc_id'])
|
||||||
@ -2427,7 +2428,7 @@ function sync_locations($sender, $arr, $absolute = false) {
|
|||||||
if($absolute && $xisting) {
|
if($absolute && $xisting) {
|
||||||
foreach($xisting as $x) {
|
foreach($xisting as $x) {
|
||||||
if(! array_key_exists('updated',$x)) {
|
if(! array_key_exists('updated',$x)) {
|
||||||
logger('sync_locations: deleting unreferenced hub location ' . $x['hubloc_url']);
|
logger('sync_locations: deleting unreferenced hub location ' . $x['hubloc_addr']);
|
||||||
$r = q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id = %d",
|
$r = q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id = %d",
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
intval($x['hubloc_id'])
|
intval($x['hubloc_id'])
|
||||||
@ -2468,7 +2469,7 @@ function zot_encode_locations($channel) {
|
|||||||
// so that nobody tries to use it.
|
// so that nobody tries to use it.
|
||||||
|
|
||||||
if(intval($channel['channel_removed']) && $hub['hubloc_url'] === z_root())
|
if(intval($channel['channel_removed']) && $hub['hubloc_url'] === z_root())
|
||||||
$hub['hubloc_deleted'] = true;
|
$hub['hubloc_deleted'] = 1;
|
||||||
|
|
||||||
$ret[] = array(
|
$ret[] = array(
|
||||||
'host' => $hub['hubloc_host'],
|
'host' => $hub['hubloc_host'],
|
||||||
|
73
mod/post.php
73
mod/post.php
@ -663,16 +663,16 @@ function post_post(&$a) {
|
|||||||
|
|
||||||
/* Check if the sender is already verified here */
|
/* Check if the sender is already verified here */
|
||||||
|
|
||||||
$hub = zot_gethub($sender);
|
$hubs = zot_gethub($sender,true);
|
||||||
|
|
||||||
if (! $hub) {
|
if (! $hubs) {
|
||||||
|
|
||||||
/* Have never seen this guid or this guid coming from this location. Check it and register it. */
|
/* Have never seen this guid or this guid coming from this location. Check it and register it. */
|
||||||
|
|
||||||
// (!!) this will validate the sender
|
// (!!) this will validate the sender
|
||||||
$result = zot_register_hub($sender);
|
$result = zot_register_hub($sender);
|
||||||
|
|
||||||
if ((! $result['success']) || (! ($hub = zot_gethub($sender)))) {
|
if ((! $result['success']) || (! ($hubs = zot_gethub($sender,true)))) {
|
||||||
$ret['message'] = 'Hub not available.';
|
$ret['message'] = 'Hub not available.';
|
||||||
logger('mod_zot: no hub');
|
logger('mod_zot: no hub');
|
||||||
json_return_and_die($ret);
|
json_return_and_die($ret);
|
||||||
@ -680,42 +680,49 @@ function post_post(&$a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update our DB to show when we last communicated successfully with this hub
|
foreach($hubs as $hub) {
|
||||||
// This will allow us to prune dead hubs from using up resources
|
|
||||||
|
|
||||||
$r = q("update hubloc set hubloc_connected = '%s' where hubloc_id = %d",
|
// Update our DB to show when we last communicated successfully with this hub
|
||||||
dbesc(datetime_convert()),
|
// This will allow us to prune dead hubs from using up resources
|
||||||
intval($hub['hubloc_id'])
|
|
||||||
);
|
|
||||||
|
|
||||||
// a dead hub came back to life - reset any tombstones we might have
|
$r = q("update hubloc set hubloc_connected = '%s' where hubloc_id = %d",
|
||||||
|
dbesc(datetime_convert()),
|
||||||
if(intval($hub['hubloc_error'])) {
|
intval($hub['hubloc_id'])
|
||||||
q("update hubloc set hubloc_error = 0 where hubloc_id = %d",
|
|
||||||
intval($hub['hubloc_id'])
|
|
||||||
);
|
);
|
||||||
if(intval($r[0]['hubloc_orphancheck'])) {
|
|
||||||
q("update hubloc set hubloc_orhpancheck = 0 where hubloc_id = %d",
|
// a dead hub came back to life - reset any tombstones we might have
|
||||||
intval($hub['hubloc_id'])
|
|
||||||
|
if(intval($hub['hubloc_error'])) {
|
||||||
|
q("update hubloc set hubloc_error = 0 where hubloc_id = %d",
|
||||||
|
intval($hub['hubloc_id'])
|
||||||
|
);
|
||||||
|
if(intval($r[0]['hubloc_orphancheck'])) {
|
||||||
|
q("update hubloc set hubloc_orhpancheck = 0 where hubloc_id = %d",
|
||||||
|
intval($hub['hubloc_id'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
q("update xchan set xchan_orphan = 0 where xchan_orphan = 1 and xchan_hash = '%s'",
|
||||||
|
dbesc($hub['hubloc_hash'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
q("update xchan set xchan_orphan = 0 where xchan_orphan = 1 and xchan_hash = '%s'",
|
|
||||||
dbesc($hub['hubloc_hash'])
|
|
||||||
);
|
/*
|
||||||
|
* This hub has now been proven to be valid.
|
||||||
|
* Any hub with the same URL and a different sitekey cannot be valid.
|
||||||
|
* Get rid of them (mark them deleted). There's a good chance they were re-installs.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// q("update hubloc set hubloc_deleted = 1 where hubloc_url = '%s' and hubloc_sitekey != '%s' ",
|
||||||
|
// dbesc($hub['hubloc_url']),
|
||||||
|
// dbesc($hub['hubloc_sitekey'])
|
||||||
|
// );
|
||||||
|
|
||||||
|
$connecting_url = $hub['hubloc_url'];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This hub has now been proven to be valid.
|
|
||||||
* Any hub with the same URL and a different sitekey cannot be valid.
|
|
||||||
* Get rid of them (mark them deleted). There's a good chance they were re-installs.
|
|
||||||
*/
|
|
||||||
|
|
||||||
q("update hubloc set hubloc_deleted = 1 where hubloc_url = '%s' and hubloc_sitekey != '%s' ",
|
|
||||||
dbesc($hub['hubloc_url']),
|
|
||||||
dbesc($hub['hubloc_sitekey'])
|
|
||||||
);
|
|
||||||
|
|
||||||
/** @TODO check which hub is primary and take action if mismatched */
|
/** @TODO check which hub is primary and take action if mismatched */
|
||||||
|
|
||||||
if (array_key_exists('recipients', $data))
|
if (array_key_exists('recipients', $data))
|
||||||
@ -917,7 +924,7 @@ function post_post(&$a) {
|
|||||||
|
|
||||||
if ($msgtype === 'notify') {
|
if ($msgtype === 'notify') {
|
||||||
|
|
||||||
logger('notify received from ' . $hub['hubloc_url']);
|
logger('notify received from ' . $connecting_url);
|
||||||
|
|
||||||
|
|
||||||
$async = get_config('system','queued_fetch');
|
$async = get_config('system','queued_fetch');
|
||||||
|
Reference in New Issue
Block a user