Send RsDiscReply information of the connected friend to himself too, when there is only one ssl id available. The reason is, that the signers of the gpg key has to be transfered. The friend skips the own RsDiscReply informations, but imports the gpg key.

Reload all gpg keys in AuthGPGimpl::LoadCertificateFromString, when new signatures are added - not only the key was imported.
Changed parameters of RsPeers and AuthGPG from "std::string" to "const std::string&"

Recompile of the GUI needed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3753 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-11-06 16:40:18 +00:00
parent a32bcbb635
commit c19c8b5532
6 changed files with 133 additions and 143 deletions

View File

@ -307,7 +307,7 @@ bool AuthGPGimpl::availableGPGCertificatesWithPrivateKeys(std::list<std::string>
* This function must be called successfully (return == 1)
* before anything else can be done. (except above fn).
*/
int AuthGPGimpl::GPGInit(std::string ownId)
int AuthGPGimpl::GPGInit(const std::string &ownId)
{
std::cerr << "AuthGPGimpl::GPGInit() called with own gpg id : " << ownId << std::endl;
@ -1109,7 +1109,7 @@ bool AuthGPGimpl::CloseAuth()
}
/**** These Two are common */
std::string AuthGPGimpl::getGPGName(GPG_id id)
std::string AuthGPGimpl::getGPGName(const std::string &id)
{
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
@ -1121,7 +1121,7 @@ std::string AuthGPGimpl::getGPGName(GPG_id id)
}
/**** These Two are common */
std::string AuthGPGimpl::getGPGEmail(GPG_id id)
std::string AuthGPGimpl::getGPGEmail(const std::string &id)
{
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
@ -1159,7 +1159,7 @@ bool AuthGPGimpl::getGPGAllList(std::list<std::string> &ids)
return true;
}
bool AuthGPGimpl::getGPGDetails(std::string id, RsPeerDetails &d)
bool AuthGPGimpl::getGPGDetails(const std::string &id, RsPeerDetails &d)
{
#ifdef GPG_DEBUG
std::cerr << "AuthGPGimpl::getPGPDetails() called for : " << id << std::endl;
@ -1275,7 +1275,7 @@ bool AuthGPGimpl::getGPGSignedList(std::list<std::string> &ids)
return true;
}
bool AuthGPGimpl::isGPGValid(GPG_id id)
bool AuthGPGimpl::isGPGValid(const std::string &id)
{
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
certmap::iterator it;
@ -1287,7 +1287,7 @@ bool AuthGPGimpl::isGPGValid(GPG_id id)
}
bool AuthGPGimpl::isGPGId(GPG_id id)
bool AuthGPGimpl::isGPGId(const std::string &id)
{
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
certmap::iterator it;
@ -1299,7 +1299,7 @@ bool AuthGPGimpl::isGPGId(GPG_id id)
}
bool AuthGPGimpl::isGPGSigned(GPG_id id)
bool AuthGPGimpl::isGPGSigned(const std::string &id)
{
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
certmap::iterator it;
@ -1310,7 +1310,7 @@ bool AuthGPGimpl::isGPGSigned(GPG_id id)
return false;
}
bool AuthGPGimpl::isGPGAccepted(GPG_id id)
bool AuthGPGimpl::isGPGAccepted(const std::string &id)
{
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
certmap::iterator it;
@ -1331,7 +1331,7 @@ bool AuthGPGimpl::isGPGAccepted(GPG_id id)
/* SKTAN : do not know how to use std::string id */
std::string AuthGPGimpl::SaveCertificateToString(std::string id)
std::string AuthGPGimpl::SaveCertificateToString(const std::string &id)
{
if (!isGPGId(id)) {
@ -1381,7 +1381,7 @@ std::string AuthGPGimpl::SaveCertificateToString(std::string id)
}
/* import to GnuPG and other Certificates */
bool AuthGPGimpl::LoadCertificateFromString(std::string str, std::string &gpg_id)
bool AuthGPGimpl::LoadCertificateFromString(const std::string &str, std::string &gpg_id)
{
if (str == "") {
#ifdef GPG_DEBUG
@ -1430,7 +1430,7 @@ bool AuthGPGimpl::LoadCertificateFromString(std::string str, std::string &gpg_id
#ifdef GPG_DEBUG
std::cerr << "AuthGPGimpl::LoadCertificateFromString() Importing considered folowing fpr : " << fingerprint << std::endl;
#endif
imported = res->imported;
imported = res->imported || res->new_signatures;
#ifdef GPG_DEBUG
fprintf(stderr, "ImportCertificate(Considered: %d Imported: %d)\n",
@ -1481,7 +1481,7 @@ bool AuthGPGimpl::LoadCertificateFromString(std::string str, std::string &gpg_id
/*************************************/
/* These take PGP Ids */
bool AuthGPGimpl::setAcceptToConnectGPGCertificate(std::string gpg_id, bool acceptance)
bool AuthGPGimpl::setAcceptToConnectGPGCertificate(const std::string &gpg_id, bool acceptance)
{
#ifdef GPG_DEBUG
@ -1507,7 +1507,7 @@ bool AuthGPGimpl::setAcceptToConnectGPGCertificate(std::string gpg_id, bool acce
}
/* These take PGP Ids */
bool AuthGPGimpl::SignCertificateLevel0(GPG_id id)
bool AuthGPGimpl::SignCertificateLevel0(const std::string &id)
{
#ifdef GPG_DEBUG
@ -1525,7 +1525,7 @@ bool AuthGPGimpl::SignCertificateLevel0(GPG_id id)
return true;
}
bool AuthGPGimpl::RevokeCertificate(std::string id)
bool AuthGPGimpl::RevokeCertificate(const std::string &id)
{
//RsStackMutex stack(gpgMtx); /******* LOCKED ******/
@ -1536,7 +1536,7 @@ bool AuthGPGimpl::RevokeCertificate(std::string id)
return false;
}
bool AuthGPGimpl::TrustCertificate(std::string id, int trustlvl)
bool AuthGPGimpl::TrustCertificate(const std::string &id, int trustlvl)
{
#ifdef GPG_DEBUG
std::cerr << "AuthGPGimpl::TrustCertificate(" << id << ", " << trustlvl << ")" << std::endl;
@ -1583,7 +1583,7 @@ bool AuthGPGimpl::VerifySignBin(const void *data, uint32_t datalen, unsigned cha
/* Sign/Trust stuff */
int AuthGPGimpl::privateSignCertificate(std::string id)
int AuthGPGimpl::privateSignCertificate(const std::string &id)
{
/* The key should be in Others list and not in Peers list ??
* Once the key is signed, it moves from Others to Peers list ???
@ -1642,14 +1642,14 @@ int AuthGPGimpl::privateSignCertificate(std::string id)
}
/* revoke the signature on Certificate */
int AuthGPGimpl::privateRevokeCertificate(std::string id)
int AuthGPGimpl::privateRevokeCertificate(const std::string &id)
{
//RsStackMutex stack(gpgMtx); /******* LOCKED ******/
return 0;
}
int AuthGPGimpl::privateTrustCertificate(std::string id, int trustlvl)
int AuthGPGimpl::privateTrustCertificate(const std::string &id, int trustlvl)
{
/* The certificate should be in Peers list ??? */
if(!isGPGAccepted(id)) {

View File

@ -50,8 +50,6 @@
#include <map>
#include "pqi/p3cfgmgr.h"
#define GPG_id std::string
#define MAX_GPG_SIGNATURE_SIZE 4096
/*!
@ -174,7 +172,7 @@ virtual bool active() = 0;
virtual bool InitAuth () = 0;
/* Init by generating new Own PGP Cert, or selecting existing PGP Cert */
virtual int GPGInit(std::string ownId) = 0;
virtual int GPGInit(const std::string &ownId) = 0;
virtual bool CloseAuth() = 0;
virtual bool GeneratePGPCertificate(std::string name, std::string email, std::string passwd, std::string &pgpId, std::string &errString) = 0;
@ -189,23 +187,23 @@ virtual bool GeneratePGPCertificate(std::string name, std::string email, std:
* provide access to details in cache list.
*
****/
virtual std::string getGPGName(GPG_id pgp_id) = 0;
virtual std::string getGPGEmail(GPG_id pgp_id) = 0;
virtual std::string getGPGName(const std::string &pgp_id) = 0;
virtual std::string getGPGEmail(const std::string &pgp_id) = 0;
/* PGP web of trust management */
virtual std::string getGPGOwnId() = 0;
virtual std::string getGPGOwnName() = 0;
//virtual std::string getGPGOwnEmail() = 0;
virtual bool getGPGDetails(std::string id, RsPeerDetails &d) = 0;
virtual bool getGPGDetails(const std::string &id, RsPeerDetails &d) = 0;
virtual bool getGPGAllList(std::list<std::string> &ids) = 0;
virtual bool getGPGValidList(std::list<std::string> &ids) = 0;
virtual bool getGPGAcceptedList(std::list<std::string> &ids) = 0;
virtual bool getGPGSignedList(std::list<std::string> &ids) = 0;
virtual bool isGPGValid(std::string id) = 0;
virtual bool isGPGSigned(std::string id) = 0;
virtual bool isGPGAccepted(std::string id) = 0;
virtual bool isGPGId(GPG_id id) = 0;
virtual bool isGPGValid(const std::string &id) = 0;
virtual bool isGPGSigned(const std::string &id) = 0;
virtual bool isGPGAccepted(const std::string &id) = 0;
virtual bool isGPGId(const std::string &id) = 0;
/*********************************************************************************/
/************************* STAGE 4 ***********************************************/
@ -214,8 +212,8 @@ virtual bool isGPGId(GPG_id id) = 0;
* STAGE 4: Loading and Saving Certificates. (Strings and Files)
*
****/
virtual bool LoadCertificateFromString(std::string pem, std::string &gpg_id) = 0;
virtual std::string SaveCertificateToString(std::string id) = 0;
virtual bool LoadCertificateFromString(const std::string &pem, std::string &gpg_id) = 0;
virtual std::string SaveCertificateToString(const std::string &id) = 0;
/*********************************************************************************/
/************************* STAGE 6 ***********************************************/
@ -227,13 +225,13 @@ virtual std::string SaveCertificateToString(std::string id) = 0;
* done in gpgroot already.
*
****/
virtual bool setAcceptToConnectGPGCertificate(std::string gpg_id, bool acceptance) = 0; //don't act on the gpg key, use a seperate set
virtual bool SignCertificateLevel0(std::string id) = 0;
virtual bool RevokeCertificate(std::string id) = 0; /* Particularly hard - leave for later */
virtual bool setAcceptToConnectGPGCertificate(const std::string &gpg_id, bool acceptance) = 0; //don't act on the gpg key, use a seperate set
virtual bool SignCertificateLevel0(const std::string &id) = 0;
virtual bool RevokeCertificate(const std::string &id) = 0; /* Particularly hard - leave for later */
//virtual bool TrustCertificateNone(std::string id) = 0;
//virtual bool TrustCertificateMarginally(std::string id) = 0;
//virtual bool TrustCertificateFully(std::string id) = 0;
virtual bool TrustCertificate(std::string id, int trustlvl) = 0; //trustlvl is 2 for none, 3 for marginal and 4 for full trust
virtual bool TrustCertificate(const std::string &id, int trustlvl) = 0; //trustlvl is 2 for none, 3 for marginal and 4 for full trust
/*********************************************************************************/
/************************* STAGE 7 ***********************************************/
@ -294,7 +292,7 @@ virtual bool active();
virtual bool InitAuth ();
/* Init by generating new Own PGP Cert, or selecting existing PGP Cert */
virtual int GPGInit(std::string ownId);
virtual int GPGInit(const std::string &ownId);
virtual bool CloseAuth();
virtual bool GeneratePGPCertificate(std::string name, std::string email, std::string passwd, std::string &pgpId, std::string &errString);
@ -309,23 +307,23 @@ virtual bool GeneratePGPCertificate(std::string name, std::string email, std:
* provide access to details in cache list.
*
****/
virtual std::string getGPGName(GPG_id pgp_id);
virtual std::string getGPGEmail(GPG_id pgp_id);
virtual std::string getGPGName(const std::string &pgp_id);
virtual std::string getGPGEmail(const std::string &pgp_id);
/* PGP web of trust management */
virtual std::string getGPGOwnId();
virtual std::string getGPGOwnName();
//virtual std::string getGPGOwnEmail();
virtual bool getGPGDetails(std::string id, RsPeerDetails &d);
virtual bool getGPGDetails(const std::string &id, RsPeerDetails &d);
virtual bool getGPGAllList(std::list<std::string> &ids);
virtual bool getGPGValidList(std::list<std::string> &ids);
virtual bool getGPGAcceptedList(std::list<std::string> &ids);
virtual bool getGPGSignedList(std::list<std::string> &ids);
virtual bool isGPGValid(std::string id);
virtual bool isGPGSigned(std::string id);
virtual bool isGPGAccepted(std::string id);
virtual bool isGPGId(GPG_id id);
virtual bool isGPGValid(const std::string &id);
virtual bool isGPGSigned(const std::string &id);
virtual bool isGPGAccepted(const std::string &id);
virtual bool isGPGId(const std::string &id);
/*********************************************************************************/
/************************* STAGE 4 ***********************************************/
@ -334,8 +332,8 @@ virtual bool isGPGId(GPG_id id);
* STAGE 4: Loading and Saving Certificates. (Strings and Files)
*
****/
virtual bool LoadCertificateFromString(std::string pem, std::string &gpg_id);
virtual std::string SaveCertificateToString(std::string id);
virtual bool LoadCertificateFromString(const std::string &pem, std::string &gpg_id);
virtual std::string SaveCertificateToString(const std::string &id);
/*********************************************************************************/
/************************* STAGE 6 ***********************************************/
@ -347,14 +345,14 @@ virtual std::string SaveCertificateToString(std::string id);
* done in gpgroot already.
*
****/
virtual bool setAcceptToConnectGPGCertificate(std::string gpg_id, bool acceptance); //don't act on the gpg key, use a seperate set
virtual bool SignCertificateLevel0(std::string id);
virtual bool RevokeCertificate(std::string id); /* Particularly hard - leave for later */
virtual bool setAcceptToConnectGPGCertificate(const std::string &gpg_id, bool acceptance); //don't act on the gpg key, use a seperate set
virtual bool SignCertificateLevel0(const std::string &id);
virtual bool RevokeCertificate(const std::string &id); /* Particularly hard - leave for later */
//virtual bool TrustCertificateNone(std::string id);
//virtual bool TrustCertificateMarginally(std::string id);
//virtual bool TrustCertificateFully(std::string id);
virtual bool TrustCertificate(std::string id, int trustlvl); //trustlvl is 2 for none, 3 for marginal and 4 for full trust
virtual bool TrustCertificate(const std::string &id, int trustlvl); //trustlvl is 2 for none, 3 for marginal and 4 for full trust
/*********************************************************************************/
/************************* STAGE 7 ***********************************************/
@ -398,9 +396,9 @@ virtual bool addService(AuthGPGService *service);
bool VerifySignature(const void *data, int datalen, const void *sig, unsigned int siglen, const std::string &withfingerprint);
/* Sign/Trust stuff */
int privateSignCertificate(GPG_id id);
int privateRevokeCertificate(GPG_id id); /* revoke the signature on Certificate */
int privateTrustCertificate(GPG_id id, int trustlvl);
int privateSignCertificate(const std::string &id);
int privateRevokeCertificate(const std::string &id); /* revoke the signature on Certificate */
int privateTrustCertificate(const std::string &id, int trustlvl);
// store all keys in map mKeyList to avoid calling gpgme exe repeatedly
bool storeAllKeys();

View File

@ -161,37 +161,37 @@ virtual bool getFriendList(std::list<std::string> &ssl_ids) = 0;
//virtual bool getOthersList(std::list<std::string> &ssl_ids) = 0;
virtual bool getPeerCount (unsigned int *pnFriendCount, unsigned int *pnnOnlineCount, bool ssl) = 0;
virtual bool isOnline(std::string ssl_id) = 0;
virtual bool isFriend(std::string ssl_id) = 0;
virtual bool isGPGAccepted(std::string gpg_id_is_friend) = 0; //
virtual std::string getPeerName(std::string ssl_or_gpg_id) = 0;
virtual std::string getGPGName(std::string gpg_id) = 0;
virtual bool getPeerDetails(std::string ssl_or_gpg_id, RsPeerDetails &d) = 0; //get Peer detail accept SSL and PGP certs
virtual bool isOnline(const std::string &ssl_id) = 0;
virtual bool isFriend(const std::string &ssl_id) = 0;
virtual bool isGPGAccepted(const std::string &gpg_id_is_friend) = 0; //
virtual std::string getPeerName(const std::string &ssl_or_gpg_id) = 0;
virtual std::string getGPGName(const std::string &gpg_id) = 0;
virtual bool getPeerDetails(const std::string &ssl_or_gpg_id, RsPeerDetails &d) = 0; //get Peer detail accept SSL and PGP certs
/* Using PGP Ids */
virtual std::string getGPGOwnId() = 0;
virtual std::string getGPGId(std::string sslid_or_gpgid) = 0; //return the gpg id of the given gpg or ssl id
virtual std::string getGPGId(const std::string &sslid_or_gpgid) = 0; //return the gpg id of the given gpg or ssl id
virtual bool getGPGAcceptedList(std::list<std::string> &gpg_ids) = 0;
virtual bool getGPGSignedList(std::list<std::string> &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<std::string> &gpg_ids) = 0;
virtual bool getGPGAllList(std::list<std::string> &gpg_ids) = 0;
virtual bool getGPGDetails(std::string gpg_id, RsPeerDetails &d) = 0;
virtual bool getSSLChildListOfGPGId(std::string gpg_id, std::list<std::string> &ssl_ids) = 0;
virtual bool getGPGDetails(const std::string &gpg_id, RsPeerDetails &d) = 0;
virtual bool getSSLChildListOfGPGId(const std::string &gpg_id, std::list<std::string> &ssl_ids) = 0;
/* Add/Remove Friends */
virtual bool addFriend(std::string ssl_id, std::string gpg_id) = 0;
virtual bool addDummyFriend(std::string gpg_id) = 0; //we want to add a empty ssl friend for this gpg id
virtual bool isDummyFriend(std::string ssl_id) = 0;
virtual bool removeFriend(std::string ssl_or_gpg_id) = 0;
virtual bool addFriend(const std::string &ssl_id, const std::string &gpg_id) = 0;
virtual bool addDummyFriend(const std::string &gpg_id) = 0; //we want to add a empty ssl friend for this gpg id
virtual bool isDummyFriend(const std::string &ssl_id) = 0;
virtual bool removeFriend(const std::string &ssl_or_gpg_id) = 0;
/* Network Stuff */
virtual bool connectAttempt(std::string ssl_id) = 0;
virtual bool setLocation(std::string ssl_id, std::string location) = 0;//location is shown in the gui to differentiate ssl certs
virtual bool setLocalAddress(std::string ssl_id, std::string addr, uint16_t port) = 0;
virtual bool setExtAddress( std::string ssl_id, std::string addr, uint16_t port) = 0;
virtual bool setDynDNS(std::string id, std::string addr) = 0;
virtual bool setNetworkMode(std::string ssl_id, uint32_t netMode) = 0;
virtual bool setVisState(std::string ssl_id, uint32_t vis) = 0;
virtual bool connectAttempt(const std::string &ssl_id) = 0;
virtual bool setLocation(const std::string &ssl_id, const std::string &location) = 0;//location is shown in the gui to differentiate ssl certs
virtual bool setLocalAddress(const std::string &ssl_id, const std::string &addr, uint16_t port) = 0;
virtual bool setExtAddress( const std::string &ssl_id, const std::string &addr, uint16_t port) = 0;
virtual bool setDynDNS(const std::string &id, const std::string &addr) = 0;
virtual bool setNetworkMode(const std::string &ssl_id, uint32_t netMode) = 0;
virtual bool setVisState(const std::string &ssl_id, uint32_t vis) = 0;
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;
virtual void allowServerIPDetermination(bool) = 0;
@ -203,14 +203,14 @@ virtual bool getAllowTunnelConnection() = 0 ;
virtual std::string GetRetroshareInvite(const std::string& ssl_id) = 0;
virtual std::string GetRetroshareInvite() = 0;
virtual bool loadCertificateFromFile(std::string fname, std::string &ssl_id, std::string &gpg_id) = 0;
virtual bool loadDetailsFromStringCert(std::string certGPG, RsPeerDetails &pd) = 0;
virtual bool saveCertificateToFile(std::string id, std::string fname) = 0;
virtual std::string saveCertificateToString(std::string id) = 0;
virtual bool loadCertificateFromFile(const std::string &fname, std::string &ssl_id, std::string &gpg_id) = 0;
virtual bool loadDetailsFromStringCert(const std::string &certGPG, RsPeerDetails &pd) = 0;
virtual bool saveCertificateToFile(const std::string &id, const std::string &fname) = 0;
virtual std::string saveCertificateToString(const std::string &id) = 0;
virtual bool setAcceptToConnectGPGCertificate(std::string gpg_id, bool acceptance) = 0;
virtual bool signGPGCertificate(std::string gpg_id) = 0;
virtual bool trustGPGCertificate(std::string gpg_id, uint32_t trustlvl) = 0;
virtual bool setAcceptToConnectGPGCertificate(const std::string &gpg_id, bool acceptance) = 0;
virtual bool signGPGCertificate(const std::string &gpg_id) = 0;
virtual bool trustGPGCertificate(const std::string &gpg_id, uint32_t trustlvl) = 0;
/* Group Stuff */
virtual bool addGroup(RsGroupInfo &groupInfo) = 0;

View File

@ -231,7 +231,7 @@ bool p3Peers::getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineC
return mConnMgr->getPeerCount(pnFriendCount, pnOnlineCount, ssl);
}
bool p3Peers::isOnline(std::string id)
bool p3Peers::isOnline(const std::string &id)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::isOnline() " << id << std::endl;
@ -247,7 +247,7 @@ bool p3Peers::isOnline(std::string id)
return false;
}
bool p3Peers::isFriend(std::string ssl_id)
bool p3Peers::isFriend(const std::string &ssl_id)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::isFriend() " << ssl_id << std::endl;
@ -272,7 +272,7 @@ static struct sockaddr_in getPreferredAddress( const struct sockaddr_in& addr1,t
}
#endif
bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPeerDetails() called for id : " << id << std::endl;
@ -449,19 +449,19 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
}
std::string p3Peers::getGPGName(std::string gpg_id)
std::string p3Peers::getGPGName(const std::string &gpg_id)
{
/* get from mAuthMgr as it should have more peers? */
return AuthGPG::getAuthGPG()->getGPGName(gpg_id);
}
bool p3Peers::isGPGAccepted(std::string gpg_id_is_friend)
bool p3Peers::isGPGAccepted(const std::string &gpg_id_is_friend)
{
/* get from mAuthMgr as it should have more peers? */
return AuthGPG::getAuthGPG()->isGPGAccepted(gpg_id_is_friend);
}
std::string p3Peers::getPeerName(std::string ssl_or_gpg_id)
std::string p3Peers::getPeerName(const std::string &ssl_or_gpg_id)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPeerName() " << ssl_or_gpg_id << std::endl;
@ -523,7 +523,7 @@ bool p3Peers::getGPGAcceptedList(std::list<std::string> &ids)
return true;
}
bool p3Peers::getSSLChildListOfGPGId(std::string gpg_id, std::list<std::string> &ids)
bool p3Peers::getSSLChildListOfGPGId(const std::string &gpg_id, std::list<std::string> &ids)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getSSLChildListOfGPGId() for id : " << gpg_id << std::endl;
@ -550,7 +550,7 @@ bool p3Peers::getSSLChildListOfGPGId(std::string gpg_id, std::list<std::string>
return true;
}
bool p3Peers::getGPGDetails(std::string id, RsPeerDetails &d)
bool p3Peers::getGPGDetails(const std::string &id, RsPeerDetails &d)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPgpDetails() called for id : " << id << std::endl;
@ -570,7 +570,7 @@ std::string p3Peers::getGPGOwnId()
return AuthGPG::getAuthGPG()->getGPGOwnId();
}
std::string p3Peers::getGPGId(std::string sslid_or_gpgid)
std::string p3Peers::getGPGId(const std::string &sslid_or_gpgid)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPGPId()" << std::endl;
@ -597,7 +597,7 @@ std::string p3Peers::getGPGId(std::string sslid_or_gpgid)
/* Add/Remove Friends */
bool p3Peers::addFriend(std::string id, std::string gpg_id)
bool p3Peers::addFriend(const std::string &id, const std::string &gpg_id)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::addFriend() with : id : " << id << "; gpg_id : " << gpg_id << std::endl;
@ -609,7 +609,7 @@ bool p3Peers::addFriend(std::string id, std::string gpg_id)
}
}
bool p3Peers::addDummyFriend(std::string gpg_id)
bool p3Peers::addDummyFriend(const std::string &gpg_id)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::addDummyFriend() called" << std::endl;
@ -626,7 +626,7 @@ bool p3Peers::addDummyFriend(std::string gpg_id)
}
}
bool p3Peers::isDummyFriend(std::string ssl_id) {
bool p3Peers::isDummyFriend(const std::string &ssl_id) {
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::isDummyFriend() called" << std::endl;
#endif
@ -643,7 +643,7 @@ bool p3Peers::isDummyFriend(std::string ssl_id) {
return ret;
}
bool p3Peers::removeFriend(std::string ssl_or_gpgid)
bool p3Peers::removeFriend(const std::string &ssl_or_gpgid)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::removeFriend() " << ssl_or_gpgid << std::endl;
@ -664,7 +664,7 @@ bool p3Peers::removeFriend(std::string ssl_or_gpgid)
}
/* Network Stuff */
bool p3Peers::connectAttempt(std::string id)
bool p3Peers::connectAttempt(const std::string &id)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::connectAttempt() " << id << std::endl;
@ -703,7 +703,7 @@ bool p3Peers::getAllowTunnelConnection()
return mConnMgr->getTunnelConnection() ;
}
bool p3Peers::setLocalAddress(std::string id, std::string addr_str, uint16_t port)
bool p3Peers::setLocalAddress(const std::string &id, const std::string &addr_str, uint16_t port)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setLocalAddress() " << id << std::endl;
@ -728,7 +728,7 @@ bool p3Peers::setLocalAddress(std::string id, std::string addr_str, uint16_t po
return false;
}
bool p3Peers::setLocation(std::string ssl_id, std::string location)
bool p3Peers::setLocation(const std::string &ssl_id, const std::string &location)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setLocation() " << ssl_id << std::endl;
@ -736,7 +736,7 @@ bool p3Peers::setLocation(std::string ssl_id, std::string location)
return mConnMgr->setLocation(ssl_id, location);
}
bool p3Peers::setExtAddress(std::string id, std::string addr_str, uint16_t port)
bool p3Peers::setExtAddress(const std::string &id, const std::string &addr_str, uint16_t port)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setExtAddress() " << id << std::endl;
@ -761,7 +761,7 @@ bool p3Peers::setExtAddress(std::string id, std::string addr_str, uint16_t port
return false;
}
bool p3Peers::setDynDNS(std::string id, std::string dyndns)
bool p3Peers::setDynDNS(const std::string &id, const std::string &dyndns)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setDynDNS() called with id: " << id << " dyndns: " << dyndns <<std::endl;
@ -769,7 +769,7 @@ bool p3Peers::setDynDNS(std::string id, std::string dyndns)
return mConnMgr->setDynDNS(id, dyndns);
}
bool p3Peers::setNetworkMode(std::string id, uint32_t extNetMode)
bool p3Peers::setNetworkMode(const std::string &id, uint32_t extNetMode)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setNetworkMode() " << id << std::endl;
@ -800,7 +800,7 @@ bool p3Peers::setNetworkMode(std::string id, uint32_t extNetMode)
bool
p3Peers::setVisState(std::string id, uint32_t extVisState)
p3Peers::setVisState(const std::string &id, uint32_t extVisState)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setVisState() " << id << std::endl;
@ -865,7 +865,7 @@ p3Peers::GetRetroshareInvite(const std::string& ssl_id)
//===========================================================================
bool p3Peers::loadCertificateFromFile(std::string fname, std::string &id, std::string &gpg_id)
bool p3Peers::loadCertificateFromFile(const std::string &fname, std::string &id, std::string &gpg_id)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::LoadCertificateFromFile() not implemented yet";
@ -920,7 +920,7 @@ bool p3Peers::loadCertificateFromFile(std::string fname, std::string &id, std::
bool p3Peers::loadDetailsFromStringCert(std::string certstr, RsPeerDetails &pd)
bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetails &pd)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::LoadCertificateFromString() ";
@ -1060,7 +1060,7 @@ bool p3Peers::loadDetailsFromStringCert(std::string certstr, RsPeerDetails &pd)
bool p3Peers::saveCertificateToFile(std::string id, std::string fname)
bool p3Peers::saveCertificateToFile(const std::string &id, const std::string &fname)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::SaveCertificateToFile() not implemented yet " << id;
@ -1073,7 +1073,7 @@ bool p3Peers::saveCertificateToFile(std::string id, std::string fname)
return false;
}
std::string p3Peers::saveCertificateToString(std::string id)
std::string p3Peers::saveCertificateToString(const std::string &id)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::SaveCertificateToString() " << id;
@ -1086,7 +1086,7 @@ std::string p3Peers::saveCertificateToString(std::string id)
}
}
bool p3Peers::signGPGCertificate(std::string id)
bool p3Peers::signGPGCertificate(const std::string &id)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::SignCertificate() " << id;
@ -1098,7 +1098,7 @@ bool p3Peers::signGPGCertificate(std::string id)
return AuthGPG::getAuthGPG()->SignCertificateLevel0(id);
}
bool p3Peers::setAcceptToConnectGPGCertificate(std::string gpg_id, bool acceptance)
bool p3Peers::setAcceptToConnectGPGCertificate(const std::string &gpg_id, bool acceptance)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setAcceptToConnectGPGCertificate() called with gpg_id : " << gpg_id << ", acceptance : " << acceptance << std::endl;
@ -1116,7 +1116,7 @@ bool p3Peers::setAcceptToConnectGPGCertificate(std::string gpg_id, bool accepta
return AuthGPG::getAuthGPG()->setAcceptToConnectGPGCertificate(gpg_id, acceptance);
}
bool p3Peers::trustGPGCertificate(std::string id, uint32_t trustlvl)
bool p3Peers::trustGPGCertificate(const std::string &id, uint32_t trustlvl)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::TrustCertificate() " << id;

View File

@ -48,37 +48,37 @@ virtual bool getFriendList(std::list<std::string> &ids);
//virtual bool getOthersList(std::list<std::string> &ids);
virtual bool getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount, bool ssl);
virtual bool isOnline(std::string id);
virtual bool isFriend(std::string id);
virtual bool isGPGAccepted(std::string gpg_id_is_friend); //
virtual std::string getGPGName(std::string gpg_id);
virtual std::string getPeerName(std::string ssl_or_gpg_id);
virtual bool getPeerDetails(std::string id, RsPeerDetails &d);
virtual bool isOnline(const std::string &id);
virtual bool isFriend(const std::string &id);
virtual bool isGPGAccepted(const std::string &gpg_id_is_friend); //
virtual std::string getGPGName(const std::string &gpg_id);
virtual std::string getPeerName(const std::string &ssl_or_gpg_id);
virtual bool getPeerDetails(const std::string &id, RsPeerDetails &d);
/* Using PGP Ids */
virtual std::string getGPGOwnId();
virtual std::string getGPGId(std::string ssl_id);
virtual std::string getGPGId(const std::string &ssl_id);
virtual bool getGPGAcceptedList(std::list<std::string> &ids);
virtual bool getGPGSignedList(std::list<std::string> &ids);
virtual bool getGPGValidList(std::list<std::string> &ids);
virtual bool getGPGAllList(std::list<std::string> &ids);
virtual bool getGPGDetails(std::string id, RsPeerDetails &d);
virtual bool getSSLChildListOfGPGId(std::string gpg_id, std::list<std::string> &ids);
virtual bool getGPGDetails(const std::string &id, RsPeerDetails &d);
virtual bool getSSLChildListOfGPGId(const std::string &gpg_id, std::list<std::string> &ids);
/* Add/Remove Friends */
virtual bool addFriend(std::string ssl_id, std::string gpg_id);
virtual bool addDummyFriend(std::string gpg_id); //we want to add a empty ssl friend for this gpg id
virtual bool isDummyFriend(std::string ssl_id);
virtual bool removeFriend(std::string ssl_id);
virtual bool addFriend(const std::string &ssl_id, const std::string &gpg_id);
virtual bool addDummyFriend(const std::string &gpg_id); //we want to add a empty ssl friend for this gpg id
virtual bool isDummyFriend(const std::string &ssl_id);
virtual bool removeFriend(const std::string &ssl_id);
/* Network Stuff */
virtual bool connectAttempt(std::string id);
virtual bool setLocation(std::string ssl_id, std::string location);//location is shown in the gui to differentiate ssl certs
virtual bool setLocalAddress(std::string id, std::string addr, uint16_t port);
virtual bool setExtAddress(std::string id, std::string addr, uint16_t port);
virtual bool setDynDNS(std::string id, std::string dyndns);
virtual bool setNetworkMode(std::string id, uint32_t netMode);
virtual bool setVisState(std::string id, uint32_t mode);
virtual bool connectAttempt(const std::string &id);
virtual bool setLocation(const std::string &ssl_id, const std::string &location);//location is shown in the gui to differentiate ssl certs
virtual bool setLocalAddress(const std::string &id, const std::string &addr, uint16_t port);
virtual bool setExtAddress(const std::string &id, const std::string &addr, uint16_t port);
virtual bool setDynDNS(const std::string &id, const std::string &dyndns);
virtual bool setNetworkMode(const std::string &id, uint32_t netMode);
virtual bool setVisState(const std::string &id, uint32_t mode);
virtual void getIPServersList(std::list<std::string>& ip_servers) ;
virtual void allowServerIPDetermination(bool) ;
@ -92,14 +92,14 @@ virtual std::string GetRetroshareInvite(const std::string& ssl_id);
// same but for own id
virtual std::string GetRetroshareInvite();
virtual bool loadCertificateFromFile(std::string fname, std::string &id, std::string &gpg_id);
virtual bool loadDetailsFromStringCert(std::string cert, RsPeerDetails &pd);
virtual bool saveCertificateToFile(std::string id, std::string fname);
virtual std::string saveCertificateToString(std::string id);
virtual bool loadCertificateFromFile(const std::string &fname, std::string &id, std::string &gpg_id);
virtual bool loadDetailsFromStringCert(const std::string &cert, RsPeerDetails &pd);
virtual bool saveCertificateToFile(const std::string &id, const std::string &fname);
virtual std::string saveCertificateToString(const std::string &id);
virtual bool setAcceptToConnectGPGCertificate(std::string gpg_id, bool acceptance);
virtual bool signGPGCertificate(std::string id);
virtual bool trustGPGCertificate(std::string id, uint32_t trustlvl);
virtual bool setAcceptToConnectGPGCertificate(const std::string &gpg_id, bool acceptance);
virtual bool signGPGCertificate(const std::string &id);
virtual bool trustGPGCertificate(const std::string &id, uint32_t trustlvl);
/* Group Stuff */
virtual bool addGroup(RsGroupInfo &groupInfo);

