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",
"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,

@ -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,

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

@ -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) {

@ -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,

Loading…
Cancel
Save