mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-25 01:01:40 -04:00
added display of SSL encryption parameters in PeerDetails dialog
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6465 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
1ebde8788f
commit
9f88917ac1
12 changed files with 102 additions and 7 deletions
|
@ -346,6 +346,12 @@ void pqipersongrp::statusChanged()
|
|||
///////////////////////////////////////////////////////////
|
||||
#endif
|
||||
|
||||
bool pqipersongrp::getCryptoParams(const std::string& id,RsPeerCryptoParams& params)
|
||||
{
|
||||
RsStackMutex stack(coreMtx); /******* LOCKED MUTEX **********/
|
||||
|
||||
return locked_getCryptoParams(id,params) ;
|
||||
}
|
||||
|
||||
int pqipersongrp::addPeer(std::string id)
|
||||
{
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
const unsigned long PQIPERSON_NO_LISTENER = 0x0001;
|
||||
|
||||
const unsigned long PQIPERSON_ALL_BW_LIMITED = 0x0010;
|
||||
class RsPeerCryptoParams ;
|
||||
|
||||
class pqipersongrp: public pqihandler, public pqiMonitor, public p3ServiceServer, public pqiNetListener
|
||||
{
|
||||
|
@ -90,8 +91,11 @@ bool notifyConnect(std::string id, uint32_t type, bool success, struct sockad
|
|||
virtual int tick();
|
||||
virtual int status();
|
||||
|
||||
virtual bool getCryptoParams(const std::string&,RsPeerCryptoParams&) ;
|
||||
protected:
|
||||
|
||||
virtual bool locked_getCryptoParams(const std::string&, RsPeerCryptoParams&) { return false ;}
|
||||
|
||||
/********* FUNCTIONS to OVERLOAD for specialisation ********/
|
||||
// THESE NEED TO BE LOCKED UNTIL PQILISTENER IS THREAD-SAFE.
|
||||
virtual pqilistener *locked_createListener(struct sockaddr_in laddr) = 0;
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "pqi/pqissllistener.h"
|
||||
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
const int pqisslzone = 37714;
|
||||
|
||||
|
@ -309,6 +310,31 @@ bool pqissl::connect_parameter(uint32_t type, uint32_t value)
|
|||
*
|
||||
*/
|
||||
|
||||
void pqissl::getCryptoParams(RsPeerCryptoParams& params)
|
||||
{
|
||||
if(active)
|
||||
{
|
||||
params.connexion_state = 1 ;
|
||||
params.cipher_name = std::string( SSL_get_cipher(ssl_connection));
|
||||
|
||||
int alg ;
|
||||
int al2 = SSL_get_cipher_bits(ssl_connection,&alg);
|
||||
|
||||
params.cipher_bits_1 = alg ;
|
||||
params.cipher_bits_2 = al2 ;
|
||||
|
||||
params.cipher_version = SSL_get_cipher_version(ssl_connection) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
params.connexion_state = 0 ;
|
||||
params.cipher_name.clear() ;
|
||||
params.cipher_bits_1 = 0 ;
|
||||
params.cipher_bits_2 = 0 ;
|
||||
params.cipher_version.clear() ;
|
||||
}
|
||||
}
|
||||
|
||||
/* returns ...
|
||||
* -1 if inactive.
|
||||
* 0 if connecting.
|
||||
|
|
|
@ -83,6 +83,7 @@ class cert;
|
|||
|
||||
class pqissllistener;
|
||||
class p3LinkMgr;
|
||||
class RsPeerCryptoParams ;
|
||||
|
||||
class pqissl: public NetBinInterface
|
||||
{
|
||||
|
@ -152,6 +153,8 @@ public:
|
|||
|
||||
int accept(SSL *ssl, int fd, struct sockaddr_in foreign_addr);
|
||||
|
||||
void getCryptoParams(RsPeerCryptoParams& params) ;
|
||||
|
||||
protected:
|
||||
|
||||
//protected internal fns that are overloaded for udp case.
|
||||
|
|
|
@ -55,6 +55,17 @@ pqilistener * pqisslpersongrp::locked_createListener(struct sockaddr_in laddr)
|
|||
return listener;
|
||||
}
|
||||
|
||||
bool pqisslpersongrp::locked_getCryptoParams(const std::string& id,RsPeerCryptoParams& params)
|
||||
{
|
||||
std::map<std::string, pqissl*>::const_iterator it = ssl_tunnels.find(id) ;
|
||||
|
||||
if(it == ssl_tunnels.end())
|
||||
return false ;
|
||||
|
||||
it->second->getCryptoParams(params) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
pqiperson * pqisslpersongrp::locked_createPerson(std::string id, pqilistener *listener)
|
||||
{
|
||||
pqioutput(PQL_DEBUG_BASIC, pqipersongrpzone, "pqipersongrp::createPerson() PeerId: " + id);
|
||||
|
@ -69,6 +80,8 @@ pqiperson * pqisslpersongrp::locked_createPerson(std::string id, pqilistener *li
|
|||
* * ServiceGeneric
|
||||
*/
|
||||
|
||||
ssl_tunnels[id] = pqis ; // keeps for getting crypt info per peer.
|
||||
|
||||
RsSerialiser *rss = new RsSerialiser();
|
||||
rss->addSerialType(new RsFileItemSerialiser());
|
||||
rss->addSerialType(new RsCacheItemSerialiser());
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include "pqi/pqipersongrp.h"
|
||||
|
||||
class p3PeerMgr;
|
||||
class RsPeerCryptoParams;
|
||||
class pqissl ;
|
||||
|
||||
class pqisslpersongrp: public pqipersongrp
|
||||
{
|
||||
|
@ -38,6 +40,8 @@ class pqisslpersongrp: public pqipersongrp
|
|||
pqisslpersongrp(SecurityPolicy *pol, unsigned long flags, p3PeerMgr *pm)
|
||||
:pqipersongrp(pol, flags), mPeerMgr(pm) { return; }
|
||||
|
||||
bool locked_getCryptoParams(const std::string&, RsPeerCryptoParams&) ;
|
||||
|
||||
protected:
|
||||
|
||||
/********* FUNCTIONS to OVERLOAD for specialisation ********/
|
||||
|
@ -48,6 +52,7 @@ virtual pqiperson *locked_createPerson(std::string id, pqilistener *listener);
|
|||
private:
|
||||
|
||||
p3PeerMgr *mPeerMgr;
|
||||
std::map<std::string,pqissl*> ssl_tunnels ;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue