The Hubzilla
|
Hubzilla implementation of zot protocol. More...
Functions | |
zot_new_uid ($channel_nick) | |
Generates a unique string for use as a zot guid. More... | |
make_xchan_hash ($guid, $guid_sig) | |
Generates a portable hash identifier for a channel. More... | |
zot_get_hublocs ($hash) | |
Given a zot hash, return all distinct hubs. More... | |
zot_build_packet ($channel, $type= 'notify', $recipients=null, $remote_key=null, $methods= '', $secret=null, $extra=null) | |
Builds a zot notification packet. More... | |
zot_best_algorithm ($methods) | |
Choose best encryption function from those available on both sites. More... | |
zot_zot ($url, $data) | |
zot_refresh ($them, $channel=null, $force=false) | |
Refreshes after permission changed or friending, etc. More... | |
zot_gethub ($arr, $multiple=false) | |
Look up if channel is known and previously verified. More... | |
zot_register_hub ($arr) | |
Registers an unknown hub. More... | |
import_xchan ($arr, $ud_flags=UPDATE_FLAGS_UPDATED, $ud_arr=null) | |
Takes an associative array of a fetched discovery packet and updates all internal data structures which need to be updated as a result. More... | |
zot_process_response ($hub, $arr, $outq) | |
Called immediately after sending a zot message which is using queue processing. More... | |
zot_fetch ($arr) | |
We received a notification packet (in mod_post) that a message is waiting for us, and we've verified the sender. Now send back a pickup message, using our message tracking ID ($arr['secret']), which we will sign with our site private key. The entire pickup message is encrypted with the remote site's public key. If everything checks out on the remote end, we will receive back a packet containing one or more messages, which will be processed and delivered before this function ultimately returns. More... | |
zot_import ($arr, $sender_url) | |
Process incoming array of messages. More... | |
public_recips ($msg) | |
A public message with no listed recipients can be delivered to anybody who has PERMS_NETWORK for that type of post, PERMS_AUTHED (in-network senders are by definition authenticated) or PERMS_SITE and is one the same site, or PERMS_SPECIFIC and the sender is a contact who is granted permissions via their connection permissions in the address book. Here we take a given message and construct a list of hashes of everybody on the site that we should try and deliver to. Some of these will be rejected, but this gives us a place to start. More... | |
allowed_public_recips ($msg) | |
This is the second part of public_recips(). More... | |
process_delivery ($sender, $arr, $deliveries, $relay, $public=false, $request=false) | |
remove_community_tag ($sender, $arr, $uid) | |
Remove community tag. More... | |
update_imported_item ($sender, $item, $orig, $uid, $tag_delivery) | |
Updates an imported item. More... | |
delete_imported_item ($sender, $item, $uid, $relay) | |
Deletes an imported item. More... | |
process_mail_delivery ($sender, $arr, $deliveries) | |
process_rating_delivery ($sender, $arr) | |
Processes delivery of rating. More... | |
process_profile_delivery ($sender, $arr, $deliveries) | |
Processes delivery of profile. More... | |
process_location_delivery ($sender, $arr, $deliveries) | |
check_location_move ($sender_hash, $locations) | |
Checks for a moved UNO channel and sets the channel_moved flag. More... | |
sync_locations ($sender, $arr, $absolute=false) | |
Synchronises locations. More... | |
zot_encode_locations ($channel) | |
Returns an array with all known distinct hubs for this channel. More... | |
import_directory_profile ($hash, $profile, $addr, $ud_flags=UPDATE_FLAGS_UPDATED, $suppress_update=0) | |
Imports a directory profile. More... | |
import_directory_keywords ($hash, $keywords) | |
update_modtime ($hash, $guid, $addr, $flags=0) | |
import_site ($arr, $pubkey) | |
build_sync_packet ($uid=0, $packet=null, $groups_changed=false) | |
Builds and sends a sync packet. More... | |
process_channel_sync_delivery ($sender, $arr, $deliveries) | |
get_rpost_path ($observer) | |
Returns path to /rpost. More... | |
import_author_zot ($x) | |
zot_reply_message_request ($data) | |
Process a message request. More... | |
zot_rekey_request ($sender, $data) | |
zotinfo ($arr) | |
zot_site_info ($channel_key= '') | |
check_zotinfo ($channel, $locations, &$ret) | |
delivery_report_is_storable ($dr) | |
update_hub_connected ($hub, $sitekey= '') | |
zot_reply_ping () | |
Useful to get a health check on a remote site. More... | |
zot_reply_pickup ($data) | |
zot_reply_auth_check ($data, $encrypted_packet) | |
zot_reply_purge ($sender, $recipients) | |
zot_reply_refresh ($sender, $recipients) | |
Remote channel info (such as permissions or photo or something) has been updated. Grab a fresh copy and sync it. More... | |
zot_reply_notify ($data) | |
Hubzilla implementation of zot protocol.
https://github.com/friendica/red/wiki/zot https://github.com/friendica/red/wiki/Zot—A-High-Level-Overview
allowed_public_recips | ( | $msg | ) |
This is the second part of public_recips().
We'll find all the channels willing to accept public posts from us, then match them against the sender privacy scope and see who in that list that the sender is allowing.
array | $msg |
Referenced by zot_import().
build_sync_packet | ( | $uid = 0 , |
|
$packet = null , |
|||
$groups_changed = false |
|||
) |
Builds and sends a sync packet.
Send a zot packet to all hubs where this channel is duplicated, refreshing such things as personal settings, channel permissions, address book updates, etc.
int | $uid | (optional) default 0 |
array | $packet | (optional) default null |
boolean | $groups_changed | (optional) default false |
Referenced by Zotlabs\Lib\Apps\app_destroy(), Zotlabs\Lib\Apps\app_install(), attach_change_permissions(), attach_store(), change_channel_keys(), Zotlabs\Module\Connedit\connedit_clone(), Zotlabs\Module\Defperms\defperms_clone(), Zotlabs\Lib\Chatroom\destroy(), event_addtocal(), Zotlabs\Module\Moderate\get(), Zotlabs\Module\Like\get(), Zotlabs\Module\Tagger\get(), Zotlabs\Module\Settings\Permcats\get(), Zotlabs\Module\Filestorage\get(), Zotlabs\Module\Mail\get(), Zotlabs\Module\Thing\get(), Zotlabs\Module\Events\get(), Zotlabs\Module\Profile_photo\get(), Zotlabs\Module\Connedit\get(), Zotlabs\Module\Item\get(), group_add(), group_add_member(), group_rmv(), group_rmv_member(), Zotlabs\Module\Notes\init(), Zotlabs\Module\Starred\init(), Zotlabs\Module\Follow\init(), Zotlabs\Module\Thing\init(), item_create_edit_activity(), menu_sync_packet(), Zotlabs\Module\Pdledit\post(), Zotlabs\Module\Settings\Features\post(), Zotlabs\Module\Settings\Featured\post(), Zotlabs\Module\Settings\Permcats\post(), Zotlabs\Module\Group\post(), Zotlabs\Module\Pconfig\post(), Zotlabs\Module\Settings\Channel\post(), Zotlabs\Module\File_upload\post(), Zotlabs\Module\Settings\Display\post(), Zotlabs\Module\Events\post(), Zotlabs\Module\Mail\post(), Zotlabs\Module\Wall_attach\post(), Zotlabs\Module\Item\post(), Zotlabs\Module\Chat\post(), Zotlabs\Module\Profile_photo\post(), Zotlabs\Module\Photos\post(), Zotlabs\Module\Profiles\post(), private_messages_drop(), profiles_build_sync(), Zotlabs\Daemon\Importfile\run(), Zotlabs\Daemon\Cron\run(), Zotlabs\Lib\NativeWiki\sync_a_wiki_item(), sync_an_item(), and zot_refresh().
check_location_move | ( | $sender_hash, | |
$locations | |||
) |
Checks for a moved UNO channel and sets the channel_moved flag.
Currently the effect of this flag is to turn the channel into 'read-only' mode. New content will not be processed (there was still an issue with blocking the ability to post comments as of 10-Mar-2016). We do not physically remove the channel at this time. The hub admin may choose to do so, but is encouraged to allow a grace period of several days in case there are any issues migrating content. This packet will generally be received by the original site when the basic channel import has been processed.
This will only be executed on the UNO system which is the old location if a new location is reported and there is only one location record. The rest of the hubloc syncronisation will be handled within sync_locations
string | $sender_hash | A channel hash |
array | $locations |
Referenced by sync_locations().
check_zotinfo | ( | $channel, | |
$locations, | |||
& | $ret | ||
) |
array | $channel | ||
array | $locations | ||
[out] | array | $ret | array locations result of zot_encode_locations() |
Referenced by zotinfo().
delete_imported_item | ( | $sender, | |
$item, | |||
$uid, | |||
$relay | |||
) |
Deletes an imported item.
array | $sender |
|
array | $item | |
int | $uid | |
boolean | $relay |
Referenced by process_delivery().
delivery_report_is_storable | ( | $dr | ) |
array | $dr |
Referenced by Zotlabs\Daemon\Deliver\run(), and zot_process_response().
get_rpost_path | ( | $observer | ) |
Returns path to /rpost.
array | $observer |
|
Referenced by Zotlabs\Module\Rpost\get().
import_author_zot | ( | $x | ) |
array | $x |
Referenced by import_author_xchan().
import_directory_keywords | ( | $hash, | |
$keywords | |||
) |
string | $hash | An xtag_hash |
array | $keywords |
Referenced by import_directory_profile().
import_directory_profile | ( | $hash, | |
$profile, | |||
$addr, | |||
$ud_flags = UPDATE_FLAGS_UPDATED , |
|||
$suppress_update = 0 |
|||
) |
Imports a directory profile.
string | $hash | |
array | $profile | |
string | $addr | |
number | $ud_flags | (optional) UPDATE_FLAGS_UPDATED |
number | $suppress_update | (optional) default 0 |
Referenced by import_xchan(), local_dir_update(), and process_profile_delivery().
import_site | ( | $arr, | |
$pubkey | |||
) |
array | $arr | |
string | $pubkey |
Referenced by import_xchan().
import_xchan | ( | $arr, | |
$ud_flags = UPDATE_FLAGS_UPDATED , |
|||
$ud_arr = null |
|||
) |
Takes an associative array of a fetched discovery packet and updates all internal data structures which need to be updated as a result.
array | $arr | => json_decoded discovery packet |
int | $ud_flags | Determines whether to create a directory update record if any changes occur, default is UPDATE_FLAGS_UPDATED $ud_flags = UPDATE_FLAGS_FORCED 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 |
array | $ud_arr | If set [typically by update_directory_entry()] indicates a specific update table row and more particularly contains a particular address (ud_addr) which needs to be updated in that table. |
Referenced by discover_by_webbie(), Zotlabs\Module\Chanview\get(), Zotlabs\Module\Probe\get(), Zotlabs\Zot\Auth\GetHublocs(), Zotlabs\Module\Magic\init(), Zotlabs\Module\Regdir\init(), new_contact(), owt_init(), poco_load(), Zotlabs\Module\Mail\post(), Zotlabs\Daemon\Gprobe\run(), update_directory_entry(), zot_refresh(), and zot_register_hub().
make_xchan_hash | ( | $guid, | |
$guid_sig | |||
) |
Generates a portable hash identifier for a channel.
Generates a portable hash identifier for the channel identified by $guid and signed with $guid_sig.
string | $guid | |
string | $guid_sig |
Referenced by allowed_public_recips(), change_channel_keys(), create_identity(), get_item_elements(), Zotlabs\Module\Import\import_account(), import_author_zot(), import_channel(), import_hublocs(), import_xchan(), Zotlabs\Module\Zfinger\init(), process_channel_sync_delivery(), zot_import(), zot_register_hub(), zot_rekey_request(), zot_reply_auth_check(), zot_reply_message_request(), zot_reply_purge(), and zotinfo().
process_channel_sync_delivery | ( | $sender, | |
$arr, | |||
$deliveries | |||
) |
array | $sender | |
array | $arr | |
array | $deliveries |
Referenced by zot_import().
process_delivery | ( | $sender, | |
$arr, | |||
$deliveries, | |||
$relay, | |||
$public = false , |
|||
$request = false |
|||
) |
array | $sender | |
array | $arr | |
array | $deliveries | |
boolean | $relay | |
boolean | $public | (optional) default false |
boolean | $request | (optional) default false |
Referenced by Zotlabs\Daemon\Externals\run(), Zotlabs\Daemon\Onepoll\run(), and zot_import().
process_location_delivery | ( | $sender, | |
$arr, | |||
$deliveries | |||
) |
array | $sender | an associative array
|
array | $arr | |
array | $deliveries | (unused) deliveries is irrelevant |
Referenced by zot_import().
process_mail_delivery | ( | $sender, | |
$arr, | |||
$deliveries | |||
) |
Referenced by zot_import().
process_profile_delivery | ( | $sender, | |
$arr, | |||
$deliveries | |||
) |
Processes delivery of profile.
array | $sender | an associative array
|
array | $arr | |
array | $deliveries | (unused) |
Referenced by zot_import().
process_rating_delivery | ( | $sender, | |
$arr | |||
) |
Processes delivery of rating.
array | $sender |
|
array | $arr |
Referenced by zot_import().
public_recips | ( | $msg | ) |
A public message with no listed recipients can be delivered to anybody who has PERMS_NETWORK for that type of post, PERMS_AUTHED (in-network senders are by definition authenticated) or PERMS_SITE and is one the same site, or PERMS_SPECIFIC and the sender is a contact who is granted permissions via their connection permissions in the address book. Here we take a given message and construct a list of hashes of everybody on the site that we should try and deliver to. Some of these will be rejected, but this gives us a place to start.
array | $msg |
Referenced by allowed_public_recips().
remove_community_tag | ( | $sender, | |
$arr, | |||
$uid | |||
) |
Remove community tag.
array | $sender | an associative array with
|
array | $arr | an associative array
|
int | $uid |
Referenced by process_delivery().
sync_locations | ( | $sender, | |
$arr, | |||
$absolute = false |
|||
) |
Synchronises locations.
array | $sender | |
array | $arr | |
boolean | $absolute | (optional) default false |
Referenced by import_xchan(), and process_location_delivery().
update_hub_connected | ( | $hub, | |
$sitekey = '' |
|||
) |
array | $hub | |
string | $sitekey | (optional, default empty) |
Referenced by Zotlabs\Zot\Receiver\ValidateSender().
update_imported_item | ( | $sender, | |
$item, | |||
$orig, | |||
$uid, | |||
$tag_delivery | |||
) |
Updates an imported item.
array | $sender | |
array | $item | |
array | $orig | |
int | $uid | |
boolean | $tag_delivery |
Referenced by process_delivery().
update_modtime | ( | $hash, | |
$guid, | |||
$addr, | |||
$flags = 0 |
|||
) |
string | $hash | |
string | $guid | |
string | $addr | |
int | $flags | (optional) default 0 |
Referenced by import_directory_profile(), import_xchan(), local_dir_update(), and process_location_delivery().
zot_best_algorithm | ( | $methods | ) |
Choose best encryption function from those available on both sites.
string | $methods | comma separated list of encryption methods |
Referenced by zot_build_packet(), zot_fetch(), and zot_reply_pickup().
zot_build_packet | ( | $channel, | |
$type = 'notify' , |
|||
$recipients = null , |
|||
$remote_key = null , |
|||
$methods = '' , |
|||
$secret = null , |
|||
$extra = null |
|||
) |
Builds a zot notification packet.
Builds a zot notification packet that you can either store in the queue with a message array or call zot_zot to immediately zot it to the other side.
array | $channel | sender channel structure |
string | $type | packet type: one of 'ping', 'pickup', 'purge', 'refresh', 'keychange', 'force_refresh', 'notify', 'auth_check' |
array | $recipients | envelope information, array ( 'guid' => string, 'guid_sig' => string ); empty for public posts |
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 |
string | $methods | optional comma separated list of encryption methods zot_best_algorithm() |
string | $secret | random string, required for packets which require verification/callback e.g. 'pickup', 'purge', 'notify', 'auth_check'. Packet types 'ping', 'force_refresh', and 'refresh' do not require verification |
string | $extra |
Referenced by build_sync_packet(), Zotlabs\Module\Zping\get(), ping_site(), Zotlabs\Daemon\Ratenotif\run(), Zotlabs\Daemon\Directory\run(), Zotlabs\Daemon\Notifier\run(), Zotlabs\Zot\Auth\Verify(), and zot_reply_message_request().
zot_encode_locations | ( | $channel | ) |
Returns an array with all known distinct hubs for this channel.
array | $channel | an associative array which must contain
|
Referenced by check_zotinfo(), Zotlabs\Daemon\Notifier\run(), and zotinfo().
zot_fetch | ( | $arr | ) |
We received a notification packet (in mod_post) that a message is waiting for us, and we've verified the sender. Now send back a pickup message, using our message tracking ID ($arr['secret']), which we will sign with our site private key. The entire pickup message is encrypted with the remote site's public key. If everything checks out on the remote end, we will receive back a packet containing one or more messages, which will be processed and delivered before this function ultimately returns.
array | $arr | decrypted and json decoded notify packet from remote site |
Referenced by zot_reply_notify().
zot_get_hublocs | ( | $hash | ) |
Given a zot hash, return all distinct hubs.
This function is used in building the zot discovery packet and therefore should only be used by channels which are defined on this hub.
string | $hash | - xchan_hash |
Referenced by Zotlabs\Module\Fhublocs\get(), process_channel_sync_delivery(), and zot_encode_locations().
zot_gethub | ( | $arr, | |
$multiple = false |
|||
) |
Look up if channel is known and previously verified.
A guid and a url, both signed by the sender, distinguish a known sender at a known location. This function looks these up to see if the channel is known and therefore previously verified. If not, we will need to verify it.
array | $arr | an associative array which must contain:
|
boolean | $multiple | (optional) default false |
Referenced by import_hublocs(), Zotlabs\Zot\Receiver\ValidateSender(), zot_fetch(), and zot_import().
zot_import | ( | $arr, | |
$sender_url | |||
) |
Process incoming array of messages.
Process an incoming array of messages which were obtained via pickup, and import, update, delete as directed.
The message types handled here are 'activity' (e.g. posts), 'mail', 'profile', 'location' and 'channel_sync'.
array | $arr | 'pickup' structure returned from remote site |
string | $sender_url | the url specified by the sender in the initial communication. We will verify the sender and url in each returned message structure and also verify that all the messages returned match the site url that we are currently processing. |
Referenced by Zotlabs\Daemon\Deliver\run(), and zot_fetch().
zot_new_uid | ( | $channel_nick | ) |
Generates a unique string for use as a zot guid.
Generates a unique string for use as a zot guid using our DNS-based url, the channel nickname and some entropy. The entropy ensures uniqueness against re-installs where the same URL and nickname are chosen.
string | $channel_nick | a unique nickname of controlling entity |
Referenced by create_identity().
zot_process_response | ( | $hub, | |
$arr, | |||
$outq | |||
) |
Called immediately after sending a zot message which is using queue processing.
Updates the queue item according to the response result and logs any information returned to aid communications troubleshooting.
string | $hub | - url of site we just contacted |
array | $arr | - output of z_post_url() |
array | $outq | - The queue structure attached to this request |
Referenced by queue_deliver().
zot_refresh | ( | $them, | |
$channel = null , |
|||
$force = false |
|||
) |
Refreshes after permission changed or friending, etc.
The top half of this function is similar to \Zotlabs\Zot\Finger::run() and could potentially be consolidated.
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 (abook entry) being added to a local channel and it may result in auto-permissions being granted.
Friending in zot is accomplished by sending a refresh packet to a specific channel which indicates a permission change has been made by the sender which affects the target channel. The hub controlling the target channel does targetted discovery (a zot-finger request requesting permissions for the local channel). These are decoded here, and if necessary and abook structure (addressbook) is created to store the permissions assigned to this channel.
Initially these abook structures are created with a 'pending' flag, so that no reverse permissions are implied until this is approved by the owner channel. A channel can also auto-populate permissions in return and send back a refresh packet of its own. This is used by forum and group communication channels so that friending and membership in the channel's "club" is automatic.
array | $them | => xchan structure of sender |
array | $channel | => local channel structure of target recipient, required for "friending" operations |
array | $force | (optional) default false |
Referenced by Zotlabs\Module\Connedit\get(), import_author_zot(), Zotlabs\Daemon\Onepoll\run(), and zot_reply_refresh().
zot_register_hub | ( | $arr | ) |
Registers an unknown hub.
A communication has been received which has an unknown (to us) sender. Perform discovery based on our calculated hash of the sender at the origination address. This will fetch the discovery packet of the sender, which contains the public key we need to verify our guid and url signatures.
array | $arr | an associative array which must contain:
|
Referenced by Zotlabs\Zot\Receiver\ValidateSender().
zot_rekey_request | ( | $sender, | |
$data | |||
) |
Referenced by Zotlabs\Zot\ZotHandler\Rekey().
zot_reply_auth_check | ( | $data, | |
$encrypted_packet | |||
) |
Referenced by Zotlabs\Zot\ZotHandler\AuthCheck().
zot_reply_message_request | ( | $data | ) |
Process a message request.
If a site receives a comment to a post but finds they have no parent to attach it with, they may send a 'request' packet containing the message_id of the missing parent. This is the handler for that packet. We will create a message_list array of the entire conversation starting with the missing parent and invoke delivery to the sender of the packet.
include/deliver.php (for local delivery) and mod/post.php (for web delivery) detect the existence of this 'message_list' at the destination and split it into individual messages which are processed/delivered in order.
Called from mod/post.php
array | $data |
Referenced by Zotlabs\Zot\ZotHandler\Request().
zot_reply_notify | ( | $data | ) |
Referenced by Zotlabs\Zot\ZotHandler\Notify().
zot_reply_pickup | ( | $data | ) |
Referenced by Zotlabs\Zot\ZotHandler\Pickup().
zot_reply_ping | ( | ) |
Useful to get a health check on a remote site.
This will let us know if any important communication details that we may have stored are no longer valid, regardless of xchan details.
Referenced by Zotlabs\Zot\ZotHandler\Ping().
zot_reply_purge | ( | $sender, | |
$recipients | |||
) |
array | $sender | |
array | $recipients | return json_return_and_die() |
Referenced by Zotlabs\Zot\ZotHandler\Purge().
zot_reply_refresh | ( | $sender, | |
$recipients | |||
) |
Remote channel info (such as permissions or photo or something) has been updated. Grab a fresh copy and sync it.
The difference between refresh and force_refresh is that force_refresh unconditionally creates a directory update record, even if no changes were detected upon processing.
array | $sender | |
array | $recipients |
Referenced by Zotlabs\Zot\ZotHandler\Refresh().
zot_site_info | ( | $channel_key = '' | ) |
Referenced by zotinfo().
zot_zot | ( | $url, | |
$data | |||
) |
string | $url | |
array | $data |
Referenced by Zotlabs\Module\Zping\get(), ping_site(), queue_deliver(), Zotlabs\Daemon\Directory\run(), Zotlabs\Zot\Auth\Verify(), and zot_fetch().
zotinfo | ( | $arr | ) |
The special address '[system]' will return a system channel if one has been defined, Or the first valid channel we find if there are no system channels.
This is used by magic-auth if we have no prior communications with this site - and returns an identity on this site which we can use to create a valid hub record so that we can exchange signed messages. The precise identity is irrelevant. It's the hub information that we really need at the other end - and this will return it.
Referenced by Zotlabs\Module\Zfinger\init(), and Zotlabs\Module\Wfinger\init().