mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
--- Merging r4780 through r4795 from /retroshare/branches/v0.5-dhtmods
Changes to support Relays. * added p3BitDht::addKnownNode() so that DhtIds can be used instead of SslIds. * switched from bdStdDht() functions to use bdModDht(). * made DhtFunctions a class variable. * added function to modify NodePerBucket() parameter. * Bugfix for LinkType. peerConnectAddress.flags was not initialised. * Extra debugging of LinkType data (use LINKMGR_DEBUG_LINKTYPE). * cleaned up udprelay output. * Added Compile Rules to libretroshare.pro for building LocalNet Testing Version. (testnetwork) * Added NumQueryNodes() function to bdDhtFunctions. * Switched bdquery.cc to use bdNumQueryNodes(). * Extended bdStdDht class to bdModDht to allow NodesPerBucket to be modified. * Fixed up Connection Fail Callback for Relay Servers. * Added Extra debugging for Proxy Connections. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4796 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
commit
d138dde66c
@ -2148,7 +2148,7 @@ int bdConnectManager::recvedConnectionRequest(bdId *id, bdId *srcConnAddr, bdId
|
|||||||
bool areProxy = (srcConnAddr->id == id->id);
|
bool areProxy = (srcConnAddr->id == id->id);
|
||||||
if (areProxy)
|
if (areProxy)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_NODE_CONNECTION
|
#ifdef DEBUG_PROXY_CONNECTION
|
||||||
std::cerr << "bdConnectManager::recvedConnectionRequest() We are MID Point for Proxy / Relay Connection.";
|
std::cerr << "bdConnectManager::recvedConnectionRequest() We are MID Point for Proxy / Relay Connection.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -2170,7 +2170,7 @@ int bdConnectManager::recvedConnectionRequest(bdId *id, bdId *srcConnAddr, bdId
|
|||||||
|
|
||||||
if (mNodeSpace->find_node(&(destConnAddr->id), numNodes, matchingIds, with_flag))
|
if (mNodeSpace->find_node(&(destConnAddr->id), numNodes, matchingIds, with_flag))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_NODE_CONNECTION
|
#ifdef DEBUG_PROXY_CONNECTION
|
||||||
std::cerr << "bdConnectManager::recvedConnectionRequest() Found Suitable Destination Addr";
|
std::cerr << "bdConnectManager::recvedConnectionRequest() Found Suitable Destination Addr";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -2188,7 +2188,7 @@ int bdConnectManager::recvedConnectionRequest(bdId *id, bdId *srcConnAddr, bdId
|
|||||||
|
|
||||||
if (proxyOk)
|
if (proxyOk)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_NODE_CONNECTION
|
#ifdef DEBUG_PROXY_CONNECTION
|
||||||
std::cerr << "bdConnectManager::recvedConnectionRequest() Proxy Addr Ok: ";
|
std::cerr << "bdConnectManager::recvedConnectionRequest() Proxy Addr Ok: ";
|
||||||
bdStdPrintId(std::cerr, destConnAddr);
|
bdStdPrintId(std::cerr, destConnAddr);
|
||||||
std::cerr << "asking for AUTH to continue";
|
std::cerr << "asking for AUTH to continue";
|
||||||
@ -2215,7 +2215,7 @@ int bdConnectManager::recvedConnectionRequest(bdId *id, bdId *srcConnAddr, bdId
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* clean up connection... its not going to work */
|
/* clean up connection... its not going to work */
|
||||||
#ifdef DEBUG_NODE_CONNECTION
|
#ifdef DEBUG_PROXY_CONNECTION
|
||||||
std::cerr << "bdConnectManager::recvedConnectionRequest() WARNING No Proxy Addr, Shutting Connect Attempt";
|
std::cerr << "bdConnectManager::recvedConnectionRequest() WARNING No Proxy Addr, Shutting Connect Attempt";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -2227,18 +2227,25 @@ int bdConnectManager::recvedConnectionRequest(bdId *id, bdId *srcConnAddr, bdId
|
|||||||
int param = 0;
|
int param = 0;
|
||||||
mPub->send_connect_msg(id, msgtype, srcConnAddr, destConnAddr, mode, param, status);
|
mPub->send_connect_msg(id, msgtype, srcConnAddr, destConnAddr, mode, param, status);
|
||||||
|
|
||||||
/* remove connection */
|
|
||||||
bdConnectManager::cleanConnectionBySender(id, srcConnAddr, destConnAddr);
|
|
||||||
|
|
||||||
/* WILL NEED CALLBACK FOR FAILED PROXY ATTEMPT - TO SUPPORT RELAYS PROPERLY
|
/* WILL NEED CALLBACK FOR FAILED PROXY ATTEMPT - TO SUPPORT RELAYS PROPERLY
|
||||||
* NODE needs to know PEERS to potentially WHITELIST!
|
* NODE needs to know PEERS to potentially WHITELIST!
|
||||||
*/
|
*/
|
||||||
if (mRelayMode == BITDHT_RELAYS_SERVER)
|
if (mRelayMode == BITDHT_RELAYS_SERVER)
|
||||||
{
|
{
|
||||||
callbackConnect(&(conn->mSrcId),&(conn->mProxyId),&(conn->mDestId),
|
#ifdef DEBUG_PROXY_CONNECTION
|
||||||
conn->mMode, conn->mPoint, param, BITDHT_CONNECT_CB_AUTH,
|
std::cerr << "bdConnectManager::recvedConnectionRequest() In RelayServer Mode, doing FAIL callbackConnect()";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bdId proxyId;
|
||||||
|
proxyId.id = mOwnId;
|
||||||
|
callbackConnect(srcConnAddr, &proxyId, destConnAddr, mode, point, param, BITDHT_CONNECT_CB_AUTH,
|
||||||
BITDHT_CONNECT_ERROR_NOADDRESS);
|
BITDHT_CONNECT_ERROR_NOADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* remove connection */
|
||||||
|
bdConnectManager::cleanConnectionBySender(id, srcConnAddr, destConnAddr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -88,7 +88,8 @@ class bdDhtFunctions
|
|||||||
// bdDhtFunctions();
|
// bdDhtFunctions();
|
||||||
/* setup variables */
|
/* setup variables */
|
||||||
virtual uint16_t bdNumBuckets() = 0;
|
virtual uint16_t bdNumBuckets() = 0;
|
||||||
virtual uint16_t bdNodesPerBucket() = 0; /* used for query + bdspace */
|
virtual uint16_t bdNodesPerBucket() = 0; /* used for bdspace */
|
||||||
|
virtual uint16_t bdNumQueryNodes() = 0; /* used for queries */
|
||||||
virtual uint16_t bdBucketBitSize() = 0;
|
virtual uint16_t bdBucketBitSize() = 0;
|
||||||
|
|
||||||
virtual int bdDistance(const bdNodeId *n1, const bdNodeId *n2, bdMetric *metric) = 0;
|
virtual int bdDistance(const bdNodeId *n1, const bdNodeId *n2, bdMetric *metric) = 0;
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
#define EXPECTED_REPLY 10 // Speed up queries
|
#define EXPECTED_REPLY 10 // Speed up queries
|
||||||
#define QUERY_IDLE_RETRY_PEER_PERIOD 300 // 5min = (mFns->bdNodesPerBucket() * 30)
|
#define QUERY_IDLE_RETRY_PEER_PERIOD 300 // 5min = (mFns->bdNumQueryNodes() * 30)
|
||||||
#define MAX_QUERY_IDLE_PERIOD 900 // 15min.
|
#define MAX_QUERY_IDLE_PERIOD 900 // 15min.
|
||||||
|
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ bdQuery::bdQuery(const bdNodeId *id, std::list<bdId> &startList, uint32_t queryF
|
|||||||
mQueryFlags = queryFlags;
|
mQueryFlags = queryFlags;
|
||||||
mQueryTS = now;
|
mQueryTS = now;
|
||||||
mSearchTime = 0;
|
mSearchTime = 0;
|
||||||
mClosestListSize = (int) (1.5 * mFns->bdNodesPerBucket());
|
mClosestListSize = (int) (1.5 * mFns->bdNumQueryNodes());
|
||||||
mPotPeerCleanTS = now;
|
mPotPeerCleanTS = now;
|
||||||
|
|
||||||
mQueryIdlePeerRetryPeriod = QUERY_IDLE_RETRY_PEER_PERIOD;
|
mQueryIdlePeerRetryPeriod = QUERY_IDLE_RETRY_PEER_PERIOD;
|
||||||
@ -174,7 +174,7 @@ int bdQuery::nextQuery(bdId &id, bdNodeId &targetNodeId)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (((it->second.mLastRecvTime == 0) || (now - it->second.mLastRecvTime < EXPECTED_REPLY)) &&
|
if (((it->second.mLastRecvTime == 0) || (now - it->second.mLastRecvTime < EXPECTED_REPLY)) &&
|
||||||
(i < mFns->bdNodesPerBucket()))
|
(i < mFns->bdNumQueryNodes()))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_QUERY
|
#ifdef DEBUG_QUERY
|
||||||
fprintf(stderr, "NextQuery() Never Received @Idx(%d) notFinished = true: ", i);
|
fprintf(stderr, "NextQuery() Never Received @Idx(%d) notFinished = true: ", i);
|
||||||
@ -231,7 +231,7 @@ int bdQuery::nextQuery(bdId &id, bdNodeId &targetNodeId)
|
|||||||
#endif
|
#endif
|
||||||
/* fall through and stop */
|
/* fall through and stop */
|
||||||
}
|
}
|
||||||
else if ((mClosest.size() < mFns->bdNodesPerBucket()) || (notFinished))
|
else if ((mClosest.size() < mFns->bdNumQueryNodes()) || (notFinished))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_QUERY
|
#ifdef DEBUG_QUERY
|
||||||
fprintf(stderr, "NextQuery() notFinished | !size(): Query not finished / No Query\n");
|
fprintf(stderr, "NextQuery() notFinished | !size(): Query not finished / No Query\n");
|
||||||
@ -510,7 +510,7 @@ int bdQuery::worthyPotentialPeer(const bdId *id)
|
|||||||
eit = mClosest.upper_bound(dist);
|
eit = mClosest.upper_bound(dist);
|
||||||
|
|
||||||
/* check if outside range, & bucket is full */
|
/* check if outside range, & bucket is full */
|
||||||
if ((sit == mClosest.end()) && (mClosest.size() >= mFns->bdNodesPerBucket()))
|
if ((sit == mClosest.end()) && (mClosest.size() >= mFns->bdNumQueryNodes()))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_QUERY
|
#ifdef DEBUG_QUERY
|
||||||
fprintf(stderr, "Peer to far away for Potential\n");
|
fprintf(stderr, "Peer to far away for Potential\n");
|
||||||
@ -604,7 +604,7 @@ int bdQuery::updatePotentialPeer(const bdId *id, uint32_t mode, uint32_t addType
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* check if outside range, & bucket is full */
|
/* check if outside range, & bucket is full */
|
||||||
if ((sit == mPotentialPeers.end()) && (mPotentialPeers.size() >= mFns->bdNodesPerBucket()))
|
if ((sit == mPotentialPeers.end()) && (mPotentialPeers.size() >= mFns->bdNumQueryNodes()))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_QUERY
|
#ifdef DEBUG_QUERY
|
||||||
fprintf(stderr, "Peer to far away for Potential\n");
|
fprintf(stderr, "Peer to far away for Potential\n");
|
||||||
@ -640,7 +640,7 @@ int bdQuery::updatePotentialPeer(const bdId *id, uint32_t mode, uint32_t addType
|
|||||||
int bdQuery::trimPotentialPeers_FixedLength()
|
int bdQuery::trimPotentialPeers_FixedLength()
|
||||||
{
|
{
|
||||||
/* trim it back */
|
/* trim it back */
|
||||||
while(mPotentialPeers.size() > (uint32_t) (mFns->bdNodesPerBucket()))
|
while(mPotentialPeers.size() > (uint32_t) (mFns->bdNumQueryNodes()))
|
||||||
{
|
{
|
||||||
std::multimap<bdMetric, bdPeer>::iterator it;
|
std::multimap<bdMetric, bdPeer>::iterator it;
|
||||||
it = mPotentialPeers.end();
|
it = mPotentialPeers.end();
|
||||||
@ -658,7 +658,7 @@ int bdQuery::trimPotentialPeers_FixedLength()
|
|||||||
|
|
||||||
int bdQuery::trimPotentialPeers_toClosest()
|
int bdQuery::trimPotentialPeers_toClosest()
|
||||||
{
|
{
|
||||||
if (mPotentialPeers.size() <= (uint32_t) (mFns->bdNodesPerBucket()))
|
if (mPotentialPeers.size() <= (uint32_t) (mFns->bdNumQueryNodes()))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
std::multimap<bdMetric, bdPeer>::reverse_iterator it;
|
std::multimap<bdMetric, bdPeer>::reverse_iterator it;
|
||||||
@ -666,7 +666,7 @@ int bdQuery::trimPotentialPeers_toClosest()
|
|||||||
bdMetric lastClosest = it->first;
|
bdMetric lastClosest = it->first;
|
||||||
|
|
||||||
/* trim it back */
|
/* trim it back */
|
||||||
while(mPotentialPeers.size() > (uint32_t) (mFns->bdNodesPerBucket()))
|
while(mPotentialPeers.size() > (uint32_t) (mFns->bdNumQueryNodes()))
|
||||||
{
|
{
|
||||||
std::multimap<bdMetric, bdPeer>::iterator it;
|
std::multimap<bdMetric, bdPeer>::iterator it;
|
||||||
it = mPotentialPeers.end();
|
it = mPotentialPeers.end();
|
||||||
|
@ -256,10 +256,16 @@ uint16_t bdStdDht::bdNumBuckets()
|
|||||||
return BITDHT_STANDARD_N_BUCKETS;
|
return BITDHT_STANDARD_N_BUCKETS;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t bdStdDht::bdNodesPerBucket() /* used for query + bdspace */
|
uint16_t bdStdDht::bdNodesPerBucket() /* used for bdspace */
|
||||||
{
|
{
|
||||||
return BITDHT_STANDARD_BUCKET_SIZE;
|
return BITDHT_STANDARD_BUCKET_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t bdStdDht::bdNumQueryNodes() /* used for queries */
|
||||||
|
{
|
||||||
|
return BITDHT_STANDARD_BUCKET_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t bdStdDht::bdBucketBitSize()
|
uint16_t bdStdDht::bdBucketBitSize()
|
||||||
{
|
{
|
||||||
return BITDHT_STANDARD_BUCKET_SIZE_BITS;
|
return BITDHT_STANDARD_BUCKET_SIZE_BITS;
|
||||||
@ -310,4 +316,18 @@ void bdStdDht::bdPrintNodeId(std::ostream &out, const bdNodeId *a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************/
|
||||||
|
|
||||||
|
void bdModDht::setNodesPerBucket(uint16_t nodesPerBucket)
|
||||||
|
{
|
||||||
|
mNodesPerBucket = nodesPerBucket;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t bdModDht::bdNodesPerBucket() /* used for bdspace */
|
||||||
|
{
|
||||||
|
return mNodesPerBucket;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,7 +69,8 @@ class bdStdDht: public bdDhtFunctions
|
|||||||
bdStdDht();
|
bdStdDht();
|
||||||
/* setup variables */
|
/* setup variables */
|
||||||
virtual uint16_t bdNumBuckets();
|
virtual uint16_t bdNumBuckets();
|
||||||
virtual uint16_t bdNodesPerBucket(); /* used for query + bdspace */
|
virtual uint16_t bdNodesPerBucket(); /* used for bdspace */
|
||||||
|
virtual uint16_t bdNumQueryNodes(); /* used for queries */
|
||||||
virtual uint16_t bdBucketBitSize();
|
virtual uint16_t bdBucketBitSize();
|
||||||
|
|
||||||
virtual int bdDistance(const bdNodeId *n1, const bdNodeId *n2, bdMetric *metric);
|
virtual int bdDistance(const bdNodeId *n1, const bdNodeId *n2, bdMetric *metric);
|
||||||
@ -86,6 +87,16 @@ virtual void bdPrintNodeId(std::ostream &out, const bdNodeId *a);
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class bdModDht: public bdStdDht
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void setNodesPerBucket(uint16_t nodesPerBucket);
|
||||||
|
virtual uint16_t bdNodesPerBucket(); /* used for bdspace */
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint16_t mNodesPerBucket;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -120,7 +120,8 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, p3NetMgr *nm,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* standard dht behaviour */
|
/* standard dht behaviour */
|
||||||
bdDhtFunctions *stdfns = new bdStdDht();
|
//bdDhtFunctions *stdfns = new bdStdDht();
|
||||||
|
mDhtFns = new bdModDht();
|
||||||
|
|
||||||
#ifdef DEBUG_BITDHT
|
#ifdef DEBUG_BITDHT
|
||||||
std::cerr << "p3BitDht() startup ... creating UdpBitDht";
|
std::cerr << "p3BitDht() startup ... creating UdpBitDht";
|
||||||
@ -128,7 +129,7 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, p3NetMgr *nm,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* create dht */
|
/* create dht */
|
||||||
mUdpBitDht = new UdpBitDht(udpstack, &mOwnDhtId, dhtVersion, bootstrapfile, stdfns);
|
mUdpBitDht = new UdpBitDht(udpstack, &mOwnDhtId, dhtVersion, bootstrapfile, mDhtFns);
|
||||||
udpstack->addReceiver(mUdpBitDht);
|
udpstack->addReceiver(mUdpBitDht);
|
||||||
|
|
||||||
/* setup callback to here */
|
/* setup callback to here */
|
||||||
@ -170,6 +171,12 @@ void p3BitDht::setupPeerSharer(pqiNetAssistPeerShare *sharer)
|
|||||||
mPeerSharer = sharer;
|
mPeerSharer = sharer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Tweak the DHT Parameters */
|
||||||
|
void p3BitDht::modifyNodesPerBucket(uint16_t count)
|
||||||
|
{
|
||||||
|
bdModDht *modFns = (bdModDht *) mDhtFns;
|
||||||
|
modFns->setNodesPerBucket(count);
|
||||||
|
}
|
||||||
|
|
||||||
/* Support for Outsourced Relay Handling */
|
/* Support for Outsourced Relay Handling */
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ virtual std::string getUdpAddressString();
|
|||||||
|
|
||||||
void setupConnectBits(UdpStunner *dhtStunner, UdpStunner *proxyStunner, UdpRelayReceiver *relay);
|
void setupConnectBits(UdpStunner *dhtStunner, UdpStunner *proxyStunner, UdpRelayReceiver *relay);
|
||||||
void setupPeerSharer(pqiNetAssistPeerShare *sharer);
|
void setupPeerSharer(pqiNetAssistPeerShare *sharer);
|
||||||
|
void modifyNodesPerBucket(uint16_t count);
|
||||||
|
|
||||||
void start(); /* starts up the bitdht thread */
|
void start(); /* starts up the bitdht thread */
|
||||||
|
|
||||||
@ -322,6 +322,7 @@ int removePeer(const std::string pid);
|
|||||||
|
|
||||||
// Can be used externally too.
|
// Can be used externally too.
|
||||||
int calculateNodeId(const std::string pid, bdNodeId *id);
|
int calculateNodeId(const std::string pid, bdNodeId *id);
|
||||||
|
int addKnownNode(const bdId *id, uint32_t flags);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -345,6 +346,8 @@ int removeTranslation_locked(const std::string pid);
|
|||||||
|
|
||||||
pqiNetAssistPeerShare *mPeerSharer;
|
pqiNetAssistPeerShare *mPeerSharer;
|
||||||
|
|
||||||
|
bdDhtFunctions *mDhtFns;
|
||||||
|
|
||||||
RsMutex dhtMtx;
|
RsMutex dhtMtx;
|
||||||
|
|
||||||
|
|
||||||
|
@ -276,6 +276,49 @@ int p3BitDht::addKnownPeer(const std::string &pid, const struct sockaddr_in &add
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Total duplicate of above function - can't be helped, should merge somehow */
|
||||||
|
int p3BitDht::addKnownNode(const bdId *id, uint32_t flags)
|
||||||
|
{
|
||||||
|
int bdflags = 0;
|
||||||
|
|
||||||
|
switch(flags & NETASSIST_KNOWN_PEER_TYPE_MASK)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case NETASSIST_KNOWN_PEER_WHITELIST:
|
||||||
|
bdflags = BITDHT_PEER_STATUS_DHT_WHITELIST;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case NETASSIST_KNOWN_PEER_FOF:
|
||||||
|
bdflags = BITDHT_PEER_STATUS_DHT_FOF;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case NETASSIST_KNOWN_PEER_FRIEND:
|
||||||
|
bdflags = BITDHT_PEER_STATUS_DHT_FRIEND;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case NETASSIST_KNOWN_PEER_RELAY:
|
||||||
|
bdflags = BITDHT_PEER_STATUS_DHT_RELAY_SERVER;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case NETASSIST_KNOWN_PEER_SELF:
|
||||||
|
bdflags = BITDHT_PEER_STATUS_DHT_SELF;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & NETASSIST_KNOWN_PEER_ONLINE)
|
||||||
|
{
|
||||||
|
bdflags |= BD_FRIEND_ENTRY_ONLINE;
|
||||||
|
}
|
||||||
|
|
||||||
|
mUdpBitDht->updateKnownPeer(id, 0, bdflags);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
int p3BitDht::addFriend(const std::string pid)
|
int p3BitDht::addFriend(const std::string pid)
|
||||||
|
@ -124,6 +124,9 @@ uint32_t p3BitDht::getRelayMode()
|
|||||||
|
|
||||||
int p3BitDht::setRelayMode(uint32_t mode)
|
int p3BitDht::setRelayMode(uint32_t mode)
|
||||||
{
|
{
|
||||||
|
std::cerr << "p3BitDht::setRelayMode(" << mode << ")";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
if (mode & RSDHT_RELAY_ENABLED)
|
if (mode & RSDHT_RELAY_ENABLED)
|
||||||
{
|
{
|
||||||
mUdpBitDht->ConnectionOptions(
|
mUdpBitDht->ConnectionOptions(
|
||||||
|
@ -31,21 +31,26 @@ release {
|
|||||||
|
|
||||||
|
|
||||||
testnetwork {
|
testnetwork {
|
||||||
#DEFINES *= PQI_DISABLE_UDP
|
# used in rsserver/rsinit.cc Enabled Port Restrictions, and makes Proxy Port next to Dht Port.
|
||||||
DEFINES *= PQI_DISABLE_TUNNEL
|
DEFINES *= LOCALNET_TESTING
|
||||||
|
|
||||||
# DEFINES *= AUTHSSL_DEBUG GPG_DEBUG
|
# used in tcponudp/udprelay.cc Debugging Info for Relays.
|
||||||
# DEFINES *= CONN_DEBUG
|
DEFINES *= DEBUG_UDP_RELAY
|
||||||
# DEFINES *= P3DISC_DEBUG
|
|
||||||
|
|
||||||
# DEFINES *= PGRP_DEBUG
|
# used in tcponudp/udpstunner.[h | cc] enables local stun (careful - modifies class variables).
|
||||||
# DEFINES *= PERSON_DEBUG
|
DEFINES *= UDPSTUN_ALLOW_LOCALNET
|
||||||
|
|
||||||
#DEFINES *= DEBUG_UDP_SORTER DEBUG_UDP_LAYER EXTADDRSEARCH_DEBUG
|
# used in pqi/p3linkmgr.cc prints out extra debug.
|
||||||
|
DEFINES *= LINKMGR_DEBUG_LINKTYPE
|
||||||
|
|
||||||
|
# used in dht/connectstatebox to reduce connection times and display debug.
|
||||||
|
# DEFINES *= TESTING_PERIODS
|
||||||
|
# DEFINES *= DEBUG_CONNECTBOX
|
||||||
|
|
||||||
QMAKE_CXXFLAGS -= -fomit-frame-pointer
|
QMAKE_CXXFLAGS -= -fomit-frame-pointer
|
||||||
QMAKE_CXXFLAGS -= -O2
|
QMAKE_CXXFLAGS -= -O2
|
||||||
QMAKE_CXXFLAGS *= -g -fno-omit-frame-pointer
|
QMAKE_CXXFLAGS *= -g -fno-omit-frame-pointer
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ const int p3connectzone = 3431;
|
|||||||
* #define LINKMGR_DEBUG 1
|
* #define LINKMGR_DEBUG 1
|
||||||
* #define LINKMGR_DEBUG_CONNFAIL 1
|
* #define LINKMGR_DEBUG_CONNFAIL 1
|
||||||
* #define LINKMGR_DEBUG_ACTIONS 1
|
* #define LINKMGR_DEBUG_ACTIONS 1
|
||||||
|
* #define LINKMGR_DEBUG_LINKTYPE 1
|
||||||
***/
|
***/
|
||||||
|
|
||||||
/****
|
/****
|
||||||
@ -85,7 +86,7 @@ const uint32_t P3CONNMGR_UDP_DEFAULT_PERIOD = 30; // this represents how long i
|
|||||||
void printConnectState(std::ostream &out, peerConnectState &peer);
|
void printConnectState(std::ostream &out, peerConnectState &peer);
|
||||||
|
|
||||||
peerConnectAddress::peerConnectAddress()
|
peerConnectAddress::peerConnectAddress()
|
||||||
:delay(0), period(0), type(0), ts(0)
|
:delay(0), period(0), type(0), flags(0), ts(0)
|
||||||
{
|
{
|
||||||
sockaddr_clear(&addr);
|
sockaddr_clear(&addr);
|
||||||
}
|
}
|
||||||
@ -683,71 +684,113 @@ bool p3LinkMgrIMPL::connectAttempt(const std::string &id, struct sockaddr_in &ra
|
|||||||
#define TRICKLE_LIMIT 2001 // 2kb
|
#define TRICKLE_LIMIT 2001 // 2kb
|
||||||
#define LOW_BANDWIDTH_LIMIT 5001 // 5kb
|
#define LOW_BANDWIDTH_LIMIT 5001 // 5kb
|
||||||
|
|
||||||
|
#ifdef LINKMGR_DEBUG_LINKTYPE
|
||||||
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() Setting up LinkType" << std::endl;
|
||||||
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() type = " << type << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
it->second.linkType = 0;
|
it->second.linkType = 0;
|
||||||
if (type & RS_NET_CONN_TCP_ALL)
|
if (type & RS_NET_CONN_TCP_ALL)
|
||||||
{
|
{
|
||||||
|
#ifdef LINKMGR_DEBUG_LINKTYPE
|
||||||
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() type & TCP_ALL => TCP_UNKNOWN" << std::endl;
|
||||||
|
#endif
|
||||||
it->second.linkType |= RS_NET_CONN_TRANS_TCP_UNKNOWN;
|
it->second.linkType |= RS_NET_CONN_TRANS_TCP_UNKNOWN;
|
||||||
}
|
}
|
||||||
else if (type & RS_NET_CONN_UDP_ALL)
|
else if (type & RS_NET_CONN_UDP_ALL)
|
||||||
{
|
{
|
||||||
if (flags & RS_CB_FLAG_MODE_UDP_DIRECT)
|
if (flags & RS_CB_FLAG_MODE_UDP_DIRECT)
|
||||||
{
|
{
|
||||||
|
#ifdef LINKMGR_DEBUG_LINKTYPE
|
||||||
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() type & UDP_ALL && flags & DIRECT => UDP_DIRECT" << std::endl;
|
||||||
|
#endif
|
||||||
it->second.linkType |= RS_NET_CONN_TRANS_UDP_DIRECT;
|
it->second.linkType |= RS_NET_CONN_TRANS_UDP_DIRECT;
|
||||||
}
|
}
|
||||||
else if (flags & RS_CB_FLAG_MODE_UDP_PROXY)
|
else if (flags & RS_CB_FLAG_MODE_UDP_PROXY)
|
||||||
{
|
{
|
||||||
|
#ifdef LINKMGR_DEBUG_LINKTYPE
|
||||||
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() type & UDP_ALL && flags & PROXY => UDP_PROXY" << std::endl;
|
||||||
|
#endif
|
||||||
it->second.linkType |= RS_NET_CONN_TRANS_UDP_PROXY;
|
it->second.linkType |= RS_NET_CONN_TRANS_UDP_PROXY;
|
||||||
}
|
}
|
||||||
else if (flags & RS_CB_FLAG_MODE_UDP_RELAY)
|
else if (flags & RS_CB_FLAG_MODE_UDP_RELAY)
|
||||||
{
|
{
|
||||||
|
#ifdef LINKMGR_DEBUG_LINKTYPE
|
||||||
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() type & UDP_ALL && flags & RELAY => UDP_RELAY" << std::endl;
|
||||||
|
#endif
|
||||||
it->second.linkType |= RS_NET_CONN_TRANS_UDP_RELAY;
|
it->second.linkType |= RS_NET_CONN_TRANS_UDP_RELAY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef LINKMGR_DEBUG_LINKTYPE
|
||||||
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() type & UDP_ALL && else => UDP_UNKNOWN" << std::endl;
|
||||||
|
#endif
|
||||||
it->second.linkType |= RS_NET_CONN_TRANS_UDP_UNKNOWN;
|
it->second.linkType |= RS_NET_CONN_TRANS_UDP_UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type & RS_NET_CONN_TUNNEL)
|
else if (type & RS_NET_CONN_TUNNEL)
|
||||||
{
|
{
|
||||||
|
#ifdef LINKMGR_DEBUG_LINKTYPE
|
||||||
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() type & TUNNEL => TUNNEL" << std::endl;
|
||||||
|
#endif
|
||||||
it->second.linkType |= RS_NET_CONN_TRANS_TUNNEL;
|
it->second.linkType |= RS_NET_CONN_TRANS_TUNNEL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef LINKMGR_DEBUG_LINKTYPE
|
||||||
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() else => TRANS_UNKNOWN" << std::endl;
|
||||||
|
#endif
|
||||||
it->second.linkType |= RS_NET_CONN_TRANS_UNKNOWN;
|
it->second.linkType |= RS_NET_CONN_TRANS_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & RS_CB_FLAG_MODE_UDP_RELAY)
|
if ((type & RS_NET_CONN_UDP_ALL) && (flags & RS_CB_FLAG_MODE_UDP_RELAY))
|
||||||
{
|
{
|
||||||
if (bandwidth < TRICKLE_LIMIT)
|
if (bandwidth < TRICKLE_LIMIT)
|
||||||
{
|
{
|
||||||
|
#ifdef LINKMGR_DEBUG_LINKTYPE
|
||||||
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() flags & RELAY && band < TRICKLE => SPEED_TRICKLE" << std::endl;
|
||||||
|
#endif
|
||||||
it->second.linkType |= RS_NET_CONN_SPEED_TRICKLE;
|
it->second.linkType |= RS_NET_CONN_SPEED_TRICKLE;
|
||||||
}
|
}
|
||||||
else if (bandwidth < LOW_BANDWIDTH_LIMIT)
|
else if (bandwidth < LOW_BANDWIDTH_LIMIT)
|
||||||
{
|
{
|
||||||
|
#ifdef LINKMGR_DEBUG_LINKTYPE
|
||||||
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() flags & RELAY && band < LOW => SPEED_LOW" << std::endl;
|
||||||
|
#endif
|
||||||
it->second.linkType |= RS_NET_CONN_SPEED_LOW;
|
it->second.linkType |= RS_NET_CONN_SPEED_LOW;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef LINKMGR_DEBUG_LINKTYPE
|
||||||
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() flags & RELAY && else => SPEED_NORMAL" << std::endl;
|
||||||
|
#endif
|
||||||
it->second.linkType |= RS_NET_CONN_SPEED_NORMAL;
|
it->second.linkType |= RS_NET_CONN_SPEED_NORMAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef LINKMGR_DEBUG_LINKTYPE
|
||||||
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() else => SPEED_NORMAL" << std::endl;
|
||||||
|
#endif
|
||||||
it->second.linkType |= RS_NET_CONN_SPEED_NORMAL;
|
it->second.linkType |= RS_NET_CONN_SPEED_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t connType = mPeerMgr->getConnectionType(id);
|
uint32_t connType = mPeerMgr->getConnectionType(id);
|
||||||
it->second.linkType |= connType;
|
it->second.linkType |= connType;
|
||||||
|
|
||||||
/********* Setup LinkType parameters **********/
|
#ifdef LINKMGR_DEBUG_LINKTYPE
|
||||||
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() connType: " << connType << std::endl;
|
||||||
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() final LinkType: " << it->second.linkType << std::endl;
|
||||||
|
|
||||||
|
|
||||||
// TEMP DEBUG.
|
|
||||||
std::cerr << "p3LinkMgrIMPL::connectAttempt() found an address: id: " << id << std::endl;
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() found an address: id: " << id << std::endl;
|
||||||
std::cerr << " laddr: " << rs_inet_ntoa(raddr.sin_addr) << " lport: " << ntohs(raddr.sin_port) << " delay: " << delay << " period: " << period;
|
std::cerr << " laddr: " << rs_inet_ntoa(raddr.sin_addr) << " lport: " << ntohs(raddr.sin_port) << " delay: " << delay << " period: " << period;
|
||||||
std::cerr << " type: " << type << std::endl;
|
std::cerr << " type: " << type << std::endl;
|
||||||
std::cerr << "p3LinkMgrIMPL::connectAttempt() set LinkType to: " << it->second.linkType << std::endl;
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() set LinkType to: " << it->second.linkType << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/********* Setup LinkType parameters **********/
|
||||||
|
|
||||||
#ifdef LINKMGR_DEBUG
|
#ifdef LINKMGR_DEBUG
|
||||||
std::cerr << "p3LinkMgrIMPL::connectAttempt() found an address: id: " << id << std::endl;
|
std::cerr << "p3LinkMgrIMPL::connectAttempt() found an address: id: " << id << std::endl;
|
||||||
|
@ -31,8 +31,6 @@
|
|||||||
* #define DEBUG_UDP_RELAY_PKTS 1
|
* #define DEBUG_UDP_RELAY_PKTS 1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#define DEBUG_UDP_RELAY 1
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG_UDP_RELAY
|
#ifdef DEBUG_UDP_RELAY
|
||||||
// DEBUG FUNCTION
|
// DEBUG FUNCTION
|
||||||
@ -334,6 +332,10 @@ int UdpRelayReceiver::removeUdpRelay(UdpRelayAddrSet *addrSet)
|
|||||||
{
|
{
|
||||||
RsStackMutex stack(relayMtx); /********** LOCK MUTEX *********/
|
RsStackMutex stack(relayMtx); /********** LOCK MUTEX *********/
|
||||||
|
|
||||||
|
#ifdef DEBUG_UDP_RELAY
|
||||||
|
std::cerr << "UdpRelayReceiver::removeUdpRelay() :" << *addrSet << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
return removeUdpRelay_relayLocked(addrSet);
|
return removeUdpRelay_relayLocked(addrSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,6 +386,10 @@ int UdpRelayReceiver::addUdpRelay(UdpRelayAddrSet *addrSet, int &relayClass, uin
|
|||||||
|
|
||||||
int UdpRelayReceiver::removeUdpRelay_relayLocked(UdpRelayAddrSet *addrSet)
|
int UdpRelayReceiver::removeUdpRelay_relayLocked(UdpRelayAddrSet *addrSet)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_UDP_RELAY
|
||||||
|
std::cerr << "UdpRelayReceiver::removeUdpRelay_relayLocked() :" << *addrSet << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* find in Relay list */
|
/* find in Relay list */
|
||||||
std::map<UdpRelayAddrSet, UdpRelayProxy>::iterator rit = mRelays.find(*addrSet);
|
std::map<UdpRelayAddrSet, UdpRelayProxy>::iterator rit = mRelays.find(*addrSet);
|
||||||
if (rit == mRelays.end())
|
if (rit == mRelays.end())
|
||||||
@ -606,14 +612,15 @@ int UdpRelayReceiver::RelayStatus(std::ostream &out)
|
|||||||
out << "\tBandwidth: " << rit->second.mBandwidth;
|
out << "\tBandwidth: " << rit->second.mBandwidth;
|
||||||
out << "\tDataSize: " << rit->second.mDataSize;
|
out << "\tDataSize: " << rit->second.mDataSize;
|
||||||
out << "\tLastBandwidthTS: " << rit->second.mLastBandwidthTS;
|
out << "\tLastBandwidthTS: " << rit->second.mLastBandwidthTS;
|
||||||
|
out << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
out << "ClassLimits:" << std::endl;
|
out << "ClassLimits:" << std::endl;
|
||||||
for(int i = 0; i < UDP_RELAY_NUM_CLASS; i++)
|
for(int i = 0; i < UDP_RELAY_NUM_CLASS; i++)
|
||||||
{
|
{
|
||||||
out << "ClassLimit[" << i << "] = " << mClassLimit[i] << std::endl;
|
out << "Limit[" << i << "] = " << mClassLimit[i];
|
||||||
out << "ClassCount[" << i << "] = " << mClassCount[i] << std::endl;
|
out << " Count: " << mClassCount[i];
|
||||||
out << "ClassBandwidth[" << i << "] = " << mClassBandwidth[i] << std::endl;
|
out << " Bandwidth: " << mClassBandwidth[i];
|
||||||
out << std::endl;
|
out << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user