From 1c9fe5b9f515d8096741a371e5fdecc40b84c3ee Mon Sep 17 00:00:00 2001 From: Beaudan Date: Tue, 9 Jul 2019 10:45:50 +1000 Subject: [PATCH] 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 --- js/modules/loki_message_api.js | 7 ++----- js/modules/loki_snode_api.js | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/js/modules/loki_message_api.js b/js/modules/loki_message_api.js index c16b6f35f..17147bc8c 100644 --- a/js/modules/loki_message_api.js +++ b/js/modules/loki_message_api.js @@ -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); } } diff --git a/js/modules/loki_snode_api.js b/js/modules/loki_snode_api.js index b1a7887f6..49e00c773 100644 --- a/js/modules/loki_snode_api.js +++ b/js/modules/loki_snode_api.js @@ -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',