Zot6: some things that need to be done ahead of time so we can turbocharge the delivery engine and split off site records from channel records.

This commit is contained in:
zotlabs 2017-09-13 19:20:16 -07:00
parent 0e6d84e207
commit 13788af908
4 changed files with 57 additions and 24 deletions

View File

@ -53,22 +53,29 @@ class Deliver {
remove_queue_item($r[0]['outq_hash']); remove_queue_item($r[0]['outq_hash']);
if($dresult && is_array($dresult)) { if($dresult && is_array($dresult)) {
foreach($dresult as $xx) { if(array_key_exists('iv',$dresult)) {
if(is_array($xx) && array_key_exists('message_id',$xx)) { $dresult = json_decode(crypto_unencapsulate($dresult,get_config('system','prvkey')),true);
if(delivery_report_is_storable($xx)) { }
q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ", if(! $dresult) {
dbesc($xx['message_id']), logger('dreport decryption failure');
dbesc($xx['location']), }
dbesc($xx['recipient']), else {
dbesc($xx['status']), foreach($dresult as $xx) {
dbesc(datetime_convert($xx['date'])), if(is_array($xx) && array_key_exists('message_id',$xx)) {
dbesc($xx['sender']) if(delivery_report_is_storable($xx)) {
); q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ",
dbesc($xx['message_id']),
dbesc($xx['location']),
dbesc($xx['recipient']),
dbesc($xx['status']),
dbesc(datetime_convert($xx['date'])),
dbesc($xx['sender'])
);
}
} }
} }
} }
} }
q("delete from dreport where dreport_queue = '%s'", q("delete from dreport where dreport_queue = '%s'",
dbesc($argv[$x]) dbesc($argv[$x])
); );

View File

@ -492,7 +492,7 @@ class Notifier {
// Now we have collected recipients (except for external mentions, FIXME) // Now we have collected recipients (except for external mentions, FIXME)
// Let's reduce this to a set of hubs; checking that the site is not dead. // Let's reduce this to a set of hubs; checking that the site is not dead.
$r = q("select hubloc.*, site.site_crypto from hubloc left join site on site_url = hubloc_url where hubloc_hash in (" . implode(',',$recipients) . ") $r = q("select hubloc.*, site.site_crypto, site.site_flags from hubloc left join site on site_url = hubloc_url where hubloc_hash in (" . implode(',',$recipients) . ")
and hubloc_error = 0 and hubloc_deleted = 0 and ( site_dead = 0 OR site_dead is null ) " and hubloc_error = 0 and hubloc_deleted = 0 and ( site_dead = 0 OR site_dead is null ) "
); );

View File

@ -72,6 +72,8 @@ define ( 'DIRECTORY_MODE_PRIMARY', 0x0001); // There can only be *one* prima
define ( 'DIRECTORY_MODE_SECONDARY', 0x0002); // All other mirror directory servers define ( 'DIRECTORY_MODE_SECONDARY', 0x0002); // All other mirror directory servers
define ( 'DIRECTORY_MODE_STANDALONE', 0x0100); // A detached (off the grid) hub with itself as directory server. define ( 'DIRECTORY_MODE_STANDALONE', 0x0100); // A detached (off the grid) hub with itself as directory server.
define ( 'ZOT6_COMPLIANT', 0x1000);
// We will look for upstream directories whenever me make contact // We will look for upstream directories whenever me make contact
// with other sites, but if this is a new installation and isn't // with other sites, but if this is a new installation and isn't
// a standalone hub, we need to seed the service with a starting // a standalone hub, we need to seed the service with a starting

View File

