aboutsummaryrefslogtreecommitdiffstats
path: root/include/zot.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-02-11 14:19:20 -0800
committerfriendica <info@friendica.com>2014-02-11 14:19:20 -0800
commitd02529fde1ee9d7ecf317ae30abce666e1b33eb4 (patch)
treef3801707655b40ea81fbe367753f1db5786432d6 /include/zot.php
parent841f3922aab013ac1ae1b7715de95f8246fe4f25 (diff)
downloadvolse-hubzilla-d02529fde1ee9d7ecf317ae30abce666e1b33eb4.tar.gz
volse-hubzilla-d02529fde1ee9d7ecf317ae30abce666e1b33eb4.tar.bz2
volse-hubzilla-d02529fde1ee9d7ecf317ae30abce666e1b33eb4.zip
implement a forced directory update mode where we unconditionally create a directory sync packet. This is needed to ensure that monthly directory pings are propagated to other directory servers so they can each prove for themselves whether or not an account is alive or dead. We do not trust other directories to provide us information beyond "look at this entry and decide for yourself" as doing otherwise would invite rogue directory manipulations. As this scheduled update occurs on all channels across all servers, we should also pick up refresh messages from all existing channel clones and these should also propagate out to all directory servers using the same mechanism (though perhaps not at the same time).
Diffstat (limited to 'include/zot.php')
-rw-r--r--include/zot.php15
1 files changed, 9 insertions, 6 deletions
diff --git a/include/zot.php b/include/zot.php
index 109744c53..21eef073c 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -79,12 +79,12 @@ function zot_get_hublocs($hash) {
* zot it to the other side
*
* @param array $channel => sender channel structure
- * @param string $type => packet type: one of 'ping', 'pickup', 'purge', 'refresh', 'notify', 'auth_check'
+ * @param string $type => packet type: one of 'ping', 'pickup', 'purge', 'refresh', 'force_refresh', 'notify', 'auth_check'
* @param array $recipients => envelope information, array ( 'guid' => string, 'guid_sig' => string ); empty for public posts
* @param string $remote_key => optional public site key of target hub used to encrypt entire packet
* NOTE: remote_key and encrypted packets are required for 'auth_check' packets, optional for all others
* @param string $secret => random string, required for packets which require verification/callback
- * e.g. 'pickup', 'purge', 'notify', 'auth_check' --- 'ping' and 'refresh' do not require verification
+ * e.g. 'pickup', 'purge', 'notify', 'auth_check'. Packet types 'ping', 'force_refresh', and 'refresh' do not require verification
*
* @returns string json encoded zot packet
*/
@@ -228,7 +228,7 @@ function zot_finger($webbie,$channel,$autofallback = true) {
}
/**
- * @function: zot_refresh($them, $channel = null)
+ * @function: zot_refresh($them, $channel = null, $force = false)
*
* zot_refresh is typically invoked when somebody has changed permissions of a channel and they are notified
* to fetch new permissions via a finger/discovery operation. This may result in a new connection
@@ -251,7 +251,7 @@ function zot_finger($webbie,$channel,$autofallback = true) {
* @returns boolean true if successful, else false
*/
-function zot_refresh($them,$channel = null) {
+function zot_refresh($them,$channel = null, $force = false) {
logger('zot_refresh: them: ' . print_r($them,true), LOGGER_DATA);
if($channel)
@@ -305,7 +305,7 @@ function zot_refresh($them,$channel = null) {
return false;
}
- $x = import_xchan($j);
+ $x = import_xchan($j,(($force) ? (-1) : 1));
if(! $x['success'])
return false;
@@ -524,6 +524,9 @@ function zot_register_hub($arr) {
* @param array $arr => json_decoded discovery packet
* @param int $ud_flags
* Determines whether to create a directory update record if any changes occur, default 1 or true
+ * $ud_flags = (-1) indicates a forced refresh where we unconditionally create a directory update record
+ * this typically occurs once a month for each channel as part of a scheduled ping to notify the directory
+ * that the channel still exists
*
* @returns array => 'success' (boolean true or false)
* 'message' (optional error string only if success is false)
@@ -885,7 +888,7 @@ function import_xchan($arr,$ud_flags = 1) {
}
}
- if($changed) {
+ if(($changed) || ($ud_flags == (-1))) {
$guid = random_string() . '@' . get_app()->get_hostname();
update_modtime($xchan_hash,$guid,$arr['address'],$ud_flags);
logger('import_xchan: changed: ' . $what,LOGGER_DEBUG);