|
|
|
@ -9,8 +9,8 @@ class LokiSnodeAPI {
|
|
|
|
|
if (!is.string(serverUrl)) {
|
|
|
|
|
throw new Error('WebAPI.initialize: Invalid server url');
|
|
|
|
|
}
|
|
|
|
|
this.serverUrl = serverUrl;
|
|
|
|
|
this.localUrl = localUrl;
|
|
|
|
|
this.serverUrl = serverUrl; // random.snode
|
|
|
|
|
this.localUrl = localUrl; // localhost.loki
|
|
|
|
|
this.randomSnodePool = [];
|
|
|
|
|
this.swarmsPendingReplenish = {};
|
|
|
|
|
}
|
|
|
|
@ -63,7 +63,7 @@ class LokiSnodeAPI {
|
|
|
|
|
pubkey_ed25519: snode.pubkey_ed25519,
|
|
|
|
|
}));
|
|
|
|
|
} catch (e) {
|
|
|
|
|
log.warn('initialiseRandomPool error', JSON.stringify(e));
|
|
|
|
|
log.warn('initialiseRandomPool error', e.code, e.message);
|
|
|
|
|
if (seedNodes.length === 0) {
|
|
|
|
|
throw new window.textsecure.SeedNodeError(
|
|
|
|
|
'Failed to contact seed node'
|
|
|
|
@ -73,6 +73,7 @@ class LokiSnodeAPI {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// nodeUrl is like 9hrje1bymy7hu6nmtjme9idyu3rm8gr3mkstakjyuw1997t7w4ny.snode
|
|
|
|
|
async unreachableNode(pubKey, nodeUrl) {
|
|
|
|
|
const conversation = ConversationController.get(pubKey);
|
|
|
|
|
const swarmNodes = [...conversation.get('swarmNodes')];
|
|
|
|
@ -82,6 +83,13 @@ class LokiSnodeAPI {
|
|
|
|
|
await conversation.updateSwarmNodes(filteredNodes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
markRandomNodeUnreachable(snode) {
|
|
|
|
|
this.randomSnodePool = _.without(
|
|
|
|
|
this.randomSnodePool,
|
|
|
|
|
_.find(this.randomSnodePool, { ip: snode.ip, port: snode.port })
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async updateLastHash(snode, hash, expiresAt) {
|
|
|
|
|
await window.Signal.Data.updateLastHash({ snode, hash, expiresAt });
|
|
|
|
|
}
|
|
|
|
@ -152,11 +160,7 @@ class LokiSnodeAPI {
|
|
|
|
|
return snodes;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
log.error('getSwarmNodes error', e.code, e.message);
|
|
|
|
|
//
|
|
|
|
|
this.randomSnodePool = _.without(
|
|
|
|
|
this.randomSnodePool,
|
|
|
|
|
_.find(this.randomSnodePool, { ip: snode.ip })
|
|
|
|
|
);
|
|
|
|
|
this.markRandomNodeUnreachable(snode);
|
|
|
|
|
return this.getSwarmNodes(pubKey);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|