mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-18 11:29:31 -04:00
get rid of p3authmgr
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2001 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
2917896834
commit
c23407cae3
46 changed files with 254 additions and 874 deletions
|
@ -318,10 +318,10 @@ int GPGAuthMgr::GPGInit(std::string ownId)
|
|||
return 0;
|
||||
}
|
||||
|
||||
mOwnGpgCert.user.name = newKey->uids->name;
|
||||
mOwnGpgCert.user.email = newKey->uids->email;
|
||||
mOwnGpgCert.user.fpr = newKey->subkeys->fpr;
|
||||
mOwnGpgCert.user.id = ownId;
|
||||
mOwnGpgCert.name = newKey->uids->name;
|
||||
mOwnGpgCert.email = newKey->uids->email;
|
||||
mOwnGpgCert.fpr = newKey->subkeys->fpr;
|
||||
mOwnGpgCert.id = ownId;
|
||||
mOwnGpgCert.key = newKey;
|
||||
|
||||
mOwnId = ownId;
|
||||
|
@ -362,16 +362,16 @@ int GPGAuthMgr::GPGInit(std::string name, std::string comment,
|
|||
return 0;
|
||||
}
|
||||
|
||||
mOwnGpgCert.user.name = name;
|
||||
mOwnGpgCert.user.email = email;
|
||||
mOwnGpgCert.user.fpr = newKey->subkeys->fpr;
|
||||
mOwnGpgCert.user.id = newKey->subkeys->keyid;
|
||||
mOwnGpgCert.name = name;
|
||||
mOwnGpgCert.email = email;
|
||||
mOwnGpgCert.fpr = newKey->subkeys->fpr;
|
||||
mOwnGpgCert.id = newKey->subkeys->keyid;
|
||||
mOwnGpgCert.key = newKey;
|
||||
|
||||
this->passphrase = inPassphrase;
|
||||
setPGPPassword_locked(inPassphrase);
|
||||
|
||||
mOwnId = mOwnGpgCert.user.id;
|
||||
mOwnId = mOwnGpgCert.id;
|
||||
gpgmeKeySelected = true;
|
||||
|
||||
return 1;
|
||||
|
@ -454,11 +454,11 @@ bool GPGAuthMgr::storeAllKeys_locked()
|
|||
* Don't really need to worry about other ids either.
|
||||
*/
|
||||
gpgme_subkey_t mainsubkey = KEY->subkeys;
|
||||
nu.user.id = mainsubkey->keyid;
|
||||
nu.user.fpr = mainsubkey->fpr;
|
||||
nu.id = mainsubkey->keyid;
|
||||
nu.fpr = mainsubkey->fpr;
|
||||
|
||||
std::cerr << "MAIN KEYID: " << nu.user.id;
|
||||
std::cerr << " FPR: " << nu.user.fpr;
|
||||
std::cerr << "MAIN KEYID: " << nu.id;
|
||||
std::cerr << " FPR: " << nu.fpr;
|
||||
std::cerr << std::endl;
|
||||
|
||||
|
||||
|
@ -478,8 +478,8 @@ bool GPGAuthMgr::storeAllKeys_locked()
|
|||
*/
|
||||
|
||||
gpgme_user_id_t mainuid = KEY->uids;
|
||||
nu.user.name = mainuid->name;
|
||||
nu.user.email = mainuid->email;
|
||||
nu.name = mainuid->name;
|
||||
nu.email = mainuid->email;
|
||||
gpgme_key_sig_t mainsiglist = mainuid->signatures;
|
||||
while(mainsiglist != NULL)
|
||||
{
|
||||
|
@ -491,11 +491,11 @@ bool GPGAuthMgr::storeAllKeys_locked()
|
|||
*/
|
||||
|
||||
std::string keyid = mainsiglist->keyid;
|
||||
if (nu.user.signers.end() == std::find(
|
||||
nu.user.signers.begin(),
|
||||
nu.user.signers.end(),keyid))
|
||||
if (nu.signers.end() == std::find(
|
||||
nu.signers.begin(),
|
||||
nu.signers.end(),keyid))
|
||||
{
|
||||
nu.user.signers.push_back(keyid);
|
||||
nu.signers.push_back(keyid);
|
||||
}
|
||||
}
|
||||
mainsiglist = mainsiglist->next;
|
||||
|
@ -530,17 +530,17 @@ bool GPGAuthMgr::storeAllKeys_locked()
|
|||
* signature notation supplied is GPGME_KEYLIST_MODE_SIG_NOTATION is on
|
||||
*/
|
||||
|
||||
nu.user.trustLvl = KEY->owner_trust;
|
||||
nu.user.ownsign = KEY->can_sign;
|
||||
nu.user.validLvl = mainuid->validity;
|
||||
nu.user.trusted = (mainuid->validity > GPGME_VALIDITY_MARGINAL);
|
||||
nu.trustLvl = KEY->owner_trust;
|
||||
nu.ownsign = KEY->can_sign;
|
||||
nu.validLvl = mainuid->validity;
|
||||
nu.trusted = (mainuid->validity > GPGME_VALIDITY_MARGINAL);
|
||||
|
||||
/* grab a reference, so the key remains */
|
||||
gpgme_key_ref(KEY);
|
||||
nu.key = KEY;
|
||||
|
||||
/* store in map */
|
||||
mKeyList[nu.user.id] = nu;
|
||||
mKeyList[nu.id] = nu;
|
||||
}
|
||||
|
||||
if (GPG_ERR_NO_ERROR != gpgme_op_keylist_end(CTX))
|
||||
|
@ -575,7 +575,7 @@ bool GPGAuthMgr::updateTrustAllKeys_locked()
|
|||
for(it = mKeyList.begin(); it != mKeyList.end(); it++)
|
||||
{
|
||||
/* check for trust items associated with key */
|
||||
std::string peerid = it->second.user.email;
|
||||
std::string peerid = it->second.email;
|
||||
std::cerr << "Searching GPGme for TrustInfo on: " << peerid;
|
||||
std::cerr << std::endl;
|
||||
|
||||
|
@ -634,26 +634,26 @@ bool GPGAuthMgr::printAllKeys_locked()
|
|||
certmap::const_iterator it;
|
||||
for(it = mKeyList.begin(); it != mKeyList.end(); it++)
|
||||
{
|
||||
std::cerr << "PGP Key: " << it->second.user.id;
|
||||
std::cerr << "PGP Key: " << it->second.id;
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::cerr << "\tName: " << it->second.user.name;
|
||||
std::cerr << "\tName: " << it->second.name;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "\tEmail: " << it->second.user.email;
|
||||
std::cerr << "\tEmail: " << it->second.email;
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::cerr << "\ttrustLvl: " << it->second.user.trustLvl;
|
||||
std::cerr << "\ttrustLvl: " << it->second.trustLvl;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "\townsign?: " << it->second.user.ownsign;
|
||||
std::cerr << "\townsign?: " << it->second.ownsign;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "\ttrusted/valid: " << it->second.user.trusted;
|
||||
std::cerr << "\ttrusted/valid: " << it->second.trusted;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "\tEmail: " << it->second.user.email;
|
||||
std::cerr << "\tEmail: " << it->second.email;
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::list<std::string>::const_iterator sit;
|
||||
for(sit = it->second.user.signers.begin();
|
||||
sit != it->second.user.signers.end(); sit++)
|
||||
for(sit = it->second.signers.begin();
|
||||
sit != it->second.signers.end(); sit++)
|
||||
{
|
||||
std::cerr << "\t\tSigner ID:" << *sit;
|
||||
|
||||
|
@ -663,7 +663,7 @@ bool GPGAuthMgr::printAllKeys_locked()
|
|||
certmap::const_iterator kit = mKeyList.find(*sit);
|
||||
if (kit != mKeyList.end())
|
||||
{
|
||||
std::cerr << " Name:" << kit->second.user.name;
|
||||
std::cerr << " Name:" << kit->second.name;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -677,14 +677,14 @@ bool GPGAuthMgr::printOwnKeys_locked()
|
|||
certmap::iterator it;
|
||||
for(it = mKeyList.begin(); it != mKeyList.end(); it++)
|
||||
{
|
||||
if (it->second.user.ownsign)
|
||||
if (it->second.ownsign)
|
||||
{
|
||||
std::cerr << "Own PGP Key: " << it->second.user.id;
|
||||
std::cerr << "Own PGP Key: " << it->second.id;
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::cerr << "\tName: " << it->second.user.name;
|
||||
std::cerr << "\tName: " << it->second.name;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "\tEmail: " << it->second.user.email;
|
||||
std::cerr << "\tEmail: " << it->second.email;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -943,30 +943,22 @@ std::string GPGAuthMgr::getPGPName(GPG_id id)
|
|||
|
||||
certmap::iterator it;
|
||||
if (mKeyList.end() != (it = mKeyList.find(id)))
|
||||
return it->second.user.name;
|
||||
return it->second.name;
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
bool GPGAuthMgr::getDetails(GPG_id id, pqiAuthDetails &details)
|
||||
/**** These Two are common */
|
||||
std::string GPGAuthMgr::getPGPEmail(GPG_id id)
|
||||
{
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
if(pgpMtx.trylock())
|
||||
{
|
||||
/* if we cannot find a ssl cert - might be a pgp cert */
|
||||
certmap::iterator it;
|
||||
if (mKeyList.end() != (it = mKeyList.find(id)))
|
||||
{
|
||||
/* what do we want from the gpg mgr */
|
||||
details = it->second.user;
|
||||
pgpMtx.unlock() ;
|
||||
return true;
|
||||
}
|
||||
pgpMtx.unlock() ;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
certmap::iterator it;
|
||||
if (mKeyList.end() != (it = mKeyList.find(id)))
|
||||
return it->second.email;
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
/**** GPG versions ***/
|
||||
|
||||
|
@ -1030,7 +1022,7 @@ bool GPGAuthMgr::getPGPAuthenticatedList(std::list<std::string> &ids)
|
|||
certmap::iterator it;
|
||||
for(it = mKeyList.begin(); it != mKeyList.end(); it++)
|
||||
{
|
||||
if (it->second.user.trusted)
|
||||
if (it->second.trusted)
|
||||
{
|
||||
ids.push_back(it->first);
|
||||
}
|
||||
|
@ -1045,7 +1037,7 @@ bool GPGAuthMgr::getPGPUnknownList(std::list<std::string> &ids)
|
|||
certmap::iterator it;
|
||||
for(it = mKeyList.begin(); it != mKeyList.end(); it++)
|
||||
{
|
||||
if (!(it->second.user.trusted))
|
||||
if (!(it->second.trusted))
|
||||
{
|
||||
ids.push_back(it->first);
|
||||
}
|
||||
|
@ -1074,7 +1066,7 @@ bool GPGAuthMgr::isPGPAuthenticated(GPG_id id)
|
|||
* which is the 'trusted' flag.
|
||||
*/
|
||||
|
||||
return (it->second.user.trusted);
|
||||
return (it->second.trusted);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -31,13 +31,17 @@
|
|||
#define RS_GPG_AUTH_HEADER
|
||||
|
||||
#include <gpgme.h>
|
||||
#include "pqi/p3authmgr.h"
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/evp.h>
|
||||
#include "util/rsthreads.h"
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
#define GPG_id std::string
|
||||
|
||||
class AuthGPG;
|
||||
|
||||
/* gpgcert is the identifier for a person.
|
||||
* It is a wrapper class for a GPGme OpenPGP certificate.
|
||||
*/
|
||||
|
@ -47,7 +51,23 @@ class gpgcert
|
|||
gpgcert();
|
||||
~gpgcert();
|
||||
|
||||
pqiAuthDetails user;
|
||||
std::string id;
|
||||
std::string name;
|
||||
std::string email;
|
||||
// std::string location;
|
||||
// std::string org;
|
||||
//
|
||||
// std::string issuer;
|
||||
|
||||
std::string fpr; /* fingerprint */
|
||||
std::list<std::string> signers;
|
||||
|
||||
uint32_t trustLvl;
|
||||
uint32_t validLvl;
|
||||
|
||||
bool ownsign;
|
||||
bool trusted; // means valid in pgp world.
|
||||
|
||||
gpgme_key_t key;
|
||||
};
|
||||
|
||||
|
@ -136,7 +156,7 @@ class GPGAuthMgr
|
|||
/* get Details from the Certificates */
|
||||
bool isAuthenticated(std::string id);
|
||||
std::string getPGPName(GPG_id pgp_id);
|
||||
bool getDetails(std::string id, pqiAuthDetails &details);
|
||||
std::string getPGPEmail(GPG_id pgp_id);
|
||||
|
||||
|
||||
/* PGP versions of Certificate Fns */
|
||||
|
@ -146,7 +166,6 @@ class GPGAuthMgr
|
|||
bool getPGPUnknownList(std::list<std::string> &ids);
|
||||
bool isPGPValid(std::string id);
|
||||
bool isPGPAuthenticated(std::string id);
|
||||
bool getPGPDetails(std::string id, pqiAuthDetails &details);
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 4 ***********************************************/
|
||||
|
|
|
@ -790,43 +790,29 @@ GPG_id AuthSSL::getGPGId(SSL_id id) {
|
|||
return getIssuerName(id);
|
||||
}
|
||||
|
||||
bool AuthSSL::getDetails(std::string id, pqiAuthDetails &details)
|
||||
bool AuthSSL::getCertDetails(SSL_id id, sslcert &cert)
|
||||
{
|
||||
#ifdef AUTHSSL_DEBUG
|
||||
std::cerr << "AuthSSL::getDetails() \"" << id << "\"";
|
||||
std::cerr << "AuthSSL::getCertDetails() \"" << id << "\"";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
sslMtx.lock(); /***** LOCK *****/
|
||||
|
||||
bool valid = false;
|
||||
sslcert *cert = NULL;
|
||||
sslcert *tcert = NULL;
|
||||
if (id == mOwnId)
|
||||
{
|
||||
cert = mOwnCert;
|
||||
cert = *mOwnCert;
|
||||
valid = true;
|
||||
}
|
||||
else if (locked_FindCert(id, &cert))
|
||||
else if (locked_FindCert(id, &tcert))
|
||||
{
|
||||
valid = true;
|
||||
}
|
||||
|
||||
if (valid)
|
||||
{
|
||||
/* fill details */
|
||||
details.id = cert->id;
|
||||
details.name = cert->name;
|
||||
details.email = cert->email;
|
||||
details.location= cert->location;
|
||||
details.org = cert->org;
|
||||
details.issuer = cert->issuer;
|
||||
|
||||
details.fpr = cert->fpr;
|
||||
details.signers = cert->signers;
|
||||
|
||||
//details.trustLvl= cert->trustLvl;
|
||||
//details.ownsign = cert->ownsign;
|
||||
//details.trusted = cert->trusted;
|
||||
details.trusted = cert->authed;
|
||||
cert = *tcert;
|
||||
}
|
||||
|
||||
sslMtx.unlock(); /**** UNLOCK ****/
|
||||
|
@ -2145,8 +2131,7 @@ int pem_passwd_cb(char *buf, int size, int rwflag, void *password)
|
|||
|
||||
static int verify_x509_callback(int preverify_ok, X509_STORE_CTX *ctx)
|
||||
{
|
||||
AuthSSL *authssl = (AuthSSL *) getAuthMgr();
|
||||
return authssl->VerifyX509Callback(preverify_ok, ctx);
|
||||
return getAuthSSL()->VerifyX509Callback(preverify_ok, ctx);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2258,7 +2243,7 @@ int LoadCheckX509andGetName(const char *cert_file, std::string &userName, std::s
|
|||
bool valid = false;
|
||||
if (x509)
|
||||
{
|
||||
valid = ((AuthSSL *) getAuthMgr())->ValidateCertificate(x509, userId);
|
||||
valid = getAuthSSL()->ValidateCertificate(x509, userId);
|
||||
}
|
||||
|
||||
if (valid)
|
||||
|
@ -2311,7 +2296,7 @@ int LoadCheckX509andGetIssuerName(const char *cert_file, std::string &issuerName
|
|||
bool valid = false;
|
||||
if (x509)
|
||||
{
|
||||
valid = ((AuthSSL *) getAuthMgr())->ValidateCertificate(x509, userId);
|
||||
valid = getAuthSSL()->ValidateCertificate(x509, userId);
|
||||
}
|
||||
|
||||
if (valid)
|
||||
|
|
|
@ -54,7 +54,6 @@
|
|||
|
||||
#include "pqi/pqi_base.h"
|
||||
#include "pqi/pqinetwork.h"
|
||||
#include "pqi/p3authmgr.h"
|
||||
|
||||
typedef std::string SSL_id;
|
||||
|
||||
|
@ -64,6 +63,7 @@ class sslcert
|
|||
{
|
||||
public:
|
||||
sslcert(X509 *x509, std::string id);
|
||||
sslcert();
|
||||
|
||||
/* certificate parameters */
|
||||
std::string id;
|
||||
|
@ -85,7 +85,7 @@ class sslcert
|
|||
};
|
||||
|
||||
|
||||
class AuthSSL: public p3AuthMgr
|
||||
class AuthSSL
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -116,7 +116,7 @@ virtual bool isAuthenticated(std::string id);
|
|||
virtual std::string getName(std::string id);
|
||||
virtual std::string getIssuerName(std::string id);
|
||||
virtual GPG_id getGPGId(SSL_id id);
|
||||
virtual bool getDetails(std::string id, pqiAuthDetails &details);
|
||||
virtual bool getCertDetails(std::string id, sslcert &cert);
|
||||
|
||||
/* first party trust info (dummy) */
|
||||
virtual bool isTrustingMe(std::string id) ;
|
||||
|
|
|
@ -1,302 +0,0 @@
|
|||
/*
|
||||
* libretroshare/src/pqi: p3authmgr.cc
|
||||
*
|
||||
* 3P/PQI network interface for RetroShare.
|
||||
*
|
||||
* Copyright 2007-2008 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <iostream>
|
||||
#include "pqi/p3authmgr.h"
|
||||
|
||||
pqiAuthDetails::pqiAuthDetails()
|
||||
:trustLvl(0), validLvl(0), ownsign(false), trusted(false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
p3DummyAuthMgr::p3DummyAuthMgr()
|
||||
{
|
||||
/* for the truely dummy option */
|
||||
mOwnId = "OWNID";
|
||||
|
||||
pqiAuthDetails ownDetails;
|
||||
ownDetails.id = mOwnId;
|
||||
ownDetails.name = "Youself";
|
||||
ownDetails.email = "me@me.com";
|
||||
ownDetails.location = "here";
|
||||
ownDetails.org = "me.com";
|
||||
|
||||
ownDetails.trustLvl = 6;
|
||||
ownDetails.ownsign = true;
|
||||
ownDetails.trusted = true;
|
||||
|
||||
/* ignoring fpr and signers */
|
||||
|
||||
mPeerList[mOwnId] = ownDetails;
|
||||
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::isTrustingMe(std::string id)
|
||||
{
|
||||
std::cerr << "isTrustingMe is not implemented in p3DummyAuthMgr. Look into authxpgp.cc." << std::endl ;
|
||||
return false ;
|
||||
}
|
||||
void p3DummyAuthMgr::addTrustingPeer(std::string id)
|
||||
{
|
||||
std::cerr << "addTrustingPeer is not implemented in p3DummyAuthMgr. Look into authxpgp.cc." << std::endl ;
|
||||
}
|
||||
|
||||
p3DummyAuthMgr::p3DummyAuthMgr(std::string ownId, std::list<pqiAuthDetails> peers)
|
||||
{
|
||||
mOwnId = ownId;
|
||||
bool addedOwn = false;
|
||||
|
||||
std::list<pqiAuthDetails>::iterator it;
|
||||
for(it = peers.begin(); it != peers.end(); it++)
|
||||
{
|
||||
mPeerList[it->id] = (*it);
|
||||
if (it->id == ownId)
|
||||
{
|
||||
addedOwn = true;
|
||||
}
|
||||
}
|
||||
if (!addedOwn)
|
||||
{
|
||||
pqiAuthDetails ownDetails;
|
||||
ownDetails.id = mOwnId;
|
||||
ownDetails.name = "Youself";
|
||||
ownDetails.email = "me@me.com";
|
||||
ownDetails.location = "here";
|
||||
ownDetails.org = "me.com";
|
||||
|
||||
ownDetails.trustLvl = 6;
|
||||
ownDetails.ownsign = true;
|
||||
ownDetails.trusted = true;
|
||||
|
||||
/* ignoring fpr and signers */
|
||||
|
||||
mPeerList[mOwnId] = ownDetails;
|
||||
}
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr:: active()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int p3DummyAuthMgr::InitAuth(const char *srvr_cert, const char *priv_key,
|
||||
const char *passwd)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::CloseAuth()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int p3DummyAuthMgr::setConfigDirectories(std::string confFile, std::string neighDir)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string p3DummyAuthMgr::OwnId()
|
||||
{
|
||||
return mOwnId;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::getAllList(std::list<std::string> &ids)
|
||||
{
|
||||
std::map<std::string, pqiAuthDetails>::iterator it;
|
||||
for(it = mPeerList.begin(); it != mPeerList.end(); it++)
|
||||
{
|
||||
ids.push_back(it->first);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::getAuthenticatedList(std::list<std::string> &ids)
|
||||
{
|
||||
std::map<std::string, pqiAuthDetails>::iterator it;
|
||||
for(it = mPeerList.begin(); it != mPeerList.end(); it++)
|
||||
{
|
||||
if (it->second.trustLvl > 3)
|
||||
{
|
||||
ids.push_back(it->first);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::getUnknownList(std::list<std::string> &ids)
|
||||
{
|
||||
std::map<std::string, pqiAuthDetails>::iterator it;
|
||||
for(it = mPeerList.begin(); it != mPeerList.end(); it++)
|
||||
{
|
||||
if (it->second.trustLvl <= 3)
|
||||
{
|
||||
ids.push_back(it->first);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::isValid(std::string id)
|
||||
{
|
||||
std::map<std::string, pqiAuthDetails>::iterator it;
|
||||
return (mPeerList.end() != mPeerList.find(id));
|
||||
}
|
||||
|
||||
|
||||
bool p3DummyAuthMgr::isAuthenticated(std::string id)
|
||||
{
|
||||
std::map<std::string, pqiAuthDetails>::iterator it;
|
||||
if (mPeerList.end() != (it = mPeerList.find(id)))
|
||||
{
|
||||
return (it->second.trustLvl > 3);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string p3DummyAuthMgr::getName(std::string id)
|
||||
{
|
||||
std::map<std::string, pqiAuthDetails>::iterator it;
|
||||
if (mPeerList.end() != (it = mPeerList.find(id)))
|
||||
{
|
||||
return it->second.name;
|
||||
}
|
||||
std::string empty("");
|
||||
return empty;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::getDetails(std::string id, pqiAuthDetails &details)
|
||||
{
|
||||
std::map<std::string, pqiAuthDetails>::iterator it;
|
||||
if (mPeerList.end() != (it = mPeerList.find(id)))
|
||||
{
|
||||
details = it->second;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::FinalSaveCertificates()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::CheckSaveCertificates()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::saveCertificates()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::loadCertificates()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::LoadCertificateFromString(std::string pem, std::string &id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string p3DummyAuthMgr::SaveCertificateToString(std::string id)
|
||||
{
|
||||
std::string dummy("CERT STRING");
|
||||
return dummy;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::LoadCertificateFromFile(std::string filename, std::string &id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::SaveCertificateToFile(std::string id, std::string filename)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool p3DummyAuthMgr::LoadCertificateFromBinary(const uint8_t *ptr, uint32_t len, std::string &id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::SaveCertificateToBinary(std::string id, uint8_t **ptr, uint32_t *len)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Signatures */
|
||||
bool p3DummyAuthMgr::AuthCertificate(std::string id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::SignCertificate(std::string id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::RevokeCertificate(std::string id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::TrustCertificate(std::string id, bool trust)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::SignData(std::string input, std::string &sign)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::SignData(const void *data, const uint32_t len, std::string &sign)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::SignDataBin(std::string input,
|
||||
unsigned char *sign, unsigned int *signlen)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::SignDataBin(const void *data, const uint32_t len,
|
||||
unsigned char *sign, unsigned int *signlen)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3DummyAuthMgr::VerifySignBin(std::string pid,
|
||||
const void *data, const uint32_t len,
|
||||
unsigned char *sign, unsigned int signlen)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1,225 +0,0 @@
|
|||
/*
|
||||
* libretroshare/src/pqi: p3authmgr.h
|
||||
*
|
||||
* 3P/PQI network interface for RetroShare.
|
||||
*
|
||||
* Copyright 2007-2008 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef RS_GENERIC_AUTH_HEADER
|
||||
#define RS_GENERIC_AUTH_HEADER
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <gpgme.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/************** GENERIC AUTHENTICATION MANAGER ***********
|
||||
* Provides a common interface for certificates.
|
||||
*
|
||||
* Initialisation must be done in derived classes
|
||||
*
|
||||
* Key features:
|
||||
* everything indexed by std::string id;
|
||||
* has auth perspective: authed / not authed - different to friends.
|
||||
* load/save certificates as strings or files.
|
||||
*
|
||||
*/
|
||||
|
||||
class p3AuthMgr;
|
||||
extern p3AuthMgr *authMgr;
|
||||
|
||||
p3AuthMgr *getAuthMgr();
|
||||
|
||||
class pqiAuthDetails
|
||||
{
|
||||
public:
|
||||
pqiAuthDetails();
|
||||
|
||||
std::string id;
|
||||
std::string name;
|
||||
std::string email;
|
||||
std::string location;
|
||||
std::string org;
|
||||
|
||||
std::string issuer;
|
||||
|
||||
std::string fpr; /* fingerprint */
|
||||
std::list<std::string> signers;
|
||||
|
||||
uint32_t trustLvl;
|
||||
uint32_t validLvl;
|
||||
|
||||
bool ownsign;
|
||||
bool trusted; // means valid in pgp world.
|
||||
};
|
||||
|
||||
|
||||
class p3AuthMgr
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~p3AuthMgr() { return; }
|
||||
|
||||
/* initialisation -> done by derived classes */
|
||||
virtual bool active() = 0;
|
||||
virtual int InitAuth(const char *srvr_cert, const char *priv_key,
|
||||
const char *passwd) = 0;
|
||||
virtual bool CloseAuth() = 0;
|
||||
virtual int setConfigDirectories(std::string confFile, std::string neighDir) = 0;
|
||||
|
||||
/* get Certificate Ids */
|
||||
|
||||
virtual std::string OwnId() = 0;
|
||||
virtual bool getAllList(std::list<std::string> &ids) = 0;
|
||||
virtual bool getAuthenticatedList(std::list<std::string> &ids) = 0;
|
||||
virtual bool getUnknownList(std::list<std::string> &ids) = 0;
|
||||
|
||||
/* get Details from the Certificates */
|
||||
|
||||
virtual bool isValid(std::string id) = 0;
|
||||
virtual bool isAuthenticated(std::string id) = 0;
|
||||
virtual std::string getName(std::string id) = 0;
|
||||
virtual std::string getIssuerName(std::string id) { return getName(id); } // Default to same id.
|
||||
virtual bool getDetails(std::string id, pqiAuthDetails &details) = 0;
|
||||
|
||||
/* High Level Load/Save Configuration */
|
||||
virtual bool FinalSaveCertificates() = 0;
|
||||
virtual bool CheckSaveCertificates() = 0;
|
||||
virtual bool saveCertificates() = 0;
|
||||
virtual bool loadCertificates() = 0;
|
||||
|
||||
/* first party trust info */
|
||||
virtual bool isTrustingMe(std::string id) = 0;
|
||||
virtual void addTrustingPeer(std::string id) = 0;
|
||||
|
||||
/* Extra Fns for PGP, call std versions if not overloaded */
|
||||
virtual std::string PGPOwnId() { return OwnId(); }
|
||||
virtual bool getPGPAllList(std::list<std::string> &ids) { return getAllList(ids); }
|
||||
virtual bool encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER) { return 0; }
|
||||
virtual bool decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN) { return 0; }
|
||||
/* Load/Save certificates */
|
||||
|
||||
virtual bool LoadCertificateFromString(std::string pem, std::string &id) = 0;
|
||||
virtual std::string SaveCertificateToString(std::string id) = 0;
|
||||
virtual bool LoadCertificateFromFile(std::string filename, std::string &id) = 0;
|
||||
virtual bool SaveCertificateToFile(std::string id, std::string filename) = 0;
|
||||
|
||||
/* specific OpenSSL ones -> careful with pointers....
|
||||
* save will allocate space,
|
||||
*/
|
||||
virtual bool LoadCertificateFromBinary(const uint8_t *ptr, uint32_t len, std::string &id) = 0;
|
||||
virtual bool SaveCertificateToBinary(std::string id, uint8_t **ptr, uint32_t *len) = 0;
|
||||
|
||||
/* Signatures */
|
||||
virtual bool AuthCertificate(std::string uid) = 0;
|
||||
virtual bool SignCertificate(std::string id) = 0;
|
||||
virtual bool RevokeCertificate(std::string id) = 0;
|
||||
virtual bool TrustCertificate(std::string id, bool trust) = 0;
|
||||
|
||||
/* Sign / Encrypt / Verify Data (TODO) */
|
||||
virtual bool SignData(std::string input, std::string &sign) = 0;
|
||||
virtual bool SignData(const void *data, const uint32_t len, std::string &sign) = 0;
|
||||
virtual bool SignDataBin(std::string input, unsigned char *sign, unsigned int *signlen) = 0;
|
||||
virtual bool SignDataBin(const void *data, const uint32_t len,
|
||||
unsigned char *sign, unsigned int *signlen) = 0;
|
||||
|
||||
virtual bool VerifySignBin(std::string pid,
|
||||
const void *data, const uint32_t len,
|
||||
unsigned char *sign, unsigned int signlen) = 0;
|
||||
|
||||
//virtual bool encryptData(std::string recipientId, std::string plaindata, std::string &result);
|
||||
|
||||
};
|
||||
|
||||
|
||||
class p3DummyAuthMgr: public p3AuthMgr
|
||||
{
|
||||
public:
|
||||
|
||||
p3DummyAuthMgr();
|
||||
p3DummyAuthMgr(std::string ownId, std::list<pqiAuthDetails> peers);
|
||||
|
||||
/* initialisation -> done by derived classes */
|
||||
virtual bool active();
|
||||
virtual int InitAuth(const char *srvr_cert, const char *priv_key,
|
||||
const char *passwd);
|
||||
virtual bool CloseAuth();
|
||||
virtual int setConfigDirectories(std::string confFile, std::string neighDir);
|
||||
|
||||
/* get Certificate Ids */
|
||||
|
||||
virtual std::string OwnId();
|
||||
virtual bool getAllList(std::list<std::string> &ids);
|
||||
virtual bool getAuthenticatedList(std::list<std::string> &ids);
|
||||
virtual bool getUnknownList(std::list<std::string> &ids);
|
||||
|
||||
/* get Details from the Certificates */
|
||||
|
||||
virtual bool isValid(std::string id);
|
||||
virtual bool isAuthenticated(std::string id);
|
||||
virtual std::string getName(std::string id);
|
||||
virtual bool getDetails(std::string id, pqiAuthDetails &details);
|
||||
|
||||
/* High Level Load/Save Configuration */
|
||||
virtual bool FinalSaveCertificates();
|
||||
virtual bool CheckSaveCertificates();
|
||||
virtual bool saveCertificates();
|
||||
virtual bool loadCertificates();
|
||||
|
||||
/* first party trust info */
|
||||
virtual bool isTrustingMe(std::string id) ;
|
||||
virtual void addTrustingPeer(std::string id) ;
|
||||
|
||||
/* Load/Save certificates */
|
||||
virtual bool LoadCertificateFromString(std::string pem, std::string &id);
|
||||
virtual std::string SaveCertificateToString(std::string id);
|
||||
virtual bool LoadCertificateFromFile(std::string filename, std::string &id);
|
||||
virtual bool SaveCertificateToFile(std::string id, std::string filename);
|
||||
|
||||
virtual bool LoadCertificateFromBinary(const uint8_t *ptr, uint32_t len, std::string &id);
|
||||
virtual bool SaveCertificateToBinary(std::string id, uint8_t **ptr, uint32_t *len);
|
||||
/* Signatures */
|
||||
|
||||
virtual bool AuthCertificate(std::string uid);
|
||||
virtual bool SignCertificate(std::string id);
|
||||
virtual bool RevokeCertificate(std::string id);
|
||||
virtual bool TrustCertificate(std::string id, bool trust);
|
||||
|
||||
virtual bool SignData(std::string input, std::string &sign);
|
||||
virtual bool SignData(const void *data, const uint32_t len, std::string &sign);
|
||||
virtual bool SignDataBin(std::string input, unsigned char *sign, unsigned int *signlen);
|
||||
virtual bool SignDataBin(const void *data, const uint32_t len,
|
||||
unsigned char *sign, unsigned int *signlen);
|
||||
|
||||
virtual bool VerifySignBin(std::string pid,
|
||||
const void *data, const uint32_t len,
|
||||
unsigned char *sign, unsigned int signlen);
|
||||
|
||||
std::string mOwnId;
|
||||
std::map<std::string, pqiAuthDetails> mPeerList;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
#include "util/rsdir.h"
|
||||
#include "rsiface/rspeers.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "pqi/p3authmgr.h"
|
||||
#include "pqi/authssl.h"
|
||||
#include "pqi/pqibin.h"
|
||||
#include "pqi/pqistore.h"
|
||||
#include "pqi/pqinotify.h"
|
||||
|
@ -40,8 +40,8 @@
|
|||
|
||||
#define CONFIG_DEBUG 1
|
||||
|
||||
p3ConfigMgr::p3ConfigMgr(p3AuthMgr *am, std::string dir, std::string fname, std::string signame)
|
||||
:mAuthMgr(am), basedir(dir), metafname(fname), metasigfname(signame),
|
||||
p3ConfigMgr::p3ConfigMgr(std::string dir, std::string fname, std::string signame)
|
||||
:basedir(dir), metafname(fname), metasigfname(signame),
|
||||
mConfigSaveActive(true)
|
||||
{
|
||||
|
||||
|
@ -160,7 +160,7 @@ void p3ConfigMgr::saveConfiguration()
|
|||
|
||||
/* sign data */
|
||||
std::string signature;
|
||||
mAuthMgr->SignData(membio->memptr(), membio->memsize(), signature);
|
||||
getAuthSSL()->SignData(membio->memptr(), membio->memsize(), signature);
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
std::cerr << "p3ConfigMgr::saveConfiguration() MetaFile Signature:";
|
||||
|
@ -274,7 +274,7 @@ void p3ConfigMgr::loadConfiguration()
|
|||
|
||||
/* get signature */
|
||||
std::string signature;
|
||||
mAuthMgr->SignData(membio->memptr(), membio->memsize(), signature);
|
||||
getAuthSSL()->SignData(membio->memptr(), membio->memsize(), signature);
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
std::cerr << "p3ConfigMgr::loadConfiguration() New MetaFile Signature:";
|
||||
|
|
|
@ -90,7 +90,6 @@ const uint32_t CONFIG_TYPE_CHANNELS = 0x0103;
|
|||
const uint32_t CONFIG_TYPE_CACHE = 0xff01;
|
||||
|
||||
class p3ConfigMgr;
|
||||
class p3AuthMgr;
|
||||
|
||||
class pqiConfig
|
||||
{
|
||||
|
@ -138,7 +137,7 @@ bool HasConfigChanged(uint16_t idx);
|
|||
class p3ConfigMgr
|
||||
{
|
||||
public:
|
||||
p3ConfigMgr(p3AuthMgr *am, std::string bdir, std::string fname, std::string signame);
|
||||
p3ConfigMgr(std::string bdir, std::string fname, std::string signame);
|
||||
|
||||
void tick();
|
||||
void saveConfiguration();
|
||||
|
@ -152,10 +151,6 @@ void completeConfiguration();
|
|||
|
||||
private:
|
||||
|
||||
|
||||
/* these are constants - so shouldn't need mutex */
|
||||
p3AuthMgr *mAuthMgr;
|
||||
|
||||
const std::string basedir;
|
||||
const std::string metafname;
|
||||
const std::string metasigfname;
|
||||
|
|
|
@ -128,19 +128,17 @@ std::string textPeerConnectState(peerConnectState &state)
|
|||
|
||||
|
||||
|
||||
p3ConnectMgr::p3ConnectMgr(p3AuthMgr *am)
|
||||
p3ConnectMgr::p3ConnectMgr()
|
||||
:p3Config(CONFIG_TYPE_PEERS),
|
||||
mAuthMgr(am), mNetStatus(RS_NET_UNKNOWN),
|
||||
mNetStatus(RS_NET_UNKNOWN),
|
||||
mStunStatus(0), mStunFound(0), mStunMoreRequired(true),
|
||||
mStatusChanged(false)
|
||||
{
|
||||
/* setup basics of own state */
|
||||
if (am)
|
||||
{
|
||||
ownState.id = mAuthMgr->OwnId();
|
||||
ownState.name = mAuthMgr->getName(ownState.id);
|
||||
ownState.netMode = RS_NET_MODE_UDP;
|
||||
}
|
||||
ownState.id = getAuthSSL()->OwnId();
|
||||
ownState.name = getAuthSSL()->getName(ownState.id);
|
||||
ownState.netMode = RS_NET_MODE_UDP;
|
||||
|
||||
//use_extr_addr_finder = true ;
|
||||
use_extr_addr_finder = false;
|
||||
allow_tunnel_connection = true;
|
||||
|
@ -1344,15 +1342,7 @@ void p3ConnectMgr::tickMonitors()
|
|||
|
||||
const std::string p3ConnectMgr::getOwnId()
|
||||
{
|
||||
if (mAuthMgr)
|
||||
{
|
||||
return mAuthMgr->OwnId();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string nullStr;
|
||||
return nullStr;
|
||||
}
|
||||
return getAuthSSL()->OwnId();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1384,7 +1374,7 @@ bool p3ConnectMgr::isOnline(std::string id)
|
|||
else
|
||||
{
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::isOnline(" << id << ") is Not Friend" << std::endl << "p3ConnectMgr::isOnline() OwnId: " << mAuthMgr->OwnId() << std::endl;
|
||||
std::cerr << "p3ConnectMgr::isOnline(" << id << ") is Not Friend" << std::endl << "p3ConnectMgr::isOnline() OwnId: " << getAuthSSL()->OwnId() << std::endl;
|
||||
#endif
|
||||
/* not a friend */
|
||||
}
|
||||
|
@ -2024,7 +2014,7 @@ bool p3ConnectMgr::addFriend(std::string id, uint32_t netMode, uint32_t visState
|
|||
}
|
||||
|
||||
/* check with the AuthMgr if its authorised */
|
||||
if (!mAuthMgr->isAuthenticated(id))
|
||||
if (!getAuthSSL()->isAuthenticated(id))
|
||||
{
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::addFriend() Failed Authentication" << std::endl;
|
||||
|
@ -2074,8 +2064,8 @@ bool p3ConnectMgr::addFriend(std::string id, uint32_t netMode, uint32_t visState
|
|||
}
|
||||
|
||||
/* get details from AuthMgr */
|
||||
pqiAuthDetails detail;
|
||||
if (!mAuthMgr->getDetails(id, detail))
|
||||
sslcert detail;
|
||||
if (!getAuthSSL()->getCertDetails(id, detail))
|
||||
{
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::addFriend() Failed to get Details" << std::endl;
|
||||
|
@ -2184,15 +2174,15 @@ bool p3ConnectMgr::addNeighbour(std::string id)
|
|||
}
|
||||
|
||||
/* check with the AuthMgr if its valid */
|
||||
if (!mAuthMgr->isValid(id))
|
||||
if (!getAuthSSL()->isValid(id))
|
||||
{
|
||||
/* no auth */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* get details from AuthMgr */
|
||||
pqiAuthDetails detail;
|
||||
if (!mAuthMgr->getDetails(id, detail))
|
||||
sslcert detail;
|
||||
if (!getAuthSSL()->getCertDetails(id, detail))
|
||||
{
|
||||
/* no details */
|
||||
return false;
|
||||
|
@ -2469,7 +2459,7 @@ bool p3ConnectMgr::retryConnectNotify(std::string id)
|
|||
bool p3ConnectMgr::setLocalAddress(std::string id, struct sockaddr_in addr)
|
||||
{
|
||||
|
||||
if (id == mAuthMgr->OwnId())
|
||||
if (id == getAuthSSL()->OwnId())
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
@ -2519,7 +2509,7 @@ bool p3ConnectMgr::setLocalAddress(std::string id, struct sockaddr_in addr)
|
|||
|
||||
bool p3ConnectMgr::setExtAddress(std::string id, struct sockaddr_in addr)
|
||||
{
|
||||
if (id == mAuthMgr->OwnId())
|
||||
if (id == getAuthSSL()->OwnId())
|
||||
{
|
||||
if (ownState.currentserveraddr.sin_addr.s_addr != addr.sin_addr.s_addr ||
|
||||
ownState.currentserveraddr.sin_port != addr.sin_port) {
|
||||
|
@ -2619,7 +2609,7 @@ bool p3ConnectMgr::setAddressList(std::string id, std::list<IpAddressTimed> I
|
|||
|
||||
bool p3ConnectMgr::setNetworkMode(std::string id, uint32_t netMode)
|
||||
{
|
||||
if (id == mAuthMgr->OwnId())
|
||||
if (id == getAuthSSL()->OwnId())
|
||||
{
|
||||
uint32_t visState = ownState.visState;
|
||||
setOwnNetConfig(netMode, visState);
|
||||
|
@ -2649,7 +2639,7 @@ bool p3ConnectMgr::setNetworkMode(std::string id, uint32_t netMode)
|
|||
|
||||
bool p3ConnectMgr::setVisState(std::string id, uint32_t visState)
|
||||
{
|
||||
if (id == mAuthMgr->OwnId())
|
||||
if (id == getAuthSSL()->OwnId())
|
||||
{
|
||||
uint32_t netMode = ownState.netMode;
|
||||
setOwnNetConfig(netMode, visState);
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#define MRK_PQI_CONNECTION_MANAGER_HEADER
|
||||
|
||||
#include "pqi/pqimonitor.h"
|
||||
#include "pqi/p3authmgr.h"
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
|
||||
//#include "pqi/p3dhtmgr.h"
|
||||
|
@ -191,7 +190,7 @@ class p3ConnectMgr: public pqiConnectCb, public p3Config
|
|||
{
|
||||
public:
|
||||
|
||||
p3ConnectMgr(p3AuthMgr *authMgr);
|
||||
p3ConnectMgr();
|
||||
|
||||
void tick();
|
||||
|
||||
|
@ -372,8 +371,6 @@ void addPeer(RsPeerConfigItem *item);
|
|||
|
||||
private:
|
||||
|
||||
p3AuthMgr *mAuthMgr;
|
||||
|
||||
p3tunnel *mP3tunnel;
|
||||
|
||||
std::map<uint32_t, pqiNetAssistFirewall *> mFwAgents;
|
||||
|
|
|
@ -87,7 +87,7 @@ static const int PQISSL_MAX_READ_ZERO_COUNT = 40;
|
|||
*
|
||||
*/
|
||||
|
||||
pqissl::pqissl(pqissllistener *l, PQInterface *parent, p3AuthMgr *am, p3ConnectMgr *cm)
|
||||
pqissl::pqissl(pqissllistener *l, PQInterface *parent, p3ConnectMgr *cm)
|
||||
:NetBinInterface(parent, parent->PeerId()),
|
||||
waiting(WAITING_NOT), active(false), certvalid(false),
|
||||
sslmode(PQISSL_ACTIVE), ssl_connection(NULL), sockfd(-1),
|
||||
|
@ -97,15 +97,7 @@ pqissl::pqissl(pqissllistener *l, PQInterface *parent, p3AuthMgr *am, p3ConnectM
|
|||
sameLAN(false), n_read_zero(0),
|
||||
mConnectDelay(0), mConnectTS(0),
|
||||
mConnectTimeout(0), mTimeoutTS(0), quietShutdown(false),
|
||||
|
||||
/**************** PQI_USE_XPGP ******************/
|
||||
#if defined(PQI_USE_XPGP)
|
||||
mAuthMgr((AuthXPGP *) am), mConnMgr(cm)
|
||||
#else /* X509 Certificates */
|
||||
/**************** PQI_USE_XPGP ******************/
|
||||
mAuthMgr((AuthSSL *) am), mConnMgr(cm)
|
||||
#endif /* X509 Certificates */
|
||||
/**************** PQI_USE_XPGP ******************/
|
||||
mConnMgr(cm)
|
||||
|
||||
{
|
||||
/* set address to zero */
|
||||
|
|
|
@ -95,7 +95,7 @@ class pqissl: public NetBinInterface
|
|||
{
|
||||
public:
|
||||
pqissl(pqissllistener *l, PQInterface *parent,
|
||||
p3AuthMgr *am, p3ConnectMgr *cm);
|
||||
p3ConnectMgr *cm);
|
||||
virtual ~pqissl();
|
||||
|
||||
// NetInterface
|
||||
|
|
|
@ -55,9 +55,8 @@ const int pqissllistenzone = 49787;
|
|||
*/
|
||||
|
||||
|
||||
pqissllistenbase::pqissllistenbase(struct sockaddr_in addr, p3AuthMgr *am, p3ConnectMgr *cm)
|
||||
:laddr(addr), active(false),
|
||||
mAuthMgr((AuthSSL *) am), mConnMgr(cm)
|
||||
pqissllistenbase::pqissllistenbase(struct sockaddr_in addr, p3ConnectMgr *cm)
|
||||
:laddr(addr), active(false), mConnMgr(cm)
|
||||
|
||||
{
|
||||
if (!(mAuthMgr -> active()))
|
||||
|
@ -521,8 +520,8 @@ int pqissllistenbase::continueaccepts()
|
|||
*
|
||||
*/
|
||||
|
||||
pqissllistener::pqissllistener(struct sockaddr_in addr, p3AuthMgr *am, p3ConnectMgr *cm)
|
||||
:pqissllistenbase(addr, am, cm)
|
||||
pqissllistener::pqissllistener(struct sockaddr_in addr, p3ConnectMgr *cm)
|
||||
:pqissllistenbase(addr, cm)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ class pqissllistenbase: public pqilistener
|
|||
public:
|
||||
|
||||
|
||||
pqissllistenbase(struct sockaddr_in addr, p3AuthMgr *am, p3ConnectMgr *cm);
|
||||
pqissllistenbase(struct sockaddr_in addr, p3ConnectMgr *cm);
|
||||
virtual ~pqissllistenbase();
|
||||
|
||||
/*************************************/
|
||||
|
@ -99,7 +99,7 @@ class pqissllistener: public pqissllistenbase
|
|||
{
|
||||
public:
|
||||
|
||||
pqissllistener(struct sockaddr_in addr, p3AuthMgr *am, p3ConnectMgr *cm);
|
||||
pqissllistener(struct sockaddr_in addr, p3ConnectMgr *cm);
|
||||
virtual ~pqissllistener();
|
||||
|
||||
int addlistenaddr(std::string id, pqissl *acc);
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "util/rsdebug.h"
|
||||
|
||||
#include "pqi/pqisslpersongrp.h"
|
||||
#include "pqi/p3authmgr.h"
|
||||
#include "pqi/authssl.h"
|
||||
|
||||
|
||||
const int pqipersongrpzone = 354;
|
||||
|
@ -50,8 +50,7 @@ const int pqipersongrpzone = 354;
|
|||
|
||||
pqilistener * pqisslpersongrp::createListener(struct sockaddr_in laddr)
|
||||
{
|
||||
p3AuthMgr *authMgr = getAuthMgr();
|
||||
pqilistener *listener = new pqissllistener(laddr, authMgr, mConnMgr);
|
||||
pqilistener *listener = new pqissllistener(laddr, mConnMgr);
|
||||
return listener;
|
||||
}
|
||||
|
||||
|
@ -63,9 +62,8 @@ pqiperson * pqisslpersongrp::createPerson(std::string id, pqilistener *listener)
|
|||
pqioutput(PQL_DEBUG_BASIC, pqipersongrpzone, out.str());
|
||||
}
|
||||
|
||||
p3AuthMgr *authMgr = getAuthMgr();
|
||||
pqiperson *pqip = new pqiperson(id, this);
|
||||
pqissl *pqis = new pqissl((pqissllistener *) listener, pqip, authMgr, mConnMgr);
|
||||
pqissl *pqis = new pqissl((pqissllistener *) listener, pqip, mConnMgr);
|
||||
|
||||
/* construct the serialiser ....
|
||||
* Needs:
|
||||
|
@ -83,7 +81,7 @@ pqiperson * pqisslpersongrp::createPerson(std::string id, pqilistener *listener)
|
|||
|
||||
pqip -> addChildInterface(PQI_CONNECT_TCP, pqisc);
|
||||
|
||||
pqissltunnel *pqitun = new pqissltunnel(pqip, authMgr, mConnMgr);
|
||||
pqissltunnel *pqitun = new pqissltunnel(pqip, mConnMgr);
|
||||
RsSerialiser *rss3 = new RsSerialiser();
|
||||
rss3->addSerialType(new RsFileItemSerialiser());
|
||||
rss3->addSerialType(new RsCacheItemSerialiser());
|
||||
|
@ -92,7 +90,7 @@ pqiperson * pqisslpersongrp::createPerson(std::string id, pqilistener *listener)
|
|||
pqip -> addChildInterface(PQI_CONNECT_TUNNEL, pqicontun);
|
||||
|
||||
#ifndef PQI_DISABLE_UDP
|
||||
pqissludp *pqius = new pqissludp(pqip, authMgr, mConnMgr);
|
||||
pqissludp *pqius = new pqissludp(pqip, mConnMgr);
|
||||
|
||||
RsSerialiser *rss2 = new RsSerialiser();
|
||||
rss2->addSerialType(new RsFileItemSerialiser());
|
||||
|
|
|
@ -90,9 +90,8 @@ const int pqisslzone = 37714;
|
|||
*
|
||||
*/
|
||||
|
||||
pqissltunnel::pqissltunnel(PQInterface *parent, p3AuthMgr *am, p3ConnectMgr *cm)
|
||||
:NetBinInterface(parent, parent->PeerId()),
|
||||
mAuthMgr((AuthSSL *) am), mConnMgr(cm)
|
||||
pqissltunnel::pqissltunnel(PQInterface *parent, p3ConnectMgr *cm)
|
||||
:NetBinInterface(parent, parent->PeerId()), mConnMgr(cm)
|
||||
{
|
||||
active = false;
|
||||
waiting = TUNNEL_WAITING_NOT;
|
||||
|
|
|
@ -74,7 +74,7 @@ struct data_with_length {
|
|||
class pqissltunnel: public NetBinInterface
|
||||
{
|
||||
public:
|
||||
pqissltunnel(PQInterface *parent, p3AuthMgr *am, p3ConnectMgr *cm);
|
||||
pqissltunnel(PQInterface *parent, p3ConnectMgr *cm);
|
||||
virtual ~pqissltunnel();
|
||||
|
||||
// NetInterface
|
||||
|
|
|
@ -52,8 +52,8 @@ static const uint32_t PQI_SSLUDP_DEF_CONN_PERIOD = 300; /* 5 minutes? */
|
|||
|
||||
/********** PQI SSL UDP STUFF **************************************/
|
||||
|
||||
pqissludp::pqissludp(PQInterface *parent, p3AuthMgr *am, p3ConnectMgr *cm)
|
||||
:pqissl(NULL, parent, am, cm), tou_bio(NULL),
|
||||
pqissludp::pqissludp(PQInterface *parent, p3ConnectMgr *cm)
|
||||
:pqissl(NULL, parent, cm), tou_bio(NULL),
|
||||
listen_checktime(0), mConnectPeriod(PQI_SSLUDP_DEF_CONN_PERIOD)
|
||||
{
|
||||
sockaddr_clear(&remote_addr);
|
||||
|
|
|
@ -55,7 +55,7 @@ class cert;
|
|||
class pqissludp: public pqissl
|
||||
{
|
||||
public:
|
||||
pqissludp(PQInterface *parent, p3AuthMgr *am, p3ConnectMgr *cm);
|
||||
pqissludp(PQInterface *parent, p3ConnectMgr *cm);
|
||||
|
||||
virtual ~pqissludp();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue