don't unset a directory server which has no active channels and hence will never have a site table update. Do this by probing the sys channel of that directory weekly and checking the directory status returned by it.
This commit is contained in:
parent
5d30565c66
commit
673556a847
@ -31,22 +31,37 @@ function find_upstream_directory($dirmode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function check_upstream_directory() {
|
function check_upstream_directory() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directories may come and go over time. We will need to check that our
|
* Directories may come and go over time. We will need to check that our
|
||||||
* directory server is still valid occasionally, and reset to something that
|
* directory server is still valid occasionally, and reset to something that
|
||||||
* is if our directory has gone offline for any reason
|
* is if our directory has gone offline for any reason
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$directory = get_config('system','directory_server');
|
$directory = get_config('system','directory_server');
|
||||||
if ($directory) {
|
|
||||||
$r = q("select * from site where site_url = '%s' and (site_flags & %d) > 0 ",
|
// it's possible there is no directory server configured and the local hub is being used.
|
||||||
dbesc($directory),
|
// If so, default to preserving the absence of a specific server setting.
|
||||||
intval(DIRECTORY_MODE_PRIMARY|DIRECTORY_MODE_SECONDARY|DIRECTORY_MODE_STANDALONE)
|
|
||||||
);
|
$isadir = true;
|
||||||
}
|
|
||||||
// If we've got something, it's still a directory. If we haven't, we need to reset and let find_upstream_directory() fix it
|
if($directory) {
|
||||||
if (! $r) {
|
$h = parse_url($directory);
|
||||||
set_config('system','directory_server','');
|
if($h) {
|
||||||
|
$x = zot_finger('sys@' . $h['host']);
|
||||||
|
if($x['success']) {
|
||||||
|
$j = json_decode($x['body'],true);
|
||||||
|
if(array_key_exists('site',$j) && array_key_exists('directory_mode',$j['site'])) {
|
||||||
|
if($j['site']['directory_mode'] === 'normal') {
|
||||||
|
$isadir = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(! $isadir)
|
||||||
|
set_config('system','directory_server','');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user