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/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, 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) { 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,