mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
made randomBias initilized with true random bytes at start
This commit is contained in:
parent
9b0a4b966e
commit
dac885e24d
@ -30,7 +30,7 @@
|
|||||||
#include "gxs/rsnxs.h"
|
#include "gxs/rsnxs.h"
|
||||||
#include "rsgxsnettunnel.h"
|
#include "rsgxsnettunnel.h"
|
||||||
|
|
||||||
//#define DEBUG_RSGXSNETTUNNEL 1
|
#define DEBUG_RSGXSNETTUNNEL 1
|
||||||
|
|
||||||
#define GXS_NET_TUNNEL_NOT_IMPLEMENTED() { std::cerr << __PRETTY_FUNCTION__ << ": not yet implemented." << std::endl; }
|
#define GXS_NET_TUNNEL_NOT_IMPLEMENTED() { std::cerr << __PRETTY_FUNCTION__ << ": not yet implemented." << std::endl; }
|
||||||
#define GXS_NET_TUNNEL_DEBUG() std::cerr << time(NULL) << " : GXS_NET_TUNNEL: " << __FUNCTION__ << " : "
|
#define GXS_NET_TUNNEL_DEBUG() std::cerr << time(NULL) << " : GXS_NET_TUNNEL: " << __FUNCTION__ << " : "
|
||||||
@ -43,7 +43,6 @@ RsGxsDistSync *rsGxsDistSync = NULL;
|
|||||||
|
|
||||||
RsGxsNetTunnelService::RsGxsNetTunnelService(): mGxsNetTunnelMtx("GxsNetTunnel")
|
RsGxsNetTunnelService::RsGxsNetTunnelService(): mGxsNetTunnelMtx("GxsNetTunnel")
|
||||||
{
|
{
|
||||||
#warning this is for testing only. In the final version this needs to be initialized with some random content, saved and re-used for a while (e.g. 1 month)
|
|
||||||
mRandomBias.clear();
|
mRandomBias.clear();
|
||||||
|
|
||||||
mLastKeepAlive = time(NULL) + (lrand48()%20); // adds some variance in order to avoid doing all this tasks at once across services
|
mLastKeepAlive = time(NULL) + (lrand48()%20); // adds some variance in order to avoid doing all this tasks at once across services
|
||||||
@ -779,14 +778,10 @@ const Bias20Bytes& RsGxsNetTunnelService::locked_randomBias()
|
|||||||
{
|
{
|
||||||
if(mRandomBias.isNull())
|
if(mRandomBias.isNull())
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_RSGXSNETTUNNEL
|
|
||||||
#warning /!\ this is for testing only! Remove this when done! Can not be done at initialization when rsPeer is not started.
|
|
||||||
RsPeerId ssl_id = rsPeers->getOwnId() ;
|
|
||||||
mRandomBias = Bias20Bytes(RsDirUtil::sha1sum(ssl_id.toByteArray(),ssl_id.SIZE_IN_BYTES)) ;
|
|
||||||
#else
|
|
||||||
mRandomBias = Bias20Bytes::random();
|
mRandomBias = Bias20Bytes::random();
|
||||||
#endif
|
|
||||||
IndicateConfigChanged();
|
IndicateConfigChanged();
|
||||||
|
|
||||||
|
std::cerr << "Initialized RsGxsNetTunnel random bias to " << RsUtil::BinToHex(mRandomBias.toByteArray(),mRandomBias.SIZE_IN_BYTES) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mRandomBias ;
|
return mRandomBias ;
|
||||||
@ -796,7 +791,7 @@ RsGxsNetTunnelVirtualPeerId RsGxsNetTunnelService::locked_makeVirtualPeerId(cons
|
|||||||
{
|
{
|
||||||
assert(RsPeerId::SIZE_IN_BYTES <= Sha1CheckSum::SIZE_IN_BYTES) ;// so that we can build the virtual PeerId from a SHA1 sum.
|
assert(RsPeerId::SIZE_IN_BYTES <= Sha1CheckSum::SIZE_IN_BYTES) ;// so that we can build the virtual PeerId from a SHA1 sum.
|
||||||
|
|
||||||
// We compute sha1( SSL_id | mRandomBias ) and trunk it to 16 bytes in order to compute a RsPeerId
|
// We compute sha1( GroupId | mRandomBias ) and trunk it to 16 bytes in order to compute a RsPeerId
|
||||||
|
|
||||||
Bias20Bytes rb(locked_randomBias());
|
Bias20Bytes rb(locked_randomBias());
|
||||||
|
|
||||||
@ -934,6 +929,7 @@ bool RsGxsNetTunnelService::saveList(bool& cleanup, std::list<RsItem*>& save)
|
|||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mGxsNetTunnelMtx);
|
RS_STACK_MUTEX(mGxsNetTunnelMtx);
|
||||||
it2->mRandomBias = mRandomBias;
|
it2->mRandomBias = mRandomBias;
|
||||||
|
std::cerr << "Saving RsGxsNetTunnel random bias to disc" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
save.push_back(it2) ;
|
save.push_back(it2) ;
|
||||||
@ -952,6 +948,8 @@ bool RsGxsNetTunnelService::loadList(std::list<RsItem *> &load)
|
|||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mGxsNetTunnelMtx);
|
RS_STACK_MUTEX(mGxsNetTunnelMtx);
|
||||||
mRandomBias = rbsi->mRandomBias;
|
mRandomBias = rbsi->mRandomBias;
|
||||||
|
|
||||||
|
std::cerr << "Loaded RsGxsNetTunnel random bias from disc: " << RsUtil::BinToHex(mRandomBias.toByteArray(),mRandomBias.SIZE_IN_BYTES) << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
GXS_NET_TUNNEL_ERROR() << " unknown item in config file: type=" << std::hex << (*it)->PacketId() << std::dec << std::endl;
|
GXS_NET_TUNNEL_ERROR() << " unknown item in config file: type=" << std::hex << (*it)->PacketId() << std::dec << std::endl;
|
||||||
|
@ -65,7 +65,7 @@ void p3ConfigMgr::tick()
|
|||||||
|
|
||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
std::cerr << "p3ConfigMgr::tick() Config Changed - Element: ";
|
std::cerr << "p3ConfigMgr::tick() Config Changed - Element: ";
|
||||||
std::cerr << it->first;
|
std::cerr << *it;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ void p3ConfigMgr::saveConfig()
|
|||||||
{
|
{
|
||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
std::cerr << "p3ConfigMgr::globalSaveConfig() Saving Element: ";
|
std::cerr << "p3ConfigMgr::globalSaveConfig() Saving Element: ";
|
||||||
std::cerr << it->first;
|
std::cerr << *it;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
ok &= (*it)->saveConfiguration();
|
ok &= (*it)->saveConfiguration();
|
||||||
@ -137,7 +137,7 @@ void p3ConfigMgr::loadConfig()
|
|||||||
{
|
{
|
||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
std::cerr << "p3ConfigMgr::loadConfig() Element: ";
|
std::cerr << "p3ConfigMgr::loadConfig() Element: ";
|
||||||
std::cerr << cit->first <<"Dummy Hash: " << dummyHash;
|
std::cerr << *cit <<" Dummy Hash: " << dummyHash;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -125,7 +125,11 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="distantSearchLineEdit"/>
|
<widget class="QLineEdit" name="distantSearchLineEdit">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>Searches a single keyword into the reachable network.</p><p>Objects already provided by friend nodes are not reported.</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>619</width>
|
<width>619</width>
|
||||||
<height>420</height>
|
<height>493</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
@ -38,7 +38,16 @@
|
|||||||
<enum>QFrame::Sunken</enum>
|
<enum>QFrame::Sunken</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<property name="margin">
|
<property name="leftMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
|
@ -487,9 +487,9 @@ static QString getSideString(uint8_t side)
|
|||||||
return side?QObject::tr("Client"):QObject::tr("Server") ;
|
return side?QObject::tr("Client"):QObject::tr("Server") ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString getMasterKeyString(uint8_t *key)
|
static QString getMasterKeyString(const uint8_t *key,uint32_t size)
|
||||||
{
|
{
|
||||||
return QString::fromStdString(RsUtil::BinToHex(key,32,10));
|
return QString::fromStdString(RsUtil::BinToHex(key,size,10));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsNetTunnelsDialog::updateDisplay()
|
void GxsNetTunnelsDialog::updateDisplay()
|
||||||
@ -567,6 +567,7 @@ void GxsNetTunnelsDialog::updateDisplay()
|
|||||||
int ox=5*fact,oy=5*fact ;
|
int ox=5*fact,oy=5*fact ;
|
||||||
|
|
||||||
painter.setPen(QColor::fromRgb(0,0,0)) ;
|
painter.setPen(QColor::fromRgb(0,0,0)) ;
|
||||||
|
painter.drawText(ox+2*cellx,oy+celly,tr("Random Bias: %1").arg(getMasterKeyString(bias.toByteArray(),20))) ; oy += celly ;
|
||||||
painter.drawText(ox+2*cellx,oy+celly,tr("GXS Groups:")) ; oy += celly ;
|
painter.drawText(ox+2*cellx,oy+celly,tr("GXS Groups:")) ; oy += celly ;
|
||||||
|
|
||||||
for(auto it(groups.begin());it!=groups.end();++it)
|
for(auto it(groups.begin());it!=groups.end();++it)
|
||||||
@ -595,7 +596,7 @@ void GxsNetTunnelsDialog::updateDisplay()
|
|||||||
.arg(getVirtualPeerStatusString(it3->second.vpid_status))
|
.arg(getVirtualPeerStatusString(it3->second.vpid_status))
|
||||||
.arg(getSideString(it3->second.side))
|
.arg(getSideString(it3->second.side))
|
||||||
.arg(getLastContactString(it3->second.last_contact))
|
.arg(getLastContactString(it3->second.last_contact))
|
||||||
.arg(getMasterKeyString(it3->second.encryption_master_key))
|
.arg(getMasterKeyString(it3->second.encryption_master_key,32))
|
||||||
),oy+=celly ;
|
),oy+=celly ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user