@ -2875,8 +2875,13 @@ function import_site($arr, $pubkey) {
$site_directory = DIRECTORY_MODE_NORMAL; $site_directory = DIRECTORY_MODE_NORMAL;
} }
$site_flags = $site_directory;
if(array_key_exists('zot',$arr) && ((float) $arr['zot']) >= 6.0)
$site_flags = ($site_flags & ZOT6_COMPLIANT);
if($exists) { if($exists) {
if(($siterecord['site_flags'] != $site_directory) if(($siterecord['site_flags'] != $site_flags)
|| ($siterecord['site_access'] != $access_policy) || ($siterecord['site_access'] != $access_policy)
|| ($siterecord['site_directory'] != $directory_url) || ($siterecord['site_directory'] != $directory_url)
|| ($siterecord['site_sellpage'] != $sellpage) || ($siterecord['site_sellpage'] != $sellpage)
@ -2896,7 +2901,7 @@ function import_site($arr, $pubkey) {
$r = q("update site set site_dead = 0, site_location = '%s', site_flags = %d, site_access = %d, site_directory = '%s', site_register = %d, site_update = '%s', site_sellpage = '%s', site_realm = '%s', site_type = %d, site_project = '%s', site_version = '%s', site_crypto = '%s' $r = q("update site set site_dead = 0, site_location = '%s', site_flags = %d, site_access = %d, site_directory = '%s', site_register = %d, site_update = '%s', site_sellpage = '%s', site_realm = '%s', site_type = %d, site_project = '%s', site_version = '%s', site_crypto = '%s'
where site_url = '%s'", where site_url = '%s'",
dbesc($site_location), dbesc($site_location),
intval($site_directory), intval($site_flags),
intval($access_policy), intval($access_policy),
dbesc($directory_url), dbesc($directory_url),
intval($register_policy), intval($register_policy),
@ -2929,7 +2934,7 @@ function import_site($arr, $pubkey) {
'site_location' => $site_location, 'site_location' => $site_location,
'site_url' => $url, 'site_url' => $url,
'site_access' => intval($access_policy), 'site_access' => intval($access_policy),
'site_flags' => intval($site_directory), 'site_flags' => intval($site_flags),
'site_update' => datetime_convert(), 'site_update' => datetime_convert(),
'site_directory' => $directory_url, 'site_directory' => $directory_url,
'site_register' => intval($register_policy), 'site_register' => intval($register_policy),
@ -4161,9 +4166,27 @@ function zotinfo($arr) {
if($x) if($x)
$ret['locations'] = $x; $ret['locations'] = $x;
$ret['site'] = array(); $ret['site'] = zot_site_info($e);
check_zotinfo($e,$x,$ret);
call_hooks('zot_finger',$ret);
return($ret);
}
function zot_site_info($channel = null) {
$signing_key = (($channel) ? $channel['channel_prvkey'] : get_config('system','prvkey'));
$sig_method = get_config('system','signature_algorithm','sha256');
$ret = [];
$ret['site'] = [];
$ret['site']['url'] = z_root(); $ret['site']['url'] = z_root();
$ret['site']['url_sig'] = base64url_encode(rsa_sign(z_root(),$e['channel_prvkey'],$sig_method)); $ret['site']['url_sig'] = base64url_encode(rsa_sign(z_root(),$signing_key,$sig_method));
$ret['site']['zot_auth'] = z_root() . '/magic'; $ret['site']['zot_auth'] = z_root() . '/magic';
$dirmode = get_config('system','directory_mode'); $dirmode = get_config('system','directory_mode');
@ -4182,6 +4205,12 @@ function zotinfo($arr) {
$ret['site']['encryption'] = crypto_methods(); $ret['site']['encryption'] = crypto_methods();
$ret['site']['signing'] = signing_methods(); $ret['site']['signing'] = signing_methods();
if(function_exists('zotvi_load')) {
$ret['site']['zot'] = '6.0';
}
else {
$ret['site']['zot'] = ZOT_REVISION;
}
// hide detailed site information if you're off the grid // hide detailed site information if you're off the grid
@ -4234,15 +4263,10 @@ function zotinfo($arr) {
} }
check_zotinfo($e,$x,$ret); return $ret['site'];
call_hooks('zot_finger',$ret);
return($ret);
} }
function check_zotinfo($channel,$locations,&$ret) { function check_zotinfo($channel,$locations,&$ret) {