View File

@ -377,15 +377,6 @@ RsDiscReply *p3disc::createDiscReply(const std::string &to, const std::string &a
return NULL;
}
peerConnectState detailAbout;
if (mConnMgr->getFriendNetStatus(aboutGpgId, detailAbout) && detailAbout.visState & RS_VIS_STATE_NODISC)
{
#ifdef P3DISC_DEBUG
std::cerr << "p3disc::createDiscReply() don't send info about this peer because he has no disc enabled." << std::endl;
#endif
return NULL;
}
// Construct a message
RsDiscReply *di = new RsDiscReply();
@ -406,8 +397,9 @@ RsDiscReply *p3disc::createDiscReply(const std::string &to, const std::string &a
std::cerr << "p3disc::createDiscReply() Found Child SSL Id:" << *sslChildIt;
std::cerr << std::endl;
#endif
if(to != *sslChildIt) // We don't send info to a peer about itself, but we allow sending info
{ // about peers with the same GPG id.
if(sslChilds.size() == 1 || to != *sslChildIt) // We don't send info to a peer about itself, when there are more than one ssl children,
{ // but we allow sending info about peers with the same GPG id. When there is only one ssl child,
// we must send it to transfer the signers of the gpg key. The receiver is skipping the own id.
peerConnectState detail;
if (!mConnMgr->getFriendNetStatus(*sslChildIt, detail)
|| detail.visState & RS_VIS_STATE_NODISC)