From 99202947ce8bf210befe66349468b7df93d7b57d Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Tue, 12 May 2020 22:55:05 -0700 Subject: [PATCH 1/4] add note --- main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/main.js b/main.js index 2338b23a3..408771485 100644 --- a/main.js +++ b/main.js @@ -175,6 +175,7 @@ function prepareURL(pathSegments, moreKeys) { localUrl: config.get('localUrl'), cdnUrl: config.get('cdnUrl'), defaultPoWDifficulty: config.get('defaultPoWDifficulty'), + // one day explain why we need to do this - neuroscr seedNodeList: JSON.stringify(config.get('seedNodeList')), certificateAuthority: config.get('certificateAuthority'), environment: config.environment, From 6a2e0af4c212072b186b270e1ba7e6f1d8a26380 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Tue, 12 May 2020 22:55:52 -0700 Subject: [PATCH 2/4] update seedNode format --- config/default.json | 16 ++++++---------- config/development.json | 8 ++++---- config/local-development.json | 1 + config/swarm-testing.json | 4 ++-- 4 files changed, 13 insertions(+), 16 deletions(-) create mode 100644 config/local-development.json diff --git a/config/default.json b/config/default.json index 913ea0e19..0765f911f 100644 --- a/config/default.json +++ b/config/default.json @@ -6,20 +6,16 @@ "defaultPoWDifficulty": "1", "seedNodeList": [ { - "ip": "public.loki.foundation", - "port": "22023" + "ip_url": "http://116.203.53.213/", + "url": "https://storage.seed1.loki.network/" }, { - "ip": "storage.seed1.loki.network", - "port": "22023" + "ip_url": "http://212.199.114.66/", + "url": "https://storage.seed3.loki.network/" }, { - "ip": "storage.seed2.loki.network", - "port": "22023" - }, - { - "ip": "imaginary.stream", - "port": "22023" + "ip_url": "http://144.76.164.202/", + "url": "https://public.loki.foundation/" } ], "updatesEnabled": false, diff --git a/config/development.json b/config/development.json index ba141816b..670d128ec 100644 --- a/config/development.json +++ b/config/development.json @@ -1,12 +1,12 @@ { "seedNodeList": [ { - "ip": "public.loki.foundation", - "port": "38157" + "url": "http://public.loki.foundation:38157/", + "ip_url": "http://144.76.164.202:38157/" }, { - "ip": "storage.testnetseed1.loki.network", - "port": "38157" + "url": "http://storage.testnetseed1.loki.network:38157/", + "ip_url": "http://116.203.32.199:38157/" } ], "openDevTools": true, diff --git a/config/local-development.json b/config/local-development.json new file mode 100644 index 000000000..392627778 --- /dev/null +++ b/config/local-development.json @@ -0,0 +1 @@ +{"buildExpiration":1597119102000,"commitHash":"13329c0b2a7b037dfe5522f6c9554b4ccb94753e"} diff --git a/config/swarm-testing.json b/config/swarm-testing.json index 4e7ab7fee..61594f421 100644 --- a/config/swarm-testing.json +++ b/config/swarm-testing.json @@ -1,8 +1,8 @@ { "seedNodeList": [ { - "ip": "localhost", - "port": "22129" + "ip_url": "http://127.0.0.1:22129/", + "url": "http://localhost:22129/" } ], "openDevTools": true, From 7baf69ae007dd1e662c09caeb6edd21e059601da Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Tue, 12 May 2020 22:56:38 -0700 Subject: [PATCH 3/4] update seedNode format in config, try ip_url as fallback --- js/modules/loki_snode_api.js | 41 +++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/js/modules/loki_snode_api.js b/js/modules/loki_snode_api.js index 7d120ff4e..98110b381 100644 --- a/js/modules/loki_snode_api.js +++ b/js/modules/loki_snode_api.js @@ -1,5 +1,5 @@ /* eslint-disable class-methods-use-this */ -/* global window, textsecure, ConversationController, _, log, process, Buffer, StringView, dcodeIO */ +/* global window, textsecure, ConversationController, _, log, process, Buffer, StringView, dcodeIO, URL */ const { lokiRpc } = require('./loki_rpc'); // not sure I like this name but it's been than util @@ -44,22 +44,33 @@ async function tryGetSnodeListFromLokidSeednode( )[0]; let snodes = []; try { - const response = await lokiRpc( - `http://${seedNode.ip}`, - seedNode.port, - 'get_n_service_nodes', - params, - {}, // Options - '/json_rpc' // Seed request endpoint - ); - // Filter 0.0.0.0 nodes which haven't submitted uptime proofs - snodes = response.result.service_node_states.filter( - snode => snode.public_ip !== '0.0.0.0' - ); + const getSnodesFromSeedUrl = async urlObj => { + const response = await lokiRpc( + `${urlObj.protocol}//${urlObj.hostname}`, + urlObj.port, + 'get_n_service_nodes', + params, + {}, // Options + '/json_rpc' // Seed request endpoint + ); + // Filter 0.0.0.0 nodes which haven't submitted uptime proofs + return response.result.service_node_states.filter( + snode => snode.public_ip !== '0.0.0.0' + ); + }; + const tryUrl = new URL(seedNode.url); + snodes = getSnodesFromSeedUrl(tryUrl); // throw before clearing the lock, so the retries can kick in if (snodes.length === 0) { - // does this error message need to be exactly this? - throw new window.textsecure.SeedNodeError('Failed to contact seed node'); + // fall back on ip_url + const tryIpUrl = new URL(seedNode.ip_url); + snodes = getSnodesFromSeedUrl(tryIpUrl); + if (snodes.length === 0) { + // does this error message need to be exactly this? + throw new window.textsecure.SeedNodeError( + 'Failed to contact seed node' + ); + } } return snodes; } catch (e) { From 73f0e2758fd651dac4d5c54daeb5e0399c13e45d Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Tue, 12 May 2020 23:00:49 -0700 Subject: [PATCH 4/4] remove unneeded generated file --- config/local-development.json | 1 - 1 file changed, 1 deletion(-) delete mode 100644 config/local-development.json diff --git a/config/local-development.json b/config/local-development.json deleted file mode 100644 index 392627778..000000000 --- a/config/local-development.json +++ /dev/null @@ -1 +0,0 @@ -{"buildExpiration":1597119102000,"commitHash":"13329c0b2a7b037dfe5522f6c9554b4ccb94753e"}