mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-01 04:46:47 -05:00
Gossip discovery refinement
Rename from RsDisc to more descriptive RsGossipDiscovery Keep full retrocompatibility suggesting usage of RsGossipDiscovery Add capability to send and receive full RetroShare invitation Emit event when receiving a full invitation Start using new debug utilities Use enum class instead of defines and constant where appropriate
This commit is contained in:
parent
4e1280839a
commit
b1285a5de7
10 changed files with 473 additions and 391 deletions
|
|
@ -1,9 +1,9 @@
|
|||
/*******************************************************************************
|
||||
* libretroshare/src/retroshare: rsdht.h *
|
||||
* RetroShare gossip discovery - discovery2 retro-compatibility include *
|
||||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright 2008-2008 by Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2019 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
|
@ -19,66 +19,14 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
#ifndef RETROSHARE_DISC_GUI_INTERFACE_H
|
||||
#define RETROSHARE_DISC_GUI_INTERFACE_H
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <retroshare/rstypes.h>
|
||||
#include "retroshare/rsgossipdiscovery.h"
|
||||
#include "util/rsdeprecate.h"
|
||||
|
||||
/* The Main Interface Class - for information about your Peers */
|
||||
class RsDisc;
|
||||
#warning "Including retroshare/rsdisc.h is deprecated, \
|
||||
use retroshare/rsgossipdiscovery.h instead"
|
||||
|
||||
/**
|
||||
* Pointer to global instance of RsDisc service implementation
|
||||
* @jsonapi{development}
|
||||
*/
|
||||
extern RsDisc *rsDisc;
|
||||
using RsDisc RS_DEPRECATED_FOR("RsGossipDiscovery") = RsGossipDiscovery;
|
||||
|
||||
class RsDisc
|
||||
{
|
||||
public:
|
||||
|
||||
RsDisc() {}
|
||||
virtual ~RsDisc() {}
|
||||
|
||||
/**
|
||||
* @brief getDiscFriends get a list with all friends (ssl id) to a given friend (ssl id)
|
||||
* @jsonapi{development}
|
||||
* @param[in] id peer to get the friends of
|
||||
* @param[out] friends list of friends (ssl id)
|
||||
* @return true on success false otherwise
|
||||
*/
|
||||
virtual bool getDiscFriends(const RsPeerId &id, std::list<RsPeerId>& friends) = 0;
|
||||
|
||||
/**
|
||||
* @brief getDiscPgpFriends get a list with all friends (pgp id) to a given friend (pgp id)
|
||||
* @jsonapi{development}
|
||||
* @param[in] pgpid peer to get the friends of
|
||||
* @param[out] gpg_friends list of friends (gpg id)
|
||||
* @return true on success false otherwise
|
||||
*/
|
||||
virtual bool getDiscPgpFriends(const RsPgpId &pgpid, std::list<RsPgpId>& gpg_friends) = 0;
|
||||
|
||||
/**
|
||||
* @brief getPeerVersion get the version string of a peer.
|
||||
* @jsonapi{development}
|
||||
* @param[in] id peer to get the version string of
|
||||
* @param[out] versions version string sent by the peer
|
||||
* @return true on success false otherwise
|
||||
*/
|
||||
virtual bool getPeerVersion(const RsPeerId &id, std::string &versions) = 0;
|
||||
|
||||
/**
|
||||
* @brief getWaitingDiscCount get the number of queued discovery packets.
|
||||
* @jsonapi{development}
|
||||
* @param[out] sendCount number of queued outgoing packets
|
||||
* @param[out] recvCount number of queued incoming packets
|
||||
* @return true on success false otherwise
|
||||
*/
|
||||
virtual bool getWaitingDiscCount(size_t &sendCount, size_t &recvCount) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
#define rsDisc rsGossipDiscovery.get()
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ enum class RsEventType : uint32_t
|
|||
BROADCAST_DISCOVERY_PEER_FOUND = 1,
|
||||
|
||||
/// @see RsDiscPendingPgpReceivedEvent
|
||||
GOSSIP_DISCOVERY_PENDIG_PGP_CERT_RECEIVED = 2,
|
||||
GOSSIP_DISCOVERY_INVITE_RECEIVED = 2,
|
||||
|
||||
/// @see AuthSSL
|
||||
AUTHSSL_CONNECTION_AUTENTICATION = 3,
|
||||
|
|
|
|||
134
libretroshare/src/retroshare/rsgossipdiscovery.h
Normal file
134
libretroshare/src/retroshare/rsgossipdiscovery.h
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
/*******************************************************************************
|
||||
* RetroShare remote peers gossip discovery *
|
||||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright (C) 2008 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2019 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public License *
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
#include "retroshare/rstypes.h"
|
||||
#include "retroshare/rsevents.h"
|
||||
#include "util/rsmemory.h"
|
||||
|
||||
class RsGossipDiscovery;
|
||||
|
||||
/**
|
||||
* Pointer to global instance of RsGossipDiscovery service implementation
|
||||
* @jsonapi{development}
|
||||
*
|
||||
* TODO: this should become std::weak_ptr once we have a reasonable services
|
||||
* management.
|
||||
*/
|
||||
extern std::shared_ptr<RsGossipDiscovery> rsGossipDiscovery;
|
||||
|
||||
/**
|
||||
* @brief Emitted when a pending PGP certificate is received
|
||||
*/
|
||||
struct RsGossipDiscoveryFriendInviteReceivedEvent : RsEvent
|
||||
{
|
||||
RsGossipDiscoveryFriendInviteReceivedEvent(
|
||||
const std::string& invite );
|
||||
|
||||
std::string mInvite;
|
||||
|
||||
/// @see RsSerializable
|
||||
virtual void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx )
|
||||
{
|
||||
RsEvent::serial_process(j,ctx);
|
||||
RS_SERIAL_PROCESS(mInvite);
|
||||
}
|
||||
};
|
||||
|
||||
class RsGossipDiscovery
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief getDiscFriends get a list of all friends of a given friend
|
||||
* @jsonapi{development}
|
||||
* @param[in] id peer to get the friends of
|
||||
* @param[out] friends list of friends (ssl id)
|
||||
* @return true on success false otherwise
|
||||
*/
|
||||
virtual bool getDiscFriends( const RsPeerId& id,
|
||||
std::list<RsPeerId>& friends ) = 0;
|
||||
|
||||
/**
|
||||
* @brief getDiscPgpFriends get a list of all friends of a given friend
|
||||
* @jsonapi{development}
|
||||
* @param[in] pgpid peer to get the friends of
|
||||
* @param[out] gpg_friends list of friends (gpg id)
|
||||
* @return true on success false otherwise
|
||||
*/
|
||||
virtual bool getDiscPgpFriends(
|
||||
const RsPgpId& pgpid, std::list<RsPgpId>& gpg_friends ) = 0;
|
||||
|
||||
/**
|
||||
* @brief getPeerVersion get the version string of a peer.
|
||||
* @jsonapi{development}
|
||||
* @param[in] id peer to get the version string of
|
||||
* @param[out] version version string sent by the peer
|
||||
* @return true on success false otherwise
|
||||
*/
|
||||
virtual bool getPeerVersion(const RsPeerId& id, std::string& version) = 0;
|
||||
|
||||
/**
|
||||
* @brief getWaitingDiscCount get the number of queued discovery packets.
|
||||
* @jsonapi{development}
|
||||
* @param[out] sendCount number of queued outgoing packets
|
||||
* @param[out] recvCount number of queued incoming packets
|
||||
* @return true on success false otherwise
|
||||
*/
|
||||
virtual bool getWaitingDiscCount(size_t& sendCount, size_t& recvCount) = 0;
|
||||
|
||||
/**
|
||||
* @brief Send RetroShare invite to given peer
|
||||
* @jsonapi{development}
|
||||
* @param[in] inviteId id of peer of which send the invite
|
||||
* @param[in] toSslId ssl id of the destination peer
|
||||
* @param[out] errorMessage Optional storage for the error message,
|
||||
* meaningful only on failure.
|
||||
* @return true on success false otherwise
|
||||
*/
|
||||
virtual bool sendInvite(
|
||||
const RsPeerId& inviteId, const RsPeerId& toSslId,
|
||||
std::string& errorMessage = RS_DEFAULT_STORAGE_PARAM(std::string)
|
||||
) = 0;
|
||||
|
||||
/**
|
||||
* @brief Request RetroShare certificate to given peer
|
||||
* @jsonapi{development}
|
||||
* @param[in] inviteId id of the peer of which request the invite
|
||||
* @param[in] toSslId id of the destination of the request
|
||||
* @param[out] errorMessage Optional storage for the error message,
|
||||
* meaningful only on failure.
|
||||
* @return true on success false otherwise
|
||||
*/
|
||||
virtual bool requestInvite(
|
||||
const RsPeerId& inviteId, const RsPeerId& toSslId,
|
||||
std::string& errorMessage = RS_DEFAULT_STORAGE_PARAM(std::string)
|
||||
) = 0;
|
||||
|
||||
virtual ~RsGossipDiscovery();
|
||||
};
|
||||
|
|
@ -30,6 +30,7 @@
|
|||
#include "retroshare/rsfiles.h"
|
||||
#include "retroshare/rsversion.h"
|
||||
#include "util/rsinitedptr.h"
|
||||
#include "retroshare/rsdisc.h"
|
||||
|
||||
class RsPluginHandler ;
|
||||
extern RsPluginHandler *rsPlugins ;
|
||||
|
|
@ -40,7 +41,6 @@ class RsReputations ;
|
|||
class RsTurtle ;
|
||||
class RsGxsTunnelService ;
|
||||
class RsDht ;
|
||||
class RsDisc ;
|
||||
class RsMsgs ;
|
||||
class RsGxsForums;
|
||||
class RsGxsChannels;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue