mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
more cleanups + sanitize p3Peers::getPeerDetails avoid to look for port on null sockaddr_storage
This commit is contained in:
parent
ed7f958f95
commit
1303d855e6
@ -35,12 +35,16 @@
|
|||||||
#include <retroshare/rsids.h>
|
#include <retroshare/rsids.h>
|
||||||
|
|
||||||
/* The Main Interface Class - for information about your Peers
|
/* The Main Interface Class - for information about your Peers
|
||||||
* A peer is another RS instance, means associated with an SSL certificate
|
* 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
|
* 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
|
* Thus a peer have SSL cert details, and also the parent GPG details
|
||||||
*/
|
*/
|
||||||
class RsPeers;
|
class RsPeers;
|
||||||
extern RsPeers *rsPeers;
|
extern RsPeers *rsPeers;
|
||||||
|
|
||||||
|
/* TODO: 2015/12/31 As for type safetyness all those constant must be declared as enum!
|
||||||
|
* C++ now supports typed enum so there is no ambiguity in serialization size
|
||||||
|
*/
|
||||||
|
|
||||||
/* Trust Levels. Should be the same values than what is declared in PGPHandler.h */
|
/* Trust Levels. Should be the same values than what is declared in PGPHandler.h */
|
||||||
|
|
||||||
@ -216,7 +220,7 @@ class RsPeerDetails
|
|||||||
RsPgpId issuer;
|
RsPgpId issuer;
|
||||||
|
|
||||||
PGPFingerprintType fpr; /* pgp fingerprint */
|
PGPFingerprintType fpr; /* pgp fingerprint */
|
||||||
std::string authcode; // (cyril) what is this used for ?????
|
std::string authcode; // TODO: 2015/12/31 (cyril) what is this used for ?????
|
||||||
std::list<RsPgpId> gpgSigners;
|
std::list<RsPgpId> gpgSigners;
|
||||||
|
|
||||||
uint32_t trustLvl;
|
uint32_t trustLvl;
|
||||||
@ -231,58 +235,59 @@ class RsPeerDetails
|
|||||||
ServicePermissionFlags service_perm_flags ;
|
ServicePermissionFlags service_perm_flags ;
|
||||||
|
|
||||||
/* Network details (only valid if friend) */
|
/* Network details (only valid if friend) */
|
||||||
uint32_t state;
|
uint32_t state;
|
||||||
bool actAsServer;
|
bool actAsServer;
|
||||||
|
|
||||||
std::string connectAddr ; // current address if connected.
|
// TODO: 2015/12/31 to take advantage of multiple connection this must be
|
||||||
uint16_t connectPort ;
|
// replaced by a set of addresses
|
||||||
|
std::string connectAddr ; // current address if connected.
|
||||||
|
uint16_t connectPort ;
|
||||||
|
|
||||||
// Hidden Node details.
|
// Hidden Node details.
|
||||||
bool isHiddenNode;
|
bool isHiddenNode;
|
||||||
std::string hiddenNodeAddress;
|
std::string hiddenNodeAddress;
|
||||||
uint16_t hiddenNodePort;
|
uint16_t hiddenNodePort;
|
||||||
uint32_t hiddenType;
|
uint32_t hiddenType;
|
||||||
|
|
||||||
// Filled in for Standard Node.
|
// Filled in for Standard Node.
|
||||||
std::string localAddr;
|
std::string localAddr;
|
||||||
uint16_t localPort;
|
uint16_t localPort;
|
||||||
std::string extAddr;
|
std::string extAddr;
|
||||||
uint16_t extPort;
|
uint16_t extPort;
|
||||||
std::string dyndns;
|
std::string dyndns;
|
||||||
std::list<std::string> ipAddressList;
|
std::list<std::string> ipAddressList;
|
||||||
|
|
||||||
uint32_t netMode;
|
uint32_t netMode;
|
||||||
/* vis State */
|
/* vis State */
|
||||||
uint16_t vs_disc;
|
uint16_t vs_disc;
|
||||||
uint16_t vs_dht;
|
uint16_t vs_dht;
|
||||||
|
|
||||||
/* basic stats */
|
/* basic stats */
|
||||||
uint32_t lastConnect; /* how long ago */
|
uint32_t lastConnect; /* how long ago */
|
||||||
uint32_t lastUsed; /* how long ago since last used: signature verif, connect attempt, etc */
|
uint32_t lastUsed; /* how long ago since last used: signature verif, connect attempt, etc */
|
||||||
uint32_t connectState; /* RS_PEER_CONNECTSTATE_... */
|
uint32_t connectState; /* RS_PEER_CONNECTSTATE_... */
|
||||||
std::string connectStateString; /* Additional string like ip address */
|
std::string connectStateString; /* Additional string like ip address */
|
||||||
uint32_t connectPeriod;
|
uint32_t connectPeriod;
|
||||||
bool foundDHT;
|
bool foundDHT;
|
||||||
|
|
||||||
/* have we been denied */
|
/* have we been denied */
|
||||||
bool wasDeniedConnection;
|
bool wasDeniedConnection;
|
||||||
time_t deniedTS;
|
time_t deniedTS;
|
||||||
|
|
||||||
/* linkType */
|
/* linkType */
|
||||||
uint32_t linkType;
|
uint32_t 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
|
class RsPeerCryptoParams
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int connexion_state ;
|
int connexion_state;
|
||||||
std::string cipher_name ;
|
std::string cipher_name;
|
||||||
int cipher_bits_1 ;
|
int cipher_bits_1;
|
||||||
int cipher_bits_2 ;
|
int cipher_bits_2;
|
||||||
std::string cipher_version ;
|
std::string cipher_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RsGroupInfo
|
class RsGroupInfo
|
||||||
@ -292,131 +297,137 @@ public:
|
|||||||
|
|
||||||
std::string id;
|
std::string id;
|
||||||
std::string name;
|
std::string name;
|
||||||
uint32_t flag;
|
uint32_t flag;
|
||||||
|
|
||||||
std::set<RsPgpId> peerIds;
|
std::set<RsPgpId> peerIds;
|
||||||
};
|
};
|
||||||
|
|
||||||
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
|
||||||
|
* understanding must document it as soon as possible
|
||||||
|
*/
|
||||||
class RsPeers
|
class RsPeers
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RsPeers() { return; }
|
RsPeers() {}
|
||||||
virtual ~RsPeers() { return; }
|
virtual ~RsPeers() {}
|
||||||
|
|
||||||
/* Updates ... */
|
// TODO: 2015/12/31 is this dead code?
|
||||||
// not implemented
|
/* Updates ... */
|
||||||
//virtual bool FriendsChanged() = 0;
|
// not implemented
|
||||||
//virtual bool OthersChanged() = 0;
|
//virtual bool FriendsChanged() = 0;
|
||||||
|
//virtual bool OthersChanged() = 0;
|
||||||
|
|
||||||
/* Peer Details (Net & Auth) */
|
/* 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 getOnlineList(std::list<RsPeerId> &ssl_ids) = 0;
|
||||||
virtual bool getFriendList(std::list<RsPeerId> &ssl_ids) = 0;
|
virtual bool getFriendList(std::list<RsPeerId> &ssl_ids) = 0;
|
||||||
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 isOnline(const RsPeerId &ssl_id) = 0;
|
||||||
virtual bool isFriend(const RsPeerId &ssl_id) = 0;
|
virtual bool isFriend(const RsPeerId &ssl_id) = 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;
|
virtual bool getPeerDetails(const RsPeerId& ssl_id, RsPeerDetails &d) = 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
|
virtual RsPgpId getGPGId(const RsPeerId& sslid) = 0; //return the gpg id of the given ssl id
|
||||||
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
|
||||||
virtual bool getGPGValidList(std::list<RsPgpId> &gpg_ids) = 0;
|
virtual bool getGPGValidList(std::list<RsPgpId> &gpg_ids) = 0;
|
||||||
virtual bool getGPGAllList(std::list<RsPgpId> &gpg_ids) = 0;
|
virtual bool getGPGAllList(std::list<RsPgpId> &gpg_ids) = 0;
|
||||||
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) = 0;
|
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) = 0;
|
||||||
|
|
||||||
/* Add/Remove Friends */
|
/* Add/Remove Friends */
|
||||||
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT) = 0;
|
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT) = 0;
|
||||||
virtual bool removeFriend(const RsPgpId& pgp_id) = 0;
|
virtual bool removeFriend(const RsPgpId& pgp_id) = 0;
|
||||||
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>& pgp_ids,std::string& backup_file,uint32_t& error_code) = 0;
|
||||||
|
|
||||||
/* Network Stuff */
|
/* Network Stuff */
|
||||||
virtual bool connectAttempt(const RsPeerId& ssl_id) = 0;
|
virtual bool connectAttempt(const RsPeerId& ssl_id) = 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;
|
||||||
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port) = 0;
|
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port) = 0;
|
||||||
|
|
||||||
virtual bool setLocalAddress(const RsPeerId &ssl_id, const std::string &addr, uint16_t port) = 0;
|
virtual bool setLocalAddress(const RsPeerId &ssl_id, const std::string &addr, uint16_t port) = 0;
|
||||||
virtual bool setExtAddress( const RsPeerId &ssl_id, const std::string &addr, uint16_t port) = 0;
|
virtual bool setExtAddress( const RsPeerId &ssl_id, const std::string &addr, uint16_t port) = 0;
|
||||||
virtual bool setDynDNS(const RsPeerId &id, const std::string &addr) = 0;
|
virtual bool setDynDNS(const RsPeerId &id, const std::string &addr) = 0;
|
||||||
virtual bool setNetworkMode(const RsPeerId &ssl_id, uint32_t netMode) = 0;
|
virtual bool setNetworkMode(const RsPeerId &ssl_id, uint32_t netMode) = 0;
|
||||||
virtual bool setVisState(const RsPeerId &ssl_id, uint16_t vs_disc, uint16_t vs_dht) = 0;
|
virtual bool setVisState(const RsPeerId &ssl_id, uint16_t vs_disc, uint16_t vs_dht) = 0;
|
||||||
|
|
||||||
virtual bool getProxyServer(const uint32_t type, std::string &addr, uint16_t &port,uint32_t& status_flags) = 0;
|
virtual bool getProxyServer(const uint32_t type, std::string &addr, uint16_t &port,uint32_t& status_flags) = 0;
|
||||||
virtual bool setProxyServer(const uint32_t type, const std::string &addr, const uint16_t port) = 0;
|
virtual bool setProxyServer(const uint32_t type, const std::string &addr, const uint16_t port) = 0;
|
||||||
|
|
||||||
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;
|
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;
|
||||||
virtual void allowServerIPDetermination(bool) = 0;
|
virtual void allowServerIPDetermination(bool) = 0;
|
||||||
virtual bool resetOwnExternalAddressList() = 0;
|
virtual bool resetOwnExternalAddressList() = 0;
|
||||||
virtual bool getAllowServerIPDetermination() = 0 ;
|
virtual bool getAllowServerIPDetermination() = 0 ;
|
||||||
|
|
||||||
/* Auth Stuff */
|
/* Auth Stuff */
|
||||||
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures) = 0;
|
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures) = 0;
|
||||||
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) = 0;
|
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) = 0;
|
||||||
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 std::string GetRetroshareInvite(bool include_signatures) = 0;
|
virtual std::string GetRetroshareInvite(bool include_signatures) = 0;
|
||||||
virtual bool hasExportMinimal() = 0 ;
|
virtual bool hasExportMinimal() = 0;
|
||||||
|
|
||||||
// Add keys to the keyring
|
// Add keys to the keyring
|
||||||
virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,RsPgpId& pgp_id, std::string& error_string) = 0;
|
virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,RsPgpId& pgp_id, std::string& error_string) = 0;
|
||||||
|
|
||||||
// Gets the GPG details, but does not add the key to the keyring.
|
// 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;
|
virtual bool loadDetailsFromStringCert(const std::string& certGPG, RsPeerDetails &pd,uint32_t& error_code) = 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;
|
||||||
virtual bool saveCertificateToFile(const RsPeerId& id, const std::string &fname) = 0;
|
virtual bool saveCertificateToFile(const RsPeerId& id, const std::string &fname) = 0;
|
||||||
virtual std::string saveCertificateToString(const RsPeerId &id) = 0;
|
virtual std::string saveCertificateToString(const RsPeerId &id) = 0;
|
||||||
|
|
||||||
virtual bool signGPGCertificate(const RsPgpId &gpg_id) = 0;
|
virtual bool signGPGCertificate(const RsPgpId &gpg_id) = 0;
|
||||||
virtual bool trustGPGCertificate(const RsPgpId &gpg_id, uint32_t trustlvl) = 0;
|
virtual bool trustGPGCertificate(const RsPgpId &gpg_id, uint32_t trustlvl) = 0;
|
||||||
|
|
||||||
/* Group Stuff */
|
/* Group Stuff */
|
||||||
virtual bool addGroup(RsGroupInfo &groupInfo) = 0;
|
virtual bool addGroup(RsGroupInfo &groupInfo) = 0;
|
||||||
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
||||||
virtual bool removeGroup(const std::string &groupId) = 0;
|
virtual bool removeGroup(const std::string &groupId) = 0;
|
||||||
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
||||||
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
|
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
|
||||||
// groupId == "" && assign == false -> remove from all groups
|
// groupId == "" && assign == false -> remove from all groups
|
||||||
virtual bool assignPeerToGroup(const std::string &groupId, const RsPgpId& peerId, bool assign) = 0;
|
virtual bool assignPeerToGroup(const std::string &groupId, const RsPgpId& peerId, bool assign) = 0;
|
||||||
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign) = 0;
|
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign) = 0;
|
||||||
|
|
||||||
/* Group sharing permission */
|
/* Group sharing permission */
|
||||||
|
|
||||||
// Given
|
// Given
|
||||||
// - the peer id
|
// - the peer id
|
||||||
// - the permission flags of a given hash, e.g. a combination of
|
// - the permission flags of a given hash, e.g. a combination of
|
||||||
// RS_DIR_FLAGS_NETWORK_WIDE_OTHERS, RS_DIR_FLAGS_NETWORK_WIDE_GROUPS, RS_DIR_FLAGS_BROWSABLE_OTHERS and RS_DIR_FLAGS_BROWSABLE_GROUPS
|
// RS_DIR_FLAGS_NETWORK_WIDE_OTHERS, RS_DIR_FLAGS_NETWORK_WIDE_GROUPS, RS_DIR_FLAGS_BROWSABLE_OTHERS and RS_DIR_FLAGS_BROWSABLE_GROUPS
|
||||||
// - the parent groups of the file
|
// - the parent groups of the file
|
||||||
//
|
//
|
||||||
// ... computes the sharing file permission hint flags set for this peer, that is a combination of
|
// ... computes the sharing file permission hint flags set for this peer, that is a combination of
|
||||||
// RS_FILE_HINTS_NETWORK_WIDE and RS_FILE_HINTS_BROWSABLE.
|
// RS_FILE_HINTS_NETWORK_WIDE and RS_FILE_HINTS_BROWSABLE.
|
||||||
//
|
//
|
||||||
virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id,FileStorageFlags file_sharing_flags,const std::list<std::string>& file_parent_groups) = 0;
|
virtual FileSearchFlags computePeerPermissionFlags(
|
||||||
|
const RsPeerId& peer_id, FileStorageFlags file_sharing_flags,
|
||||||
|
const std::list<std::string>& file_parent_groups) = 0;
|
||||||
|
|
||||||
/* Service permission flags */
|
/* Service permission flags */
|
||||||
|
|
||||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) = 0;
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) = 0;
|
||||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) = 0;
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) = 0;
|
||||||
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) = 0;
|
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -243,21 +243,19 @@ bool p3Peers::isFriend(const RsPeerId &ssl_id)
|
|||||||
|
|
||||||
bool p3Peers::haveSecretKey(const RsPgpId& id)
|
bool p3Peers::haveSecretKey(const RsPgpId& id)
|
||||||
{
|
{
|
||||||
return AuthGPG::getAuthGPG()->haveSecretKey(id) ;
|
return AuthGPG::getAuthGPG()->haveSecretKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* There are too many dependancies of this function
|
/* There are too many dependancies of this function
|
||||||
* to shift it immeidately
|
* to shift it immeidately
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
std::cerr << "p3Peers::getPeerDetails() called for id : " << id << std::endl;
|
std::cerr << "p3Peers::getPeerDetails() called for id : " << id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// NOW Only for SSL Details.
|
|
||||||
|
|
||||||
RsPeerId sOwnId = AuthSSL::getAuthSSL()->OwnId();
|
RsPeerId sOwnId = AuthSSL::getAuthSSL()->OwnId();
|
||||||
peerState ps;
|
peerState ps;
|
||||||
|
|
||||||
@ -271,27 +269,11 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
|||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
std::cerr << "p3Peers::getPeerDetails() ERROR not an SSL Id: " << id << std::endl;
|
std::cerr << "p3Peers::getPeerDetails() ERROR not an SSL Id: " << id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return false ;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool res = getGPGDetails(id, d);
|
|
||||||
//
|
|
||||||
// d.isOnlyGPGdetail = true;
|
|
||||||
//
|
|
||||||
// if(id.length() == 16)
|
|
||||||
// d.service_perm_flags = mPeerMgr->servicePermissionFlags(id) ;
|
|
||||||
// else if(id.length() == 32)
|
|
||||||
// d.service_perm_flags = mPeerMgr->servicePermissionFlags(id) ;
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// std::cerr << "p3Peers::getPeerDetails() ERROR not an correct Id: " << id << std::endl;
|
|
||||||
// d.service_perm_flags = RS_SERVICE_PERM_NONE ;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return res ;
|
|
||||||
|
|
||||||
/* get from gpg (first), to fill in the sign and trust details */
|
/* get from gpg (first), to fill in the sign and trust details */
|
||||||
/* don't retrun now, we've got fill in the ssl and connection info */
|
/* don't return now, we've got fill in the ssl and connection info */
|
||||||
getGPGDetails(ps.gpg_id, d);
|
getGPGDetails(ps.gpg_id, d);
|
||||||
d.isOnlyGPGdetail = false;
|
d.isOnlyGPGdetail = false;
|
||||||
|
|
||||||
@ -299,7 +281,7 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
|||||||
d.id = id;
|
d.id = id;
|
||||||
d.location = ps.location;
|
d.location = ps.location;
|
||||||
|
|
||||||
d.service_perm_flags = mPeerMgr->servicePermissionFlags(ps.gpg_id) ;
|
d.service_perm_flags = mPeerMgr->servicePermissionFlags(ps.gpg_id);
|
||||||
|
|
||||||
/* generate */
|
/* generate */
|
||||||
d.authcode = "AUTHCODE";
|
d.authcode = "AUTHCODE";
|
||||||
@ -327,10 +309,28 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
|||||||
d.hiddenNodePort = 0;
|
d.hiddenNodePort = 0;
|
||||||
d.hiddenType = RS_HIDDEN_TYPE_NONE;
|
d.hiddenType = RS_HIDDEN_TYPE_NONE;
|
||||||
|
|
||||||
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
|
if (sockaddr_storage_isnull(ps.localaddr))
|
||||||
d.localPort = sockaddr_storage_port(ps.localaddr);
|
{
|
||||||
d.extAddr = sockaddr_storage_iptostring(ps.serveraddr);
|
d.localAddr = "INVALID_IP";
|
||||||
d.extPort = sockaddr_storage_port(ps.serveraddr);
|
d.localPort = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
|
||||||
|
d.localPort = sockaddr_storage_port(ps.localaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sockaddr_storage_isnull(ps.serveraddr))
|
||||||
|
{
|
||||||
|
d.extAddr = "INVALID_IP";
|
||||||
|
d.extPort = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d.extAddr = sockaddr_storage_iptostring(ps.serveraddr);
|
||||||
|
d.extPort = sockaddr_storage_port(ps.serveraddr);
|
||||||
|
}
|
||||||
|
|
||||||
d.dyndns = ps.dyndns;
|
d.dyndns = ps.dyndns;
|
||||||
|
|
||||||
std::list<pqiIpAddress>::iterator it;
|
std::list<pqiIpAddress>::iterator it;
|
||||||
|
@ -35,118 +35,115 @@ struct sockaddr_storage;
|
|||||||
|
|
||||||
class p3Peers: public RsPeers
|
class p3Peers: public RsPeers
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
p3Peers(p3LinkMgr *lm, p3PeerMgr *pm, p3NetMgr *nm);
|
p3Peers(p3LinkMgr *lm, p3PeerMgr *pm, p3NetMgr *nm);
|
||||||
virtual ~p3Peers() { return; }
|
virtual ~p3Peers() {}
|
||||||
|
|
||||||
/* Updates ... */
|
/* Updates ... */
|
||||||
virtual bool FriendsChanged();
|
virtual bool FriendsChanged();
|
||||||
virtual bool OthersChanged();
|
virtual bool OthersChanged();
|
||||||
|
|
||||||
/* Peer Details (Net & Auth) */
|
/* Peer Details (Net & Auth) */
|
||||||
virtual const RsPeerId& getOwnId();
|
virtual const RsPeerId& getOwnId();
|
||||||
|
|
||||||
virtual bool haveSecretKey(const RsPgpId& gpg_id) ;
|
virtual bool haveSecretKey(const RsPgpId& gpg_id) ;
|
||||||
|
|
||||||
|
virtual bool getOnlineList(std::list<RsPeerId> &ids);
|
||||||
|
virtual bool getFriendList(std::list<RsPeerId> &ids);
|
||||||
|
virtual bool getPeerCount (unsigned int *friendCount, unsigned int *onlineCount, bool ssl);
|
||||||
|
|
||||||
virtual bool getOnlineList(std::list<RsPeerId> &ids);
|
virtual bool isOnline(const RsPeerId &id);
|
||||||
virtual bool getFriendList(std::list<RsPeerId> &ids);
|
virtual bool isFriend(const RsPeerId &id);
|
||||||
//virtual bool getOthersList(std::list<std::string> &ids);
|
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend);
|
||||||
virtual bool getPeerCount (unsigned int *friendCount, unsigned int *onlineCount, bool ssl);
|
virtual std::string getGPGName(const RsPgpId &gpg_id);
|
||||||
|
virtual std::string getPeerName(const RsPeerId& ssl_or_gpg_id);
|
||||||
|
virtual bool getPeerDetails(const RsPeerId& ssl_or_gpg_id, RsPeerDetails &d);
|
||||||
|
|
||||||
virtual bool isOnline(const RsPeerId &id);
|
/* Using PGP Ids */
|
||||||
virtual bool isFriend(const RsPeerId &id);
|
virtual const RsPgpId& getGPGOwnId();
|
||||||
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend); //
|
virtual RsPgpId getGPGId(const RsPeerId &ssl_id);
|
||||||
virtual std::string getGPGName(const RsPgpId &gpg_id);
|
virtual bool isKeySupported(const RsPgpId& ids);
|
||||||
virtual std::string getPeerName(const RsPeerId& ssl_or_gpg_id);
|
virtual bool getGPGAcceptedList(std::list<RsPgpId> &ids);
|
||||||
virtual bool getPeerDetails(const RsPeerId& ssl_or_gpg_id, RsPeerDetails &d);
|
virtual bool getGPGSignedList(std::list<RsPgpId> &ids);
|
||||||
|
virtual bool getGPGValidList(std::list<RsPgpId> &ids);
|
||||||
/* Using PGP Ids */
|
virtual bool getGPGAllList(std::list<RsPgpId> &ids);
|
||||||
virtual const RsPgpId& getGPGOwnId();
|
virtual bool getGPGDetails(const RsPgpId &id, RsPeerDetails &d);
|
||||||
virtual RsPgpId getGPGId(const RsPeerId &ssl_id);
|
virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId> &ids);
|
||||||
virtual bool isKeySupported(const RsPgpId& ids);
|
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) ;
|
||||||
virtual bool getGPGAcceptedList(std::list<RsPgpId> &ids);
|
|
||||||
virtual bool getGPGSignedList(std::list<RsPgpId> &ids);
|
|
||||||
virtual bool getGPGValidList(std::list<RsPgpId> &ids);
|
|
||||||
virtual bool getGPGAllList(std::list<RsPgpId> &ids);
|
|
||||||
virtual bool getGPGDetails(const RsPgpId &id, RsPeerDetails &d);
|
|
||||||
virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId> &ids);
|
|
||||||
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) ;
|
|
||||||
|
|
||||||
/* Add/Remove Friends */
|
/* Add/Remove Friends */
|
||||||
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT);
|
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT);
|
||||||
virtual bool removeFriend(const RsPgpId& gpgid);
|
virtual bool removeFriend(const RsPgpId& gpgid);
|
||||||
virtual bool removeFriendLocation(const RsPeerId& sslId);
|
virtual bool removeFriendLocation(const RsPeerId& sslId);
|
||||||
|
|
||||||
/* keyring management */
|
/* keyring management */
|
||||||
virtual bool removeKeysFromPGPKeyring(const std::set<RsPgpId> &pgp_ids,std::string& backup_file,uint32_t& error_code);
|
virtual bool removeKeysFromPGPKeyring(const std::set<RsPgpId> &pgp_ids,std::string& backup_file,uint32_t& error_code);
|
||||||
|
|
||||||
/* Network Stuff */
|
/* Network Stuff */
|
||||||
virtual bool connectAttempt(const RsPeerId &id);
|
virtual bool connectAttempt(const RsPeerId &id);
|
||||||
virtual bool setLocation(const RsPeerId &ssl_id, const std::string &location);//location is shown in the gui to differentiate ssl certs
|
virtual bool setLocation(const RsPeerId &ssl_id, const std::string &location);//location is shown in the gui to differentiate ssl certs
|
||||||
virtual bool setHiddenNode(const RsPeerId &id, const std::string &hidden_node_address);
|
virtual bool setHiddenNode(const RsPeerId &id, const std::string &hidden_node_address);
|
||||||
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port);
|
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port);
|
||||||
|
|
||||||
virtual bool setLocalAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
|
virtual bool setLocalAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
|
||||||
virtual bool setExtAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
|
virtual bool setExtAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
|
||||||
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
|
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
|
||||||
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode);
|
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode);
|
||||||
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht);
|
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht);
|
||||||
|
|
||||||
virtual bool getProxyServer(const uint32_t type, std::string &addr, uint16_t &port,uint32_t& status);
|
virtual bool getProxyServer(const uint32_t type, std::string &addr, uint16_t &port,uint32_t& status);
|
||||||
virtual bool setProxyServer(const uint32_t type,const std::string &addr, const uint16_t port);
|
virtual bool setProxyServer(const uint32_t type, const std::string &addr, const uint16_t port);
|
||||||
virtual bool isProxyAddress(const uint32_t type,const sockaddr_storage&);
|
virtual bool isProxyAddress(const uint32_t type, const sockaddr_storage &addr);
|
||||||
|
|
||||||
virtual void getIPServersList(std::list<std::string>& ip_servers) ;
|
virtual void getIPServersList(std::list<std::string>& ip_servers);
|
||||||
virtual void allowServerIPDetermination(bool) ;
|
virtual void allowServerIPDetermination(bool);
|
||||||
virtual bool getAllowServerIPDetermination() ;
|
virtual bool getAllowServerIPDetermination();
|
||||||
virtual bool resetOwnExternalAddressList() ;
|
virtual bool resetOwnExternalAddressList();
|
||||||
|
|
||||||
/* Auth Stuff */
|
/* Auth Stuff */
|
||||||
// Get the invitation (GPG cert + local/ext address + SSL id for the given peer)
|
// Get the invitation (GPG cert + local/ext address + SSL id for the given peer)
|
||||||
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures);
|
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures);
|
||||||
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) ;
|
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) ;
|
||||||
|
|
||||||
// same but for own id
|
// same but for own id
|
||||||
virtual std::string GetRetroshareInvite(bool include_signatures);
|
virtual std::string GetRetroshareInvite(bool include_signatures);
|
||||||
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);
|
||||||
|
|
||||||
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);
|
||||||
virtual bool loadDetailsFromStringCert(const std::string &cert, RsPeerDetails &pd, uint32_t& error_code);
|
virtual bool loadDetailsFromStringCert(const std::string &cert, RsPeerDetails &pd, uint32_t& error_code);
|
||||||
|
|
||||||
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code);
|
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code);
|
||||||
virtual bool saveCertificateToFile(const RsPeerId &id, const std::string &fname);
|
virtual bool saveCertificateToFile(const RsPeerId &id, const std::string &fname);
|
||||||
virtual std::string saveCertificateToString(const RsPeerId &id);
|
virtual std::string saveCertificateToString(const RsPeerId &id);
|
||||||
|
|
||||||
virtual bool signGPGCertificate(const RsPgpId &id);
|
virtual bool signGPGCertificate(const RsPgpId &id);
|
||||||
virtual bool trustGPGCertificate(const RsPgpId &id, uint32_t trustlvl);
|
virtual bool trustGPGCertificate(const RsPgpId &id, uint32_t trustlvl);
|
||||||
|
|
||||||
/* Group Stuff */
|
/* Group Stuff */
|
||||||
virtual bool addGroup(RsGroupInfo &groupInfo);
|
virtual bool addGroup(RsGroupInfo &groupInfo);
|
||||||
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo);
|
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo);
|
||||||
virtual bool removeGroup(const std::string &groupId);
|
virtual bool removeGroup(const std::string &groupId);
|
||||||
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
|
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
|
||||||
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
|
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
|
||||||
virtual bool assignPeerToGroup(const std::string &groupId, const RsPgpId &peerId, bool assign);
|
virtual bool assignPeerToGroup(const std::string &groupId, const RsPgpId &peerId, bool assign);
|
||||||
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId>& peerIds, bool assign);
|
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId>& peerIds, bool assign);
|
||||||
|
|
||||||
virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id,FileStorageFlags share_flags,const std::list<std::string>& parent_groups) ;
|
virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id,FileStorageFlags share_flags,const std::list<std::string>& parent_groups);
|
||||||
|
|
||||||
// service permission stuff
|
// service permission stuff
|
||||||
|
|
||||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) ;
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id);
|
||||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId & ssl_id) ;
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId & ssl_id);
|
||||||
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) ;
|
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
p3LinkMgr *mLinkMgr;
|
p3LinkMgr *mLinkMgr;
|
||||||
p3PeerMgr *mPeerMgr;
|
p3PeerMgr *mPeerMgr;
|
||||||
p3NetMgr *mNetMgr;
|
p3NetMgr *mNetMgr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user