The Red Matrix
 All Classes Namespaces Files Functions Variables Pages
zot.php File Reference

Functions

 zot_new_uid ($channel_nick)
 
 zot_get_hublocs ($hash)
 
 zot_build_packet ($channel, $type= 'notify', $recipients=null, $remote_key=null, $secret=null)
 
 zot_zot ($url, $data)
 
 zot_finger ($webbie, $channel, $autofallback=true)
 
 zot_refresh ($them, $channel=null)
 
 zot_gethub ($arr)
 
 zot_register_hub ($arr)
 
 import_xchan ($arr, $ud_flags=1)
 
 zot_process_response ($hub, $arr, $outq)
 
 zot_fetch ($arr)
 
 zot_import ($arr, $sender_url)
 
 public_recips ($msg)
 
 allowed_public_recips ($msg)
 
 process_delivery ($sender, $arr, $deliveries, $relay)
 
 remove_community_tag ($sender, $arr, $uid)
 
 update_imported_item ($sender, $item, $uid)
 
 delete_imported_item ($sender, $item, $uid)
 
 process_mail_delivery ($sender, $arr, $deliveries)
 
 process_profile_delivery ($sender, $arr, $deliveries)
 
 import_directory_profile ($hash, $profile, $addr, $ud_flags=1, $suppress_update=0)
 
 import_directory_keywords ($hash, $keywords)
 
 update_modtime ($hash, $guid, $addr, $flags=0)
 
 import_site ($arr, $pubkey)
 
 build_sync_packet ($uid=0, $packet=null)
 
 process_channel_sync_delivery ($sender, $arr, $deliveries)
 
 get_rpost_path ($observer)
 
 import_author_zot ($x)
 

Function Documentation

allowed_public_recips (   $msg)

Referenced by zot_import().

build_sync_packet (   $uid = 0,
  $packet = null 
)

Send a zot packet to all hubs where this channel is duplicated, refreshing such things as personal settings, channel permissions, address book updates, etc.

Referenced by connections_clone(), connedit_clone(), and settings_post().

delete_imported_item (   $sender,
  $item,
  $uid 
)

Referenced by process_delivery().

get_rpost_path (   $observer)

Referenced by rpost_callback(), and rpost_content().

import_author_zot (   $x)

Referenced by import_author_xchan().

import_directory_keywords (   $hash,
  $keywords 
)
import_directory_profile (   $hash,
  $profile,
  $addr,
  $ud_flags = 1,
  $suppress_update = 0 
)
import_site (   $arr,
  $pubkey 
)

Referenced by import_xchan().

import_xchan (   $arr,
  $ud_flags = 1 
)

import_xchan($arr,$ud_flags = 1) Takes an associative array of a fecthed discovery packet and updates all internal data structures which need to be updated as a result.

Parameters
array$arr=> json_decoded discovery packet
int$ud_flagsDetermines whether to create a directory update record if any changes occur, default 1 or true
Returns
array => 'success' (boolean true or false) 'message' (optional error string only if success is false)

Referenced by chanview_content(), gprobe_run(), magic_init(), mail_post(), new_contact(), poco_load(), post_init(), update_directory_entry(), zot_refresh(), and zot_register_hub().

process_channel_sync_delivery (   $sender,
  $arr,
  $deliveries 
)

Referenced by zot_import().

process_delivery (   $sender,
  $arr,
  $deliveries,
  $relay 
)

Referenced by onepoll_run(), and zot_import().

process_mail_delivery (   $sender,
  $arr,
  $deliveries 
)

Referenced by zot_import().

process_profile_delivery (   $sender,
  $arr,
  $deliveries 
)

Referenced by zot_import().

public_recips (   $msg)

Referenced by allowed_public_recips().

remove_community_tag (   $sender,
  $arr,
  $uid 
)

Referenced by process_delivery().

update_imported_item (   $sender,
  $item,
  $uid 
)

Referenced by process_delivery().

update_modtime (   $hash,
  $guid,
  $addr,
  $flags = 0 
)
zot_build_packet (   $channel,
  $type = 'notify',
  $recipients = null,
  $remote_key = null,
  $secret = null 
)

zot_build_packet($channel,$type = 'notify',$recipients = null, $remote_key = null, $secret = null) 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

Parameters
array$channel=> sender channel structure
string$type=> packet type: one of 'ping', 'pickup', 'purge', '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$secret=> random string, required for packets which require verification/callback e.g. 'pickup', 'purge', 'notify', 'auth_check' — 'ping' and 'refresh' do not require verification
Returns
string json encoded zot packet

