added some documentation to the friend server

This commit is contained in:
csoler 2022-11-05 20:17:55 +01:00
parent f7c22af995
commit d6aa58d52c

View File

@ -31,12 +31,81 @@
class RsFriendServerClientRemoveItem;
class RsFriendServerClientPublishItem;
// Storage for peer-related information as known by the friend server.
// Peers send to the friend server the list of peers they already have, with their own friendship level with that peer.
// The FS needs to send back a list of peers, with the friendship level to the current peer.
// In the list of closest peers, the reverse friendship levels are stored: for a peer A the reverse friendship level to peer B is whether B has
// added A as friend or not.
// In the list of friends for a peer, the forward FL is stored. The forward FL of a peer A to a peer B is whether A has added B as friend or not.
// +================================================================+
// | o---o o |
// | \ / - Retroshare Friend Server - / \ |
// | o o---o |
// +================================================================+
//
// The friend server facilitates a group of RS Tor-nodes to make friends. It maintains a pool of
// participants (RS nodes currently susbscribing to the friend server) and advertise them to each other
// as possible friends. Its goal is to allow new RS users to quickly experiment with the software without
// compromising their anonymity.
//
// Implementation
// ==============
//
// The implementation is entirely client-based: clients make a request, and get a response. No connection is maintained
// beyond this interaction. Consequently, the friend server returns a random ID to each client that the client can use to
// e.g. signal its departure from the friend server and the release of its data.
//
// Both client and server use a binary interface linked to a proxy-connected socket to stream RS items, everything
// happenning on top of Tor connections.
//
// Algorithms
// ==========
//
// * Protocol
//
// Retroshare Client Server (Friend Server)
//
// ------------ Tor connection --------> no action
// Server online MSG <-------------- Tor ACK ------------
//
//
// Friend Req. loop ------------ Friend Request --------> Friend list calculation / update
// <---------- Friend list + ID --------
//
//
// FS disabled ------------ FS Close + ID ---------> Data cleaning, peer removal.
//
//
// * Friend selection
//
// In order to reduce the ease to retrieve the list of all participants to a friend server, the
// friend server always returns the same list of friends to a given peer. To do so, participants are sorted
// for each peer, using a XOR distance such as:
//
// d(P1,P2) = P1 (XOR) P2 (XOR) R
//
// ...where R is a random bias.
//
// Since being in the n closest peers is not a reflexive relationship (P1 may be within the n closest peers
// to P2 but P2 may not be in the n closest peers to P1), selected friends for peer A are picked from both
// the closest peers of A, and the peers that received the RS certificate of A.
//
// Another important effect of the stability of retrieved friends is to maintain a network that is not
// fully connected and stable over time, which corresponds to the mesh model of the RS network.
//
// * Peer friendship level
//
// For display purposes, the friend server also stores the "friendship level" for each pair of peers,
// that means whether the peer has added the other peer as friend, or only reveived his key, etc.
//
// Peers send to the friend server the list of peers they already have, with their own friendship
// level with that peer. The FS needs to send back a list of peers, with the friendship level to the current peer.
// In the list of closest peers, the reverse friendship levels are stored: for a peer A the reverse friendship
// level to peer B is whether B has added A as friend or not.In the list of friends for a peer, the forward FL
// is stored. The forward FL of a peer A to a peer B is whether A has added B as friend or not.
//
// * Security
//
// Obviously the friend server knows who is possibly connected to whom. Since the connections to the
// friend server are anonymous, this information is difficult to protect, although the implementation
// currently makes it difficult to retrieve.
//
// The friend server is only available to Tor nodes, since it allows RS nodes to connect to random peers.
// This allows trying the software without compromizing one's privacy.
struct PeerInfo
{