Merge pull request #337 from BeaudanBrown/filter-and-purge

Make sure we are purging nodes from retrieve swarm list, and also filter 0.0.0.0 ips when getting snodes from wrong swarm error
pull/347/head
Beaudan Campbell-Brown 6 years ago committed by GitHub
commit d3aba65e41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -240,15 +240,12 @@ class LokiMessageAPI {
throw e;
} else if (e instanceof textsecure.NotFoundError) {
// TODO: Handle resolution error
successiveFailures += 1;
} else if (e instanceof textsecure.HTTPError) {
// TODO: Handle working connection but error response
const body = await e.response.text();
log.warn('HTTPError body:', body);
successiveFailures += 1;
} else {
successiveFailures += 1;
}
successiveFailures += 1;
}
}
log.error(`Failed to send to node: ${address}`);
@ -307,7 +304,7 @@ class LokiMessageAPI {
successiveFailures += 1;
}
}
if (successiveFailures >= 3) {
if (successiveFailures >= MAX_ACCEPTABLE_FAILURES) {
await lokiSnodeAPI.unreachableNode(this.ourKey, address);
}
}

@ -152,8 +152,9 @@ class LokiSnodeAPI {
async updateSwarmNodes(pubKey, newNodes) {
try {
const filteredNodes = newNodes.filter(snode => snode.ip !== '0.0.0.0');
const conversation = ConversationController.get(pubKey);
await conversation.updateSwarmNodes(newNodes);
await conversation.updateSwarmNodes(filteredNodes);
} catch (e) {
throw new window.textsecure.ReplayableError({
message: 'Could not get conversation',

Loading…
Cancel
Save