mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-14 10:37:33 -07:00
Fix a sporadic warning in cluster-geo, and fix test to not overload the test-watcher.
This commit is contained in:
parent
2854f14966
commit
0e4a2c378f
3 changed files with 25 additions and 16 deletions
|
@ -97,7 +97,7 @@ function agentIdToIp(agentId)
|
|||
};
|
||||
|
||||
var lastTestResult = null;
|
||||
var allOtherAgents = [];
|
||||
var allOtherAgents = {};
|
||||
|
||||
function doTest()
|
||||
{
|
||||
|
@ -114,16 +114,19 @@ function doTest()
|
|||
if (body) {
|
||||
try {
|
||||
var peers = JSON.parse(body);
|
||||
if (Array.isArray(peers))
|
||||
allOtherAgents = allOtherAgents.concat(peers);
|
||||
if (Array.isArray(peers)) {
|
||||
for(var xx=0;xx<peers.length;++xx)
|
||||
allOtherAgents[peers[xx]] = true;
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
if (allOtherAgents.length > 1) {
|
||||
var agents = Object.keys(allOtherAgents);
|
||||
if (agents.length > 1) {
|
||||
|
||||
var target = allOtherAgents[Math.floor(Math.random() * allOtherAgents.length)];
|
||||
var target = agents[Math.floor(Math.random() * agents.length)];
|
||||
while (target === thisAgentId)
|
||||
target = allOtherAgents[Math.floor(Math.random() * allOtherAgents.length)];
|
||||
target = agents[Math.floor(Math.random() * agents.length)];
|
||||
|
||||
var testRequest = null;
|
||||
var timeoutId = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue