mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
merged upstream/master
This commit is contained in:
commit
f006146ee4
17 changed files with 344 additions and 113 deletions
|
@ -239,17 +239,21 @@ void RsGxsMsgMetaData::clear()
|
|||
mMsgId.clear();
|
||||
mThreadId.clear();
|
||||
mParentId.clear();
|
||||
mAuthorId.clear();
|
||||
mOrigMsgId.clear();
|
||||
mMsgName.clear();
|
||||
mServiceString.clear();
|
||||
mAuthorId.clear();
|
||||
|
||||
signSet.TlvClear();
|
||||
mMsgName.clear();
|
||||
mPublishTs = 0;
|
||||
mMsgFlags = 0;
|
||||
|
||||
mServiceString.clear();
|
||||
mMsgStatus = 0;
|
||||
mMsgSize = 0;
|
||||
mChildTs = 0;
|
||||
recvTS = 0;
|
||||
mHash.clear();
|
||||
validated = false;
|
||||
}
|
||||
|
||||
bool RsGxsMsgMetaData::serialise(void *data, uint32_t *size)
|
||||
|
|
|
@ -78,15 +78,16 @@ const uint32_t RS_FEED_TYPE_SECURITY = 0x0800;
|
|||
const uint32_t RS_FEED_TYPE_POSTED = 0x1000;
|
||||
const uint32_t RS_FEED_TYPE_SECURITY_IP = 0x2000;
|
||||
|
||||
const uint32_t RS_FEED_ITEM_PEER_CONNECT = RS_FEED_TYPE_PEER | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_PEER_DISCONNECT = RS_FEED_TYPE_PEER | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_PEER_HELLO = RS_FEED_TYPE_PEER | 0x0003;
|
||||
const uint32_t RS_FEED_ITEM_PEER_NEW = RS_FEED_TYPE_PEER | 0x0004;
|
||||
const uint32_t RS_FEED_ITEM_PEER_CONNECT = RS_FEED_TYPE_PEER | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_PEER_DISCONNECT = RS_FEED_TYPE_PEER | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_PEER_HELLO = RS_FEED_TYPE_PEER | 0x0003;
|
||||
const uint32_t RS_FEED_ITEM_PEER_NEW = RS_FEED_TYPE_PEER | 0x0004;
|
||||
const uint32_t RS_FEED_ITEM_PEER_OFFSET = RS_FEED_TYPE_PEER | 0x0005;
|
||||
|
||||
const uint32_t RS_FEED_ITEM_SEC_CONNECT_ATTEMPT = RS_FEED_TYPE_SECURITY | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_SEC_AUTH_DENIED = RS_FEED_TYPE_SECURITY | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_SEC_UNKNOWN_IN = RS_FEED_TYPE_SECURITY | 0x0003;
|
||||
const uint32_t RS_FEED_ITEM_SEC_UNKNOWN_OUT = RS_FEED_TYPE_SECURITY | 0x0004;
|
||||
const uint32_t RS_FEED_ITEM_SEC_CONNECT_ATTEMPT = RS_FEED_TYPE_SECURITY | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_SEC_AUTH_DENIED = RS_FEED_TYPE_SECURITY | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_SEC_UNKNOWN_IN = RS_FEED_TYPE_SECURITY | 0x0003;
|
||||
const uint32_t RS_FEED_ITEM_SEC_UNKNOWN_OUT = RS_FEED_TYPE_SECURITY | 0x0004;
|
||||
const uint32_t RS_FEED_ITEM_SEC_WRONG_SIGNATURE = RS_FEED_TYPE_SECURITY | 0x0005;
|
||||
const uint32_t RS_FEED_ITEM_SEC_BAD_CERTIFICATE = RS_FEED_TYPE_SECURITY | 0x0006;
|
||||
const uint32_t RS_FEED_ITEM_SEC_INTERNAL_ERROR = RS_FEED_TYPE_SECURITY | 0x0007;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define RETROSHARE_RTT_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/retroshare: rsrtt.h
|
||||
* libretroshare/src/retroshare: rsrtt.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
|
@ -58,6 +58,7 @@ class RsRtt
|
|||
virtual ~RsRtt() { return; }
|
||||
|
||||
virtual uint32_t getPongResults(const RsPeerId& id, int n, std::list<RsRttPongResult> &results) = 0;
|
||||
virtual double getMeanOffset(const RsPeerId& id) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -30,11 +30,13 @@
|
|||
#include "pqi/pqibin.h"
|
||||
#include "pqi/pqistore.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "rsserver/p3face.h"
|
||||
|
||||
#include "services/p3rtt.h"
|
||||
#include "rsitems/rsrttitems.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <math.h>
|
||||
|
||||
/****
|
||||
* #define DEBUG_RTT 1
|
||||
|
@ -358,7 +360,26 @@ int p3rtt::storePongResult(const RsPeerId& id, uint32_t counter, double recv_ts,
|
|||
peerInfo->mPongResults.pop_front();
|
||||
}
|
||||
|
||||
/* should do calculations */
|
||||
//Wait at least 20 pongs before compute mean time offset
|
||||
if(peerInfo->mPongResults.size() > 20)
|
||||
{
|
||||
double mean = 0;
|
||||
for(std::list<RsRttPongResult>::const_iterator prIt = peerInfo->mPongResults.begin(), end = peerInfo->mPongResults.end(); prIt != end; ++ prIt)
|
||||
{
|
||||
mean += prIt->mOffset;
|
||||
}
|
||||
peerInfo->mCurrentMeanOffset = mean / peerInfo->mPongResults.size();
|
||||
if(fabs(peerInfo->mCurrentMeanOffset) > 120)
|
||||
{
|
||||
p3Notify *notify = RsServer::notify();
|
||||
if (notify)
|
||||
{
|
||||
//notify->AddPopupMessage(RS_POPUP_OFFSET, eerInfo->mId.toStdString(),"", "Time Offset: ");
|
||||
notify->AddFeedItem(RS_FEED_ITEM_PEER_OFFSET, peerInfo->mId.toStdString());
|
||||
}
|
||||
std::cerr << "(WW) Peer:" << peerInfo->mId << " get time offset more than two minutes with you!!!" << std::endl;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -379,7 +400,16 @@ uint32_t p3rtt::getPongResults(const RsPeerId& id, int n, std::list<RsRttPongRes
|
|||
return i ;
|
||||
}
|
||||
|
||||
double p3rtt::getMeanOffset(const RsPeerId &id)
|
||||
{
|
||||
RsStackMutex stack(mRttMtx); /****** LOCKED MUTEX *******/
|
||||
|
||||
RttPeerInfo *peer = locked_GetPeerInfo(id);
|
||||
if(peer)
|
||||
return peer->mCurrentMeanOffset;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
RttPeerInfo *p3rtt::locked_GetPeerInfo(const RsPeerId& id)
|
||||
{
|
||||
|
|
|
@ -46,6 +46,7 @@ class RttPeerInfo
|
|||
double mCurrentPingTS;
|
||||
double mCurrentPingCounter;
|
||||
bool mCurrentPongRecvd;
|
||||
double mCurrentMeanOffset;
|
||||
|
||||
uint32_t mLostPongs;
|
||||
uint32_t mSentPings;
|
||||
|
@ -69,6 +70,7 @@ virtual RsServiceInfo getServiceInfo();
|
|||
/***** overloaded from rsRtt *****/
|
||||
|
||||
virtual uint32_t getPongResults(const RsPeerId& id, int n, std::list<RsRttPongResult> &results);
|
||||
virtual double getMeanOffset(const RsPeerId &id);
|
||||
|
||||
/***** overloaded from p3Service *****/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue