From 87c5d0858c035530f8b643b31ea5d13988580c02 Mon Sep 17 00:00:00 2001 From: Beaudan Date: Mon, 1 Jul 2019 17:22:55 +1000 Subject: [PATCH] Choose a random seed node from a list for bootstrapping --- config/default.json | 16 ++++++++++++++-- js/modules/loki_snode_api.js | 5 +++-- main.js | 3 +-- preload.js | 3 +-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/config/default.json b/config/default.json index b0b5e0987..cedf639dc 100644 --- a/config/default.json +++ b/config/default.json @@ -5,8 +5,20 @@ "contentProxyUrl": "random.snode", "localServerPort": "8081", "defaultPoWDifficulty": "100", - "seedNodeUrl": "3.104.19.14", - "seedNodePort": "22023", + "seedNodeList": [ + { + "ip": "3.104.19.14", + "port": "22023" + }, + { + "ip": "13.238.53.205", + "port": "38157" + }, + { + "ip": "imaginary.stream", + "port": "38157" + } + ], "disableAutoUpdate": false, "updatesUrl": "https://updates2.signal.org/desktop", "updatesPublicKey": diff --git a/js/modules/loki_snode_api.js b/js/modules/loki_snode_api.js index 9fbfa7885..1eea467ed 100644 --- a/js/modules/loki_snode_api.js +++ b/js/modules/loki_snode_api.js @@ -94,10 +94,11 @@ class LokiSnodeAPI { storage_port: true, }, }; + const seedNode = window.seedNodeList[Math.floor(Math.random() * window.seedNodeList.length)]; try { const result = await rpc( - `http://${window.seedNodeUrl}`, - window.seedNodePort, + `http://${seedNode.ip}`, + seedNode.port, 'get_n_service_nodes', params, {}, // Options diff --git a/main.js b/main.js index b3bd6bbd0..c2135252d 100644 --- a/main.js +++ b/main.js @@ -156,8 +156,7 @@ function prepareURL(pathSegments, moreKeys) { cdnUrl: config.get('cdnUrl'), localServerPort: config.get('localServerPort'), defaultPoWDifficulty: config.get('defaultPoWDifficulty'), - seedNodeUrl: config.get('seedNodeUrl'), - seedNodePort: config.get('seedNodePort'), + seedNodeList: JSON.stringify(config.get('seedNodeList')), certificateAuthority: config.get('certificateAuthority'), environment: config.environment, node_version: process.versions.node, diff --git a/preload.js b/preload.js index 80acb1169..68c7eea38 100644 --- a/preload.js +++ b/preload.js @@ -305,8 +305,7 @@ window.WebAPI = initializeWebAPI({ proxyUrl: config.proxyUrl, }); -window.seedNodeUrl = config.seedNodeUrl; -window.seedNodePort = config.seedNodePort; +window.seedNodeList = JSON.parse(config.seedNodeList); const LokiSnodeAPI = require('./js/modules/loki_snode_api'); window.lokiSnodeAPI = new LokiSnodeAPI({