mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-22 12:34:24 +00:00
fix dht count when using proxy (fix #231)
This commit is contained in:
parent
2168e34677
commit
6cae25e7ab
@ -74,7 +74,7 @@ namespace DhtProxy
|
||||
}
|
||||
}
|
||||
|
||||
vector<CNode*> getRandomDhtProxies()
|
||||
vector<CNode*> getRandomDhtProxies(int *totalProxyNodes)
|
||||
{
|
||||
// (cs_vNodes) lock must be held!
|
||||
vector<CNode*> vNodesProxy;
|
||||
@ -83,6 +83,8 @@ namespace DhtProxy
|
||||
vNodesProxy.push_back(pnode);
|
||||
}
|
||||
}
|
||||
if( totalProxyNodes )
|
||||
*totalProxyNodes = (int) vNodesProxy.size();
|
||||
std::random_shuffle(vNodesProxy.begin(),vNodesProxy.end());
|
||||
if(vNodesProxy.size() > numProxiesToUse) {
|
||||
vNodesProxy.resize(numProxiesToUse);
|
||||
|
@ -86,6 +86,8 @@ namespace DhtProxy
|
||||
// Handle a dhtput request received from TCP. send request to UDP. (server side)
|
||||
// return true if accepted.
|
||||
bool dhtputRequestReceived(const CDHTPutRequest& req, CNode* pfrom);
|
||||
|
||||
vector<CNode*> getRandomDhtProxies(int *totalProxyNodes = NULL);
|
||||
}
|
||||
|
||||
class CDHTTarget
|
||||
|
@ -459,13 +459,24 @@ void lockAndSaveUserData()
|
||||
|
||||
int getDhtNodes(boost::int64_t *dht_global_nodes)
|
||||
{
|
||||
boost::shared_ptr<session> ses(m_ses);
|
||||
if( !ses )
|
||||
return 0;
|
||||
session_status ss = ses->status();
|
||||
int dhtNodes = 0;
|
||||
|
||||
if( dht_global_nodes )
|
||||
*dht_global_nodes = ss.dht_global_nodes;
|
||||
return ss.dht_nodes;
|
||||
*dht_global_nodes = 0;
|
||||
|
||||
if( !DhtProxy::fEnabled ) {
|
||||
boost::shared_ptr<session> ses(m_ses);
|
||||
if( ses ) {
|
||||
session_status ss = ses->status();
|
||||
if( dht_global_nodes )
|
||||
*dht_global_nodes = ss.dht_global_nodes;
|
||||
dhtNodes = ss.dht_nodes;
|
||||
}
|
||||
} else {
|
||||
LOCK(cs_vNodes);
|
||||
DhtProxy::getRandomDhtProxies(&dhtNodes);
|
||||
}
|
||||
return dhtNodes;
|
||||
}
|
||||
|
||||
void torrentManualTrackerUpdate(const std::string &username)
|
||||
|
Loading…
x
Reference in New Issue
Block a user