diff options
author | zottel <github@zottel.net> | 2015-09-30 08:45:13 +0200 |
---|---|---|
committer | zottel <github@zottel.net> | 2015-09-30 08:45:13 +0200 |
commit | 0d60789f69ce3f26e5f4824cef0bc48c834014d5 (patch) | |
tree | 2ec8ac596b7332c49a88a5644be0eb309fe484a2 /include | |
parent | f950d27b3debfe08e022a477dbfb4fac101106e4 (diff) | |
parent | e769fbaffb09aa673d7475c598e7df7e7978d210 (diff) | |
download | volse-hubzilla-0d60789f69ce3f26e5f4824cef0bc48c834014d5.tar.gz volse-hubzilla-0d60789f69ce3f26e5f4824cef0bc48c834014d5.tar.bz2 volse-hubzilla-0d60789f69ce3f26e5f4824cef0bc48c834014d5.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'include')
-rw-r--r-- | include/deliver.php | 14 | ||||
-rw-r--r-- | include/notifier.php | 7 | ||||
-rw-r--r-- | include/queue.php | 25 | ||||
-rw-r--r-- | include/zot.php | 71 |
4 files changed, 109 insertions, 8 deletions
diff --git a/include/deliver.php b/include/deliver.php index 86fc90b3f..a338d1a89 100644 --- a/include/deliver.php +++ b/include/deliver.php @@ -29,6 +29,8 @@ function deliver_run($argv, $argc) { * If not, reduce the outq_priority. */ + $base = ''; + $h = parse_url($r[0]['outq_posturl']); if($h) { $base = $h['scheme'] . '://' . $h['host'] . (($h['port']) ? ':' . $h['port'] : ''); @@ -76,11 +78,13 @@ function deliver_run($argv, $argc) { $result = z_post_url($r[0]['outq_posturl'],$r[0]['outq_msg']); if($result['success'] && $result['return_code'] < 300) { logger('deliver: queue post success to ' . $r[0]['outq_posturl'], LOGGER_DEBUG); - q("update site set site_update = '%s', site_dead = 0 where site_url = '%s' ", - dbesc(datetime_convert()), - dbesc($site_url) - ); - q("update dreport set status = '%s', dreport_time = '%s' where dreport_queue = '%s' limit 1", + if($base) { + q("update site set site_update = '%s', site_dead = 0 where site_url = '%s' ", + dbesc(datetime_convert()), + dbesc($base) + ); + } + q("update dreport set dreport_result = '%s', dreport_time = '%s' where dreport_queue = '%s' limit 1", dbesc('accepted for delivery'), dbesc(datetime_convert()), dbesc($argv[$x]) diff --git a/include/notifier.php b/include/notifier.php index 3b29229cf..db1aa9690 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -605,11 +605,16 @@ function notifier_run($argv, $argc){ 'request' => $request, 'normal_mode' => $normal_mode, 'packet_type' => $packet_type, - 'walltowall' => $walltowall + 'walltowall' => $walltowall, + 'queued' => array() ); call_hooks('notifier_hub',$narr); + if($narr['queued']) { + foreach($narr['queued'] as $pq) + $deliveries[] = $pq; + } continue; } diff --git a/include/queue.php b/include/queue.php index 18c8c5fa2..71ac50c83 100644 --- a/include/queue.php +++ b/include/queue.php @@ -23,6 +23,9 @@ function queue_run($argv, $argc){ logger('queue: start'); + // delete all queue items more than 3 days old + // but first mark these sites dead if we haven't heard from them in a month + $r = q("select outq_posturl from outq where outq_created < %s - INTERVAL %s", db_utcnow(), db_quoteinterval('3 DAY') ); @@ -85,15 +88,34 @@ function queue_run($argv, $argc){ return; foreach($r as $rr) { + + $dresult = null; + if(in_array($rr['outq_posturl'],$deadguys)) continue; + $base = ''; + $h = parse_url($rr['outq_posturl']); + if($h) + $base = $h['scheme'] . '://' . $h['host'] . (($h['port']) ? ':' . $h['port'] : ''); + if($rr['outq_driver'] === 'post') { $result = z_post_url($rr['outq_posturl'],$rr['outq_msg']); if($result['success'] && $result['return_code'] < 300) { logger('queue: queue post success to ' . $rr['outq_posturl'], LOGGER_DEBUG); + if($base) { + q("update site set site_update = '%s', site_dead = 0 where site_url = '%s' ", + dbesc(datetime_convert()), + dbesc($base) + ); + } + q("update dreport set dreport_result = '%s', dreport_time = '%s' where dreport_queue = '%s' limit 1", + dbesc('accepted for delivery'), + dbesc(datetime_convert()), + dbesc($rr['outq_hash']) + ); $y = q("delete from outq where outq_hash = '%s'", - dbesc($rr['ouq_hash']) + dbesc($rr['outq_hash']) ); } else { @@ -102,6 +124,7 @@ function queue_run($argv, $argc){ dbesc(datetime_convert()), dbesc($rr['outq_hash']) ); + $deadguys[] = $rr['outq_posturl']; } continue; } diff --git a/include/zot.php b/include/zot.php index ef9f325d0..7707f34fc 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2392,6 +2392,9 @@ function sync_locations($sender, $arr, $absolute = false) { } } } + else { + logger('No locations to sync!'); + } $ret['change_message'] = $what; $ret['changed'] = $changed; @@ -2768,7 +2771,7 @@ function import_site($arr, $pubkey) { else { $update = true; $r = q("insert into site ( site_location, site_url, site_access, site_flags, site_update, site_directory, site_register, site_sellpage, site_realm, site_type ) - values ( '%s', '%s', %d, %d, '%s', '%s', %d, '%s', '%s' )", + values ( '%s', '%s', %d, %d, '%s', '%s', %d, '%s', '%s', %d )", dbesc($site_location), dbesc($url), intval($access_policy), @@ -3783,7 +3786,73 @@ function zotinfo($arr) { $ret['site']['realm'] = get_directory_realm(); } + + check_zotinfo($e,$x,$ret); + + call_hooks('zot_finger',$ret); return($ret); } + + +function check_zotinfo($channel,$locations,&$ret) { + + +// logger('locations: ' . print_r($locations,true),LOGGER_DATA); + + // This function will likely expand as we find more things to detect and fix. + // 1. Because magic-auth is reliant on it, ensure that the system channel has a valid hubloc + // Force this to be the case if anything is found to be wrong with it. + + // @FIXME ensure that the system channel exists in the first place and has an xchan + + if($channel['channel_system']) { + // the sys channel must have a location (hubloc) + $valid_location = false; + if((count($locations) === 1) && ($locations[0]['primary']) && (! $locations[0]['deleted'])) { + if((rsa_verify($locations[0]['url'],base64url_decode($locations[0]['url_sig']),$channel['channel_pubkey'])) + && ($locations[0]['sitekey'] === get_config('system','pubkey')) + && ($locations[0]['url'] === z_root())) + $valid_location = true; + else + logger('sys channel: invalid url signature'); + } + + if((! $locations) || (! $valid_location)) { + + logger('System channel locations are not valid. Attempting repair.'); + + // Don't trust any existing records. Just get rid of them, but only do this + // for the sys channel as normal channels will be trickier. + + q("delete from hubloc where hubloc_hash = '%s'", + dbesc($channel['channel_hash']) + ); + $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_primary, + hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey, hubloc_network ) + values ( '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s' )", + dbesc($channel['channel_guid']), + dbesc($channel['channel_guid_sig']), + dbesc($channel['channel_hash']), + dbesc($channel['channel_address'] . '@' . get_app()->get_hostname()), + intval(1), + dbesc(z_root()), + dbesc(base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey']))), + dbesc(get_app()->get_hostname()), + dbesc(z_root() . '/post'), + dbesc(get_config('system','pubkey')), + dbesc('zot') + ); + if($r) { + $x = zot_encode_locations($channel); + if($x) { + $ret['locations'] = $x; + } + } + else { + logger('Unable to store sys hub location'); + } + } + } +}
\ No newline at end of file |