Referenced by admin_page_hubloc_post(), build_sync_packet(), directory_run(), notifier_run(), post_init(), and zping_content().

zot_fetch (   $arr)

zot_fetch($arr)

We received a notification packet (in mod/post.php) 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.
Parameters
array$arrdecrypted and json decoded notify packet from remote site

Referenced by post_post().

zot_finger (   $webbie,
  $channel,
  $autofallback = true 
)

: zot_finger

Look up information about channel

Parameters
string $webbie does not have to be host qualified e.g. 'foo' is treated as 'foo'
array $channel (optional), if supplied permissions will be enumerated specifically for $channel
boolean $autofallback fallback/failover to http if https connection cannot be established. Default is true.
Returns
: array => see z_post_url and mod/zfinger.php

Referenced by chanview_content(), gprobe_run(), magic_init(), mail_post(), new_contact(), poco_load(), post_init(), probe_content(), and update_directory_entry().

zot_get_hublocs (   $hash)

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

Parameters
string$hash- xchan_hash array of hubloc (hub location structures) hubloc_id int hubloc_guid char(255) hubloc_guid_sig text hubloc_hash char(255) hubloc_addr char(255) hubloc_flags int hubloc_status int hubloc_url char(255) hubloc_url_sig text hubloc_host char(255) hubloc_callback char(255) hubloc_connect char(255) hubloc_sitekey text hubloc_updated datetime hubloc_connected datetime

Only search for active hublocs - e.g. those that haven't been marked deleted

Referenced by zfinger_init().

zot_gethub (   $arr)

: zot_gethub

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.

Parameters
array$arr$arr must contain: string $arr['guid'] => guid of conversant string $arr['guid_sig'] => guid signed with conversant's private key string $arr['url'] => URL of the origination hub of this communication string $arr['url_sig'] => URL signed with conversant's private key
Returns
: array => hubloc record

Referenced by import_post(), post_post(), zot_fetch(), and zot_import().

zot_import (   $arr,
  $sender_url 
)

zot_import

Process an incoming array of messages which were obtained via pickup, and import, update, delete as directed.

Parameters
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.

The message types handled here are 'activity' (e.g. posts), 'mail' , 'profile', and 'channel_sync'

Returns
array => array ( [0] => string $channel_hash, [1] => string $delivery_status, [2] => string $address ) suitable for logging remotely, enumerating the processing results of each message/recipient combination.

Referenced by deliver_run(), and zot_fetch().

zot_new_uid (   $channel_nick)

Red implementation of zot protocol.

https://github.com/friendica/red/wiki/zot https://github.com/friendica/red/wiki/Zot—A-High-Level-Overview

zot_new_uid($channel_nick)

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. NOTE: zot doesn't require this to be unique. Internally we use a whirlpool hash of this guid and the signature of this guid signed with the channel private key. This can be verified and should make the probability of collision of the verified result negligible within the constraints of our immediate universe.

Parameters
stringchannel_nickname = unique nickname of controlling entity
Returns
string

Referenced by create_identity().

zot_process_response (   $hub,
  $arr,
  $outq 
)

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.

Parameters
string$hub- url of site we just contacted
array$arr- output of z_post_url()
array$outq- The queue structure attached to this request
Returns
nothing

Referenced by deliver_run(), and queue_run().

zot_refresh (   $them,
  $channel = null 
)

: zot_refresh($them, $channel = null)

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.

Parameters
array$them=> xchan structure of sender
array$channel=> local channel structure of target recipient, required for "friending" operations
Returns
boolean true if successful, else false

Referenced by connedit_content(), import_author_zot(), onepoll_run(), and post_post().

zot_register_hub (   $arr)

zot_register_hub($arr)

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.

Parameters
array$arr$arr must contain: string $arr['guid'] => guid of conversant string $arr['guid_sig'] => guid signed with conversant's private key string $arr['url'] => URL of the origination hub of this communication string $arr['url_sig'] => URL signed with conversant's private key
Returns
array => 'success' (boolean true or false) 'message' (optional error string only if success is false)

Referenced by post_post().

zot_zot (   $url,
  $data 
)

: zot_zot

Parameters
string $url
array $data
Returns
: array => see z_post_url for returned data format

Referenced by admin_page_hubloc_post(), deliver_run(), directory_run(), notifier_run(), post_init(), queue_run(), zot_fetch(), and zping_content().