Merge pull request #1128 from neuroscr/seed-https-support

Seed https support
pull/1130/head
Ryan Tharp 5 years ago committed by GitHub
commit 21622c7dea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,20 +6,16 @@
"defaultPoWDifficulty": "1", "defaultPoWDifficulty": "1",
"seedNodeList": [ "seedNodeList": [
{ {
"ip": "public.loki.foundation", "ip_url": "http://116.203.53.213/",
"port": "22023" "url": "https://storage.seed1.loki.network/"
}, },
{ {
"ip": "storage.seed1.loki.network", "ip_url": "http://212.199.114.66/",
"port": "22023" "url": "https://storage.seed3.loki.network/"
}, },
{ {
"ip": "storage.seed2.loki.network", "ip_url": "http://144.76.164.202/",
"port": "22023" "url": "https://public.loki.foundation/"
},
{
"ip": "imaginary.stream",
"port": "22023"
} }
], ],
"updatesEnabled": false, "updatesEnabled": false,

@ -1,12 +1,12 @@
{ {
"seedNodeList": [ "seedNodeList": [
{ {
"ip": "public.loki.foundation", "url": "http://public.loki.foundation:38157/",
"port": "38157" "ip_url": "http://144.76.164.202:38157/"
}, },
{ {
"ip": "storage.testnetseed1.loki.network", "url": "http://storage.testnetseed1.loki.network:38157/",
"port": "38157" "ip_url": "http://116.203.32.199:38157/"
} }
], ],
"openDevTools": true, "openDevTools": true,

@ -1,8 +1,8 @@
{ {
"seedNodeList": [ "seedNodeList": [
{ {
"ip": "localhost", "ip_url": "http://127.0.0.1:22129/",
"port": "22129" "url": "http://localhost:22129/"
} }
], ],
"openDevTools": true, "openDevTools": true,

@ -1,5 +1,5 @@
/* eslint-disable class-methods-use-this */ /* 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'); const { lokiRpc } = require('./loki_rpc');
// not sure I like this name but it's been than util // not sure I like this name but it's been than util
@ -44,22 +44,33 @@ async function tryGetSnodeListFromLokidSeednode(
)[0]; )[0];
let snodes = []; let snodes = [];
try { try {
const response = await lokiRpc( const getSnodesFromSeedUrl = async urlObj => {
`http://${seedNode.ip}`, const response = await lokiRpc(
seedNode.port, `${urlObj.protocol}//${urlObj.hostname}`,
'get_n_service_nodes', urlObj.port,
params, 'get_n_service_nodes',
{}, // Options params,
'/json_rpc' // Seed request endpoint {}, // 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( // Filter 0.0.0.0 nodes which haven't submitted uptime proofs
snode => snode.public_ip !== '0.0.0.0' 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 // throw before clearing the lock, so the retries can kick in
if (snodes.length === 0) { if (snodes.length === 0) {
// does this error message need to be exactly this? // fall back on ip_url
throw new window.textsecure.SeedNodeError('Failed to contact seed node'); 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; return snodes;
} catch (e) { } catch (e) {

@ -175,6 +175,7 @@ function prepareURL(pathSegments, moreKeys) {
localUrl: config.get('localUrl'), localUrl: config.get('localUrl'),
cdnUrl: config.get('cdnUrl'), cdnUrl: config.get('cdnUrl'),
defaultPoWDifficulty: config.get('defaultPoWDifficulty'), defaultPoWDifficulty: config.get('defaultPoWDifficulty'),
// one day explain why we need to do this - neuroscr
seedNodeList: JSON.stringify(config.get('seedNodeList')), seedNodeList: JSON.stringify(config.get('seedNodeList')),
certificateAuthority: config.get('certificateAuthority'), certificateAuthority: config.get('certificateAuthority'),
environment: config.environment, environment: config.environment,

Loading…
Cancel
Save