- made the names consistent between ftdata, ftdatamultiplex and tests/

- added missing virtual functions in ftDataRecv
- setup initSSL instance as a static member of AuthSSL, instead of an external (does not change much except the init in rsinit.cc)
- changed p3PeerMgrIMPL to take SSL and PGP ids as parameters. This avoids calling AuthSSL and AuthGPG from the constructor => very helpful for tests.
- added random creation function in t_RsGenericId<>
- added functions setAuthSSL_debug() and setAuthGPG_debug() to manually setup the authSSL and authGPG objects to use. Used in tests.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6035 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2012-12-26 18:12:19 +00:00
parent 69859f2a43
commit 66207b81e5
12 changed files with 52 additions and 23 deletions

View file

@ -225,6 +225,9 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler
/* GPG service */
virtual bool addService(AuthGPGService *service) ;
// This is for debug purpose only. Don't use it !!
static void setAuthGPG_debug(AuthGPG *auth_gpg) { _instance = auth_gpg ; }
protected:
AuthGPG(const std::string& path_to_pubring, const std::string& path_to_secring,const std::string& path_to_trustdb,const std::string& pgp_lock_file);
virtual ~AuthGPG();

View file

@ -59,7 +59,7 @@
***/
// initialisation du pointeur de singleton
static AuthSSL *instance_ssl = NULL;
AuthSSL *AuthSSL::instance_ssl = NULL;
static pthread_mutex_t *mutex_buf = NULL;
struct CRYPTO_dynlock_value
@ -200,12 +200,12 @@ void tls_cleanup()
}
/* hidden function - for testing purposes() */
void setAuthSSL(AuthSSL *newssl)
void AuthSSL::setAuthSSL_debug(AuthSSL *newssl)
{
instance_ssl = newssl;
}
void AuthSSLInit()
void AuthSSL::AuthSSLInit()
{
if (instance_ssl == NULL)
{

View file

@ -86,7 +86,6 @@ class sslcert
};
/* required to install instance */
extern void AuthSSLInit();
class AuthSSL
{
@ -94,6 +93,7 @@ class AuthSSL
AuthSSL();
static AuthSSL *getAuthSSL();
static void AuthSSLInit();
/* Initialisation Functions (Unique) */
virtual bool validateOwnCertificate(X509 *x509, EVP_PKEY *pkey) = 0;
@ -155,6 +155,9 @@ virtual void getCurrentConnectionAttemptInfo( std::string& gpg_id, s
virtual bool FailedCertificate(X509 *x509, const std::string& gpgid,const std::string& sslid,const std::string& sslcn,const struct sockaddr_in &addr, bool incoming) = 0; /* store for discovery */
virtual bool CheckCertificate(std::string peerId, X509 *x509) = 0; /* check that they are exact match */
static void setAuthSSL_debug(AuthSSL*) ; // used for debug only. The real function is InitSSL()
static AuthSSL *instance_ssl ;
};
@ -235,9 +238,6 @@ virtual bool CheckCertificate(std::string peerId, X509 *x509); /* check that th
private:
// the single instance of this
static AuthSSL *instance_ssl;
bool LocalStoreCert(X509* x509);
bool RemoveX509(std::string id);

View file

@ -97,7 +97,10 @@ std::string textPeerConnectState(peerState &state)
}
p3PeerMgrIMPL::p3PeerMgrIMPL()
p3PeerMgrIMPL::p3PeerMgrIMPL( const std::string& ssl_own_id,
const std::string& gpg_own_id,
const std::string& gpg_own_name,
const std::string& ssl_own_location)
:p3Config(CONFIG_TYPE_PEERS), mPeerMtx("p3PeerMgr"), mStatusChanged(false)
{
@ -108,10 +111,10 @@ p3PeerMgrIMPL::p3PeerMgrIMPL()
mNetMgr = NULL;
/* setup basics of own state */
mOwnState.id = AuthSSL::getAuthSSL()->OwnId();
mOwnState.gpg_id = AuthGPG::getAuthGPG()->getGPGOwnId();
mOwnState.name = AuthGPG::getAuthGPG()->getGPGOwnName();
mOwnState.location = AuthSSL::getAuthSSL()->getOwnLocation();
mOwnState.id = ssl_own_id ;
mOwnState.gpg_id = gpg_own_id ;
mOwnState.name = gpg_own_name ;
mOwnState.location = ssl_own_location ;
mOwnState.netMode = RS_NET_MODE_UPNP; // Default to UPNP.
mOwnState.visState = 0;

View file

@ -290,7 +290,10 @@ virtual bool haveOnceConnected();
/* Extra IMPL Functions (used by p3LinkMgr, p3NetMgr + Setup) */
/************************************************************************************************/
p3PeerMgrIMPL();
p3PeerMgrIMPL( const std::string& ssl_own_id,
const std::string& gpg_own_id,
const std::string& gpg_own_name,
const std::string& ssl_own_location) ;
void setManagers(p3LinkMgrIMPL *linkMgr, p3NetMgrIMPL *netMgr);