mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-07 13:52:43 -04:00
implement dummy friend for a gpg key, improve PersDialog ui
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2018 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
9976b80566
commit
e50dc4e3b9
9 changed files with 212 additions and 83 deletions
|
@ -1031,6 +1031,19 @@ bool AuthGPG::isGPGValid(GPG_id id)
|
|||
|
||||
}
|
||||
|
||||
bool AuthGPG::isGPGId(GPG_id id)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
storeAllKeys_locked();
|
||||
certmap::iterator it;
|
||||
if (mKeyList.end() != (it = mKeyList.find(id))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool AuthGPG::isGPGSigned(GPG_id id)
|
||||
{
|
||||
|
@ -1657,8 +1670,8 @@ static gpg_error_t keySignCallback(void *opaque, gpgme_status_code_t status, \
|
|||
else if (status == GPGME_STATUS_ALREADY_SIGNED)
|
||||
{
|
||||
/* The key has already been signed with this key */
|
||||
params->state = SIGN_ERROR;
|
||||
params->err = gpg_error (GPG_ERR_CONFLICT);
|
||||
params->state = SIGN_QUIT;
|
||||
result = "quit";
|
||||
}
|
||||
else if (status == GPGME_STATUS_GET_LINE &&
|
||||
(!std::string("keyedit.prompt").compare(args)))
|
||||
|
|
|
@ -164,6 +164,7 @@ class AuthGPG
|
|||
bool isGPGValid(std::string id);
|
||||
bool isGPGSigned(std::string id);
|
||||
bool isGPGAccepted(std::string id);
|
||||
bool isGPGId(GPG_id id);
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 4 ***********************************************/
|
||||
|
|
|
@ -1355,8 +1355,15 @@ bool p3ConnectMgr::getOwnNetStatus(peerConnectState &state)
|
|||
|
||||
bool p3ConnectMgr::isFriend(std::string id)
|
||||
{
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
return (mFriendList.end() != mFriendList.find(id));
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::isFriend(" << id << ") called" << std::endl;
|
||||
#endif
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
bool ret = (mFriendList.end() != mFriendList.find(id));
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::isFriend(" << id << ") returning : " << ret << std::endl;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool p3ConnectMgr::isOnline(std::string id)
|
||||
|
@ -1990,7 +1997,7 @@ void p3ConnectMgr::peerConnectRequest(std::string id, struct sockaddr_in radd
|
|||
|
||||
bool p3ConnectMgr::addFriend(std::string id, std::string gpg_id, uint32_t netMode, uint32_t visState, time_t lastContact)
|
||||
{
|
||||
/* so three possibilities
|
||||
/* so four possibilities
|
||||
* (1) already exists as friend -> do nothing.
|
||||
* (2) is in others list -> move over.
|
||||
* (3) is non-existant -> create new one.
|
||||
|
@ -2000,6 +2007,12 @@ bool p3ConnectMgr::addFriend(std::string id, std::string gpg_id, uint32_t netMod
|
|||
std::cerr << "p3ConnectMgr::addFriend() " << id << "; gpg_id : " << gpg_id << std::endl;
|
||||
#endif
|
||||
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::addFriend() removing dummy friend" << std::endl;
|
||||
#endif
|
||||
//remove any dummy friend because we just add a real ssl friend
|
||||
removeFriend("dummy"+ gpg_id);
|
||||
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
|
||||
|
@ -2101,7 +2114,8 @@ bool p3ConnectMgr::removeFriend(std::string id)
|
|||
{
|
||||
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::removeFriend() " << id << std::endl;
|
||||
std::cerr << "p3ConnectMgr::removeFriend() for id : " << id << std::endl;
|
||||
std::cerr << "p3ConnectMgr::removeFriend() mFriendList.size() : " << mFriendList.size() << std::endl;
|
||||
#endif
|
||||
|
||||
netAssistFriend(id, false);
|
||||
|
@ -2114,7 +2128,10 @@ bool p3ConnectMgr::removeFriend(std::string id)
|
|||
if (mFriendList.end() != (it = mFriendList.find(id)))
|
||||
{
|
||||
|
||||
peerConnectState peer = it->second;
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::removeFriend() friend found in the list." << id << std::endl;
|
||||
#endif
|
||||
peerConnectState peer = it->second;
|
||||
|
||||
mFriendList.erase(it);
|
||||
|
||||
|
@ -2123,13 +2140,16 @@ bool p3ConnectMgr::removeFriend(std::string id)
|
|||
peer.state &= (~RS_PEER_S_ONLINE);
|
||||
peer.actions = RS_PEER_MOVED;
|
||||
peer.inConnAttempt = false;
|
||||
mOthersList[id] = peer;
|
||||
//mOthersList[id] = peer;
|
||||
mStatusChanged = true;
|
||||
|
||||
success = true;
|
||||
}
|
||||
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::removeFriend() new mFriendList.size() : " << mFriendList.size() << std::endl;
|
||||
#endif
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ virtual bool getPeerDetails(std::string ssl_or_gpg_id, RsPeerDetails &d) = 0; //
|
|||
|
||||
/* Using PGP Ids */
|
||||
virtual std::string getGPGOwnId() = 0;
|
||||
virtual std::string getGPGId(std::string ssl_id) = 0;
|
||||
virtual std::string getGPGId(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;
|
||||
|
|
|
@ -243,21 +243,15 @@ bool p3Peers::isOnline(std::string id)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool p3Peers::isFriend(std::string id)
|
||||
bool p3Peers::isFriend(std::string ssl_id)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::isFriend() " << id;
|
||||
std::cerr << "p3Peers::isFriend() " << ssl_id;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* get from mConnectMgr */
|
||||
peerConnectState state;
|
||||
if (mConnMgr->getFriendNetStatus(id, state) &&
|
||||
(state.state & RS_PEER_S_FRIEND))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
/* get from mConnectMgr */
|
||||
return mConnMgr->isFriend(ssl_id);
|
||||
}
|
||||
|
||||
static struct sockaddr_in getPreferredAddress( const struct sockaddr_in& addr1,time_t ts1,
|
||||
|
@ -562,7 +556,7 @@ std::string p3Peers::getGPGOwnId()
|
|||
return AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
}
|
||||
|
||||
std::string p3Peers::getGPGId(std::string ssl_id)
|
||||
std::string p3Peers::getGPGId(std::string sslid_or_gpgid)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::getPGPId()";
|
||||
|
@ -570,15 +564,22 @@ std::string p3Peers::getGPGId(std::string ssl_id)
|
|||
#endif
|
||||
|
||||
/* get from mAuthMgr */
|
||||
if (ssl_id == AuthSSL::getAuthSSL()->OwnId()) {
|
||||
if (sslid_or_gpgid == AuthSSL::getAuthSSL()->OwnId()) {
|
||||
return AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
}
|
||||
peerConnectState pcs;
|
||||
if (mConnMgr->getFriendNetStatus(ssl_id, pcs)) {
|
||||
if (mConnMgr->getFriendNetStatus(sslid_or_gpgid, pcs)) {
|
||||
return pcs.gpg_id;
|
||||
} else {
|
||||
return "";
|
||||
if ( AuthGPG::getAuthGPG()->isGPGValid(sslid_or_gpgid)) {
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::getPGPId() given id is already an gpg id : " << sslid_or_gpgid;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return sslid_or_gpgid;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
@ -599,10 +600,18 @@ bool p3Peers::addFriend(std::string id, std::string gpg_id)
|
|||
bool p3Peers::addDummyFriend(std::string gpg_id)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::addDummyFriend() not implemented yet" << std::endl;
|
||||
std::cerr << "p3Peers::addDummyFriend() called" << std::endl;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
std::string dummy_ssl_id = "dummy"+ gpg_id;
|
||||
//check if this gpg_id already got a dummy friend
|
||||
if (!mConnMgr->isFriend(dummy_ssl_id)) {
|
||||
return mConnMgr->addFriend(dummy_ssl_id, gpg_id);
|
||||
} else {
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::addDummyFriend() dummy friend already exists for gpg_id : " << gpg_id << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool p3Peers::removeFriend(std::string id)
|
||||
|
@ -934,12 +943,9 @@ bool p3Peers::signGPGCertificate(std::string id)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (AuthGPG::getAuthGPG()->SignCertificateLevel0(id)) {
|
||||
//by default, set the GPG to accept connection
|
||||
AuthGPG::getAuthGPG()->setAcceptToConnectGPGCertificate(id, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
AuthGPG::getAuthGPG()->SignCertificateLevel0(id);
|
||||
AuthGPG::getAuthGPG()->setAcceptToConnectGPGCertificate(id, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3Peers::setAcceptToConnectGPGCertificate(std::string gpg_id, bool acceptance)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue