mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 08:59:37 -05:00
Expose RsPeers JSON API
Added also new method for better usability via the API that allow to add friend directly for RetroShare invitation (supports also URL) without having to call to mulptiple metods to set IP etc. RsPeers::acceptInvite /rsPeers/acceptInvite
This commit is contained in:
parent
a8ddec03fc
commit
cc6f0b1f05
@ -19,24 +19,24 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||||
* *
|
* *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
#ifndef RETROSHARE_PEER_GUI_INTERFACE_H
|
#pragma once
|
||||||
#define RETROSHARE_PEER_GUI_INTERFACE_H
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include <retroshare/rstypes.h>
|
#include "retroshare/rstypes.h"
|
||||||
#include <retroshare/rsfiles.h>
|
#include "retroshare/rsfiles.h"
|
||||||
#include <retroshare/rsids.h>
|
#include "retroshare/rsids.h"
|
||||||
#include "util/rsurl.h"
|
#include "util/rsurl.h"
|
||||||
|
#include "util/rsdeprecate.h"
|
||||||
|
|
||||||
/* The Main Interface Class - for information about your Peers
|
|
||||||
* A peer is another RS instance, means associated with an SSL certificate
|
|
||||||
* A same GPG person can have multiple peer running with different SSL certs signed by the same GPG key
|
|
||||||
* Thus a peer have SSL cert details, and also the parent GPG details
|
|
||||||
*/
|
|
||||||
class RsPeers;
|
class RsPeers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pointer to global instance of RsPeers service implementation
|
||||||
|
* @jsonapi{development}
|
||||||
|
*/
|
||||||
extern RsPeers* rsPeers;
|
extern RsPeers* rsPeers;
|
||||||
|
|
||||||
/* TODO: 2015/12/31 As for type safetyness all those constant must be declared as enum!
|
/* TODO: 2015/12/31 As for type safetyness all those constant must be declared as enum!
|
||||||
@ -203,11 +203,8 @@ std::string RsPeerNetModeString(uint32_t netModel);
|
|||||||
std::string RsPeerLastConnectString(uint32_t lastConnect);
|
std::string RsPeerLastConnectString(uint32_t lastConnect);
|
||||||
|
|
||||||
|
|
||||||
/* Details class */
|
struct RsPeerDetails : RsSerializable
|
||||||
class RsPeerDetails
|
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
|
|
||||||
RsPeerDetails();
|
RsPeerDetails();
|
||||||
|
|
||||||
/* Auth details */
|
/* Auth details */
|
||||||
@ -279,13 +276,61 @@ class RsPeerDetails
|
|||||||
|
|
||||||
/* linkType */
|
/* linkType */
|
||||||
uint32_t linkType;
|
uint32_t linkType;
|
||||||
|
|
||||||
|
/// @see RsSerializable
|
||||||
|
virtual void serial_process( RsGenericSerializer::SerializeJob j,
|
||||||
|
RsGenericSerializer::SerializeContext& ctx )
|
||||||
|
{
|
||||||
|
RS_SERIAL_PROCESS(isOnlyGPGdetail);
|
||||||
|
RS_SERIAL_PROCESS(id);
|
||||||
|
RS_SERIAL_PROCESS(gpg_id);
|
||||||
|
RS_SERIAL_PROCESS(name);
|
||||||
|
RS_SERIAL_PROCESS(email);
|
||||||
|
RS_SERIAL_PROCESS(location);
|
||||||
|
RS_SERIAL_PROCESS(org);
|
||||||
|
RS_SERIAL_PROCESS(issuer);
|
||||||
|
RS_SERIAL_PROCESS(fpr);
|
||||||
|
RS_SERIAL_PROCESS(authcode);
|
||||||
|
RS_SERIAL_PROCESS(gpgSigners);
|
||||||
|
RS_SERIAL_PROCESS(trustLvl);
|
||||||
|
RS_SERIAL_PROCESS(validLvl);
|
||||||
|
RS_SERIAL_PROCESS(ownsign);
|
||||||
|
RS_SERIAL_PROCESS(hasSignedMe);
|
||||||
|
RS_SERIAL_PROCESS(accept_connection);
|
||||||
|
RS_SERIAL_PROCESS(service_perm_flags);
|
||||||
|
RS_SERIAL_PROCESS(state);
|
||||||
|
RS_SERIAL_PROCESS(actAsServer);
|
||||||
|
RS_SERIAL_PROCESS(connectAddr);
|
||||||
|
RS_SERIAL_PROCESS(connectPort);
|
||||||
|
RS_SERIAL_PROCESS(isHiddenNode);
|
||||||
|
RS_SERIAL_PROCESS(hiddenNodeAddress);
|
||||||
|
RS_SERIAL_PROCESS(hiddenNodePort);
|
||||||
|
RS_SERIAL_PROCESS(hiddenType);
|
||||||
|
RS_SERIAL_PROCESS(localAddr);
|
||||||
|
RS_SERIAL_PROCESS(localPort);
|
||||||
|
RS_SERIAL_PROCESS(extAddr);
|
||||||
|
RS_SERIAL_PROCESS(extPort);
|
||||||
|
RS_SERIAL_PROCESS(dyndns);
|
||||||
|
RS_SERIAL_PROCESS(ipAddressList);
|
||||||
|
RS_SERIAL_PROCESS(netMode);
|
||||||
|
RS_SERIAL_PROCESS(vs_disc);
|
||||||
|
RS_SERIAL_PROCESS(vs_dht);
|
||||||
|
RS_SERIAL_PROCESS(lastConnect);
|
||||||
|
RS_SERIAL_PROCESS(lastUsed);
|
||||||
|
RS_SERIAL_PROCESS(connectState);
|
||||||
|
RS_SERIAL_PROCESS(connectStateString);
|
||||||
|
RS_SERIAL_PROCESS(connectPeriod);
|
||||||
|
RS_SERIAL_PROCESS(foundDHT);
|
||||||
|
RS_SERIAL_PROCESS(wasDeniedConnection);
|
||||||
|
RS_SERIAL_PROCESS(deniedTS);
|
||||||
|
RS_SERIAL_PROCESS(linkType);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// This class is used to get info about crytographic algorithms used with a
|
// This class is used to get info about crytographic algorithms used with a
|
||||||
// particular peer.
|
// particular peer.
|
||||||
class RsPeerCryptoParams
|
struct RsPeerCryptoParams
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
int connexion_state;
|
int connexion_state;
|
||||||
std::string cipher_name;
|
std::string cipher_name;
|
||||||
int cipher_bits_1;
|
int cipher_bits_1;
|
||||||
@ -293,9 +338,8 @@ public:
|
|||||||
std::string cipher_version;
|
std::string cipher_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RsGroupInfo : RsSerializable
|
struct RsGroupInfo : RsSerializable
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
RsGroupInfo();
|
RsGroupInfo();
|
||||||
|
|
||||||
RsNodeGroupId id;
|
RsNodeGroupId id;
|
||||||
@ -304,9 +348,11 @@ public:
|
|||||||
|
|
||||||
std::set<RsPgpId> peerIds;
|
std::set<RsPgpId> peerIds;
|
||||||
|
|
||||||
// RsSerializable interface
|
/// @see RsSerializable
|
||||||
public:
|
void serial_process(
|
||||||
void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) {
|
RsGenericSerializer::SerializeJob j,
|
||||||
|
RsGenericSerializer::SerializeContext &ctx)
|
||||||
|
{
|
||||||
RS_SERIAL_PROCESS(id);
|
RS_SERIAL_PROCESS(id);
|
||||||
RS_SERIAL_PROCESS(name);
|
RS_SERIAL_PROCESS(name);
|
||||||
RS_SERIAL_PROCESS(flag);
|
RS_SERIAL_PROCESS(flag);
|
||||||
@ -316,8 +362,11 @@ public:
|
|||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail);
|
std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail);
|
||||||
|
|
||||||
/* TODO: 2015/12/31 this class seems foundamental for RetroShare code
|
/** The Main Interface Class - for information about your Peers
|
||||||
* understanding must document it as soon as possible
|
* A peer is another RS instance, means associated with an SSL certificate
|
||||||
|
* A same GPG person can have multiple peer running with different SSL certs
|
||||||
|
* signed by the same GPG key
|
||||||
|
* Thus a peer have SSL cert details, and also the parent GPG details
|
||||||
*/
|
*/
|
||||||
class RsPeers
|
class RsPeers
|
||||||
{
|
{
|
||||||
@ -326,32 +375,86 @@ public:
|
|||||||
RsPeers() {}
|
RsPeers() {}
|
||||||
virtual ~RsPeers() {}
|
virtual ~RsPeers() {}
|
||||||
|
|
||||||
// TODO: 2015/12/31 is this dead code?
|
/**
|
||||||
/* Updates ... */
|
* @brief Get own SSL peer id
|
||||||
// not implemented
|
* @return own peer id
|
||||||
//virtual bool FriendsChanged() = 0;
|
*/
|
||||||
//virtual bool OthersChanged() = 0;
|
|
||||||
|
|
||||||
/* Peer Details (Net & Auth) */
|
|
||||||
virtual const RsPeerId& getOwnId() = 0;
|
virtual const RsPeerId& getOwnId() = 0;
|
||||||
|
|
||||||
virtual bool haveSecretKey(const RsPgpId& gpg_id) = 0 ;
|
virtual bool haveSecretKey(const RsPgpId& gpg_id) = 0 ;
|
||||||
|
|
||||||
virtual bool getOnlineList(std::list<RsPeerId> &ssl_ids) = 0;
|
/**
|
||||||
virtual bool getFriendList(std::list<RsPeerId> &ssl_ids) = 0;
|
* @brief Get trusted peers list
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[out] sslIds storage for the trusted peers
|
||||||
|
* @return false if error occurred, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool getFriendList(std::list<RsPeerId>& sslIds) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get connected peers list
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[out] sslIds storage for the peers
|
||||||
|
* @return false if error occurred, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool getOnlineList(std::list<RsPeerId> &sslIds) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get peers count
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[out] peersCount storage for trusted peers count
|
||||||
|
* @param[out] onlinePeersCount storage for online peers count
|
||||||
|
* @param[in] countLocations true to count multiple locations of same owner
|
||||||
|
* @return false if error occurred, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool getPeersCount(
|
||||||
|
uint32_t& peersCount, uint32_t& onlinePeersCount,
|
||||||
|
bool countLocations = true ) = 0;
|
||||||
|
|
||||||
|
RS_DEPRECATED
|
||||||
virtual bool getPeerCount(unsigned int *pnFriendCount, unsigned int *pnnOnlineCount, bool ssl) = 0;
|
virtual bool getPeerCount(unsigned int *pnFriendCount, unsigned int *pnnOnlineCount, bool ssl) = 0;
|
||||||
|
|
||||||
virtual bool isOnline(const RsPeerId &ssl_id) = 0;
|
/**
|
||||||
virtual bool isFriend(const RsPeerId &ssl_id) = 0;
|
* @brief Check if there is an established connection to the given peer
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] sslId id of the peer to check
|
||||||
|
* @return true if the connection is establisced, false otherwise
|
||||||
|
*/
|
||||||
|
virtual bool isOnline(const RsPeerId &sslId) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if given peer is a trusted node
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] sslId id of the peer to check
|
||||||
|
* @return true if the node is trusted, false otherwise
|
||||||
|
*/
|
||||||
|
virtual bool isFriend(const RsPeerId &sslId) = 0;
|
||||||
|
|
||||||
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend) = 0;
|
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend) = 0;
|
||||||
virtual std::string getPeerName(const RsPeerId &ssl_id) = 0;
|
virtual std::string getPeerName(const RsPeerId &ssl_id) = 0;
|
||||||
virtual std::string getGPGName(const RsPgpId& gpg_id) = 0;
|
virtual std::string getGPGName(const RsPgpId& gpg_id) = 0;
|
||||||
virtual bool getPeerDetails(const RsPeerId& ssl_id, RsPeerDetails &d) = 0;
|
|
||||||
|
/**
|
||||||
|
* @brief Get details details of the given peer
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] sslId id of the peer
|
||||||
|
* @param[out] det storage for the details of the peer
|
||||||
|
* @return false if error occurred, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool getPeerDetails(const RsPeerId& sslId, RsPeerDetails& det) = 0;
|
||||||
|
|
||||||
virtual bool getGPGDetails(const RsPgpId& gpg_id, RsPeerDetails &d) = 0;
|
virtual bool getGPGDetails(const RsPgpId& gpg_id, RsPeerDetails &d) = 0;
|
||||||
|
|
||||||
/* Using PGP Ids */
|
/* Using PGP Ids */
|
||||||
virtual const RsPgpId& getGPGOwnId() = 0;
|
virtual const RsPgpId& getGPGOwnId() = 0;
|
||||||
virtual RsPgpId getGPGId(const RsPeerId& sslid) = 0; //return the gpg id of the given ssl id
|
|
||||||
|
/**
|
||||||
|
* @brief Get PGP id for the given peer
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] sslId SSL id of the peer
|
||||||
|
* @return PGP id of the peer
|
||||||
|
*/
|
||||||
|
virtual RsPgpId getGPGId(const RsPeerId& sslId) = 0;
|
||||||
virtual bool isKeySupported(const RsPgpId& gpg_ids) = 0;
|
virtual bool isKeySupported(const RsPgpId& gpg_ids) = 0;
|
||||||
virtual bool getGPGAcceptedList(std::list<RsPgpId> &gpg_ids) = 0;
|
virtual bool getGPGAcceptedList(std::list<RsPgpId> &gpg_ids) = 0;
|
||||||
virtual bool getGPGSignedList(std::list<RsPgpId> &gpg_ids) = 0;//friends that we accpet to connect with but we don't want to sign their gpg key
|
virtual bool getGPGSignedList(std::list<RsPgpId> &gpg_ids) = 0;//friends that we accpet to connect with but we don't want to sign their gpg key
|
||||||
@ -360,16 +463,49 @@ public:
|
|||||||
virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId>& ids) = 0;
|
virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId>& ids) = 0;
|
||||||
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, std::string reason = "") = 0;
|
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, std::string reason = "") = 0;
|
||||||
|
|
||||||
/* Add/Remove Friends */
|
/**
|
||||||
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT) = 0;
|
* @brief Add trusted node
|
||||||
virtual bool removeFriend(const RsPgpId& pgp_id) = 0;
|
* @jsonapi{development}
|
||||||
|
* @param[in] sslId SSL id of the node to add
|
||||||
|
* @param[in] gpgId PGP id of the node to add
|
||||||
|
* @param[in] flags service permissions flag
|
||||||
|
* @return false if error occurred, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool addFriend( const RsPeerId &sslId, const RsPgpId& gpgId,
|
||||||
|
ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT ) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Revoke connection trust from to node
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] pgpId PGP id of the node
|
||||||
|
* @return false if error occurred, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool removeFriend(const RsPgpId& pgpId) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Remove location of a trusted node, useful to prune old unused
|
||||||
|
* locations of a trusted peer without revoking trust
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] sslId SSL id of the location to remove
|
||||||
|
* @return false if error occurred, true otherwise
|
||||||
|
*/
|
||||||
virtual bool removeFriendLocation(const RsPeerId& sslId) = 0;
|
virtual bool removeFriendLocation(const RsPeerId& sslId) = 0;
|
||||||
|
|
||||||
/* keyring management */
|
/* keyring management */
|
||||||
virtual bool removeKeysFromPGPKeyring(const std::set<RsPgpId>& pgp_ids,std::string& backup_file,uint32_t& error_code) = 0;
|
virtual bool removeKeysFromPGPKeyring(
|
||||||
|
const std::set<RsPgpId>& pgpIds, std::string& backupFile,
|
||||||
|
uint32_t& errorCode ) = 0;
|
||||||
|
|
||||||
/* Network Stuff */
|
/* Network Stuff */
|
||||||
virtual bool connectAttempt(const RsPeerId& ssl_id) = 0;
|
|
||||||
|
/**
|
||||||
|
* @brief Trigger connection attempt to given node
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] sslId SSL id of the node to connect
|
||||||
|
* @return false if error occurred, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool connectAttempt(const RsPeerId& sslId) = 0;
|
||||||
|
|
||||||
virtual bool setLocation(const RsPeerId &ssl_id, const std::string &location) = 0; // location is shown in the gui to differentiate ssl certs
|
virtual bool setLocation(const RsPeerId &ssl_id, const std::string &location) = 0; // location is shown in the gui to differentiate ssl certs
|
||||||
|
|
||||||
virtual bool setHiddenNode(const RsPeerId &id, const std::string &hidden_node_address) = 0;
|
virtual bool setHiddenNode(const RsPeerId &id, const std::string &hidden_node_address) = 0;
|
||||||
@ -393,6 +529,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get RetroShare invite of the given peer
|
* @brief Get RetroShare invite of the given peer
|
||||||
|
* @jsonapi{development}
|
||||||
* @param[in] sslId Id of the peer of which we want to generate an invite
|
* @param[in] sslId Id of the peer of which we want to generate an invite
|
||||||
* @param[in] includeSignatures true to add key signatures to the invite
|
* @param[in] includeSignatures true to add key signatures to the invite
|
||||||
* @param[in] includeExtraLocators false to avoid to add extra locators
|
* @param[in] includeExtraLocators false to avoid to add extra locators
|
||||||
@ -402,6 +539,17 @@ public:
|
|||||||
const RsPeerId& sslId, bool includeSignatures = false,
|
const RsPeerId& sslId, bool includeSignatures = false,
|
||||||
bool includeExtraLocators = true ) = 0;
|
bool includeExtraLocators = true ) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add trusted node from invite
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] invite invite string being it in cert or URL format
|
||||||
|
* @param[in] flags service permissions flag
|
||||||
|
* @return false if error occurred, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool acceptInvite(
|
||||||
|
const std::string& invite,
|
||||||
|
ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT ) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get RetroShare invite of our own peer
|
* @brief Get RetroShare invite of our own peer
|
||||||
* @param[in] includeSignatures true to add key signatures to the invite
|
* @param[in] includeSignatures true to add key signatures to the invite
|
||||||
@ -417,11 +565,31 @@ public:
|
|||||||
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) = 0;
|
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) = 0;
|
||||||
virtual bool hasExportMinimal() = 0;
|
virtual bool hasExportMinimal() = 0;
|
||||||
|
|
||||||
// Add keys to the keyring
|
/**
|
||||||
virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,RsPgpId& pgp_id, std::string& error_string) = 0;
|
* @brief Import certificate into the keyring
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] cert string representation of the certificate
|
||||||
|
* @param[out] sslId storage for the SSL id of the certificate
|
||||||
|
* @param[out] pgpId storage for the PGP id of the certificate
|
||||||
|
* @param[out] errorString storage for the possible error string
|
||||||
|
* @return false if error occurred, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool loadCertificateFromString(
|
||||||
|
const std::string& cert, RsPeerId& sslId, RsPgpId& pgpId,
|
||||||
|
std::string& errorString) = 0;
|
||||||
|
|
||||||
// Gets the GPG details, but does not add the key to the keyring.
|
/**
|
||||||
virtual bool loadDetailsFromStringCert(const std::string& certGPG, RsPeerDetails &pd,uint32_t& error_code) = 0;
|
* @brief Examine certificate and get details without importing into
|
||||||
|
* the keyring
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] cert string representation of the certificate
|
||||||
|
* @param[out] certDetails storage for the certificate details
|
||||||
|
* @param[out] errorCode storage for possible error number
|
||||||
|
* @return false if error occurred, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool loadDetailsFromStringCert(
|
||||||
|
const std::string& cert, RsPeerDetails& certDetails,
|
||||||
|
uint32_t& errorCode ) = 0;
|
||||||
|
|
||||||
// Certificate utils
|
// Certificate utils
|
||||||
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code) = 0;
|
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code) = 0;
|
||||||
@ -468,4 +636,5 @@ public:
|
|||||||
virtual bool getPeerMaximumRates(const RsPgpId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate) =0;
|
virtual bool getPeerMaximumRates(const RsPgpId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "pqi/authgpg.h"
|
#include "pqi/authgpg.h"
|
||||||
#include "retroshare/rsinit.h"
|
#include "retroshare/rsinit.h"
|
||||||
#include "retroshare/rsfiles.h"
|
#include "retroshare/rsfiles.h"
|
||||||
|
#include "util/rsurl.h"
|
||||||
|
|
||||||
#include "pgp/rscertificate.h"
|
#include "pgp/rscertificate.h"
|
||||||
|
|
||||||
@ -200,6 +201,15 @@ bool p3Peers::getFriendList(std::list<RsPeerId> &ids)
|
|||||||
// return true;
|
// return true;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
bool p3Peers::getPeersCount(
|
||||||
|
uint32_t& peersCount, uint32_t& onlinePeersCount,
|
||||||
|
bool countLocations )
|
||||||
|
{
|
||||||
|
peersCount = mPeerMgr->getFriendCount(countLocations, false);
|
||||||
|
onlinePeersCount = mPeerMgr->getFriendCount(countLocations, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool p3Peers::getPeerCount (unsigned int *friendCount, unsigned int *onlineCount, bool ssl)
|
bool p3Peers::getPeerCount (unsigned int *friendCount, unsigned int *onlineCount, bool ssl)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
@ -1099,6 +1109,72 @@ bool p3Peers::GetPGPBase64StringAndCheckSum( const RsPgpId& gpg_id,
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool p3Peers::acceptInvite( const std::string& invite,
|
||||||
|
ServicePermissionFlags flags )
|
||||||
|
{
|
||||||
|
if(invite.empty()) return false;
|
||||||
|
|
||||||
|
const std::string* radixPtr(&invite);
|
||||||
|
|
||||||
|
RsUrl url(invite);
|
||||||
|
std::map<std::string, std::string> query(url.query());
|
||||||
|
|
||||||
|
if(query.find("radix") != query.end())
|
||||||
|
radixPtr = &query["radix"];
|
||||||
|
|
||||||
|
const std::string& radix(*radixPtr);
|
||||||
|
if(radix.empty()) return false;
|
||||||
|
|
||||||
|
RsPgpId pgpId;
|
||||||
|
RsPeerId sslId;
|
||||||
|
std::string errorString;
|
||||||
|
|
||||||
|
if(!loadCertificateFromString(radix, sslId, pgpId, errorString))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
RsPeerDetails peerDetails;
|
||||||
|
uint32_t errorCode;
|
||||||
|
|
||||||
|
if(!loadDetailsFromStringCert(radix, peerDetails, errorCode))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(peerDetails.gpg_id.isNull())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
addFriend(peerDetails.id, peerDetails.gpg_id, flags);
|
||||||
|
|
||||||
|
if (!peerDetails.location.empty())
|
||||||
|
setLocation(peerDetails.id, peerDetails.location);
|
||||||
|
|
||||||
|
// Update new address even the peer already existed.
|
||||||
|
if (peerDetails.isHiddenNode)
|
||||||
|
{
|
||||||
|
setHiddenNode( peerDetails.id,
|
||||||
|
peerDetails.hiddenNodeAddress,
|
||||||
|
peerDetails.hiddenNodePort );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//let's check if there is ip adresses in the certificate.
|
||||||
|
if (!peerDetails.extAddr.empty() && peerDetails.extPort)
|
||||||
|
setExtAddress( peerDetails.id,
|
||||||
|
peerDetails.extAddr,
|
||||||
|
peerDetails.extPort );
|
||||||
|
if (!peerDetails.localAddr.empty() && peerDetails.localPort)
|
||||||
|
setLocalAddress( peerDetails.id,
|
||||||
|
peerDetails.localAddr,
|
||||||
|
peerDetails.localPort );
|
||||||
|
if (!peerDetails.dyndns.empty())
|
||||||
|
setDynDNS(peerDetails.id, peerDetails.dyndns);
|
||||||
|
for(auto&& ipr : peerDetails.ipAddressList)
|
||||||
|
addPeerLocator(
|
||||||
|
peerDetails.id,
|
||||||
|
RsUrl(ipr.substr(0, ipr.find(' '))) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::string p3Peers::GetRetroshareInvite(
|
std::string p3Peers::GetRetroshareInvite(
|
||||||
const RsPeerId& ssl_id, bool include_signatures,
|
const RsPeerId& ssl_id, bool include_signatures,
|
||||||
bool includeExtraLocators )
|
bool includeExtraLocators )
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "retroshare/rspeers.h"
|
#include "retroshare/rspeers.h"
|
||||||
#include "util/rsurl.h"
|
#include "util/rsurl.h"
|
||||||
|
#include "util/rsdeprecate.h"
|
||||||
|
|
||||||
class p3LinkMgr;
|
class p3LinkMgr;
|
||||||
class p3PeerMgr;
|
class p3PeerMgr;
|
||||||
@ -56,6 +57,11 @@ public:
|
|||||||
|
|
||||||
virtual bool getOnlineList(std::list<RsPeerId> &ids);
|
virtual bool getOnlineList(std::list<RsPeerId> &ids);
|
||||||
virtual bool getFriendList(std::list<RsPeerId> &ids);
|
virtual bool getFriendList(std::list<RsPeerId> &ids);
|
||||||
|
virtual bool getPeersCount(
|
||||||
|
uint32_t& peersCount, uint32_t& onlinePeersCount,
|
||||||
|
bool countLocations );
|
||||||
|
|
||||||
|
RS_DEPRECATED
|
||||||
virtual bool getPeerCount (unsigned int *friendCount, unsigned int *onlineCount, bool ssl);
|
virtual bool getPeerCount (unsigned int *friendCount, unsigned int *onlineCount, bool ssl);
|
||||||
|
|
||||||
virtual bool isOnline(const RsPeerId &id);
|
virtual bool isOnline(const RsPeerId &id);
|
||||||
@ -121,6 +127,11 @@ public:
|
|||||||
bool includeExtraLocators = true );
|
bool includeExtraLocators = true );
|
||||||
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum);
|
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum);
|
||||||
|
|
||||||
|
/// @see RsPeers::acceptInvite
|
||||||
|
virtual bool acceptInvite(
|
||||||
|
const std::string& invite,
|
||||||
|
ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT );
|
||||||
|
|
||||||
virtual bool hasExportMinimal();
|
virtual bool hasExportMinimal();
|
||||||
|
|
||||||
virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,RsPgpId& pgp_id, std::string& error_string);
|
virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,RsPgpId& pgp_id, std::string& error_string);
|
||||||
|
Loading…
Reference in New Issue
Block a user