Commit b280d826 authored by Éloïs's avatar Éloïs
Browse files

[ifx] getWS2P : return WS2P endpoint if there not WS2PTOR

parent 3e117452
......@@ -98,7 +98,18 @@ export class PeerDTO implements Cloneable {
let api:{ uuid:string, host:string, port:number, path:string }|null = null
const endpointRegexp = (tor) ? CommonConstants.WS2PTOR_REGEXP:CommonConstants.WS2P_REGEXP
for (const ep of this.endpoints) {
const matches:any = !api && ep.match(endpointRegexp)
if (tor) {
const matches:any = ep.match(CommonConstants.WS2PTOR_REGEXP)
if (matches) {
return {
uuid: matches[1],
host: matches[2] || '',
port: parseInt(matches[3]) || 0,
path: matches[4]
}
}
}
const matches:any = !api && ep.match(CommonConstants.WS2P_REGEXP)
if (matches) {
api = {
uuid: matches[1],
......
......@@ -141,7 +141,7 @@ export const WS2PDependency = {
const peers = await server.dal.getWS2Peers()
for (const p of peers) {
for (const ep of p.endpoints) {
if (ep.match(/^WS2P /)) {
if (ep.match(/^WS2P/)) {
console.log(p.pubkey, ep)
}
}
......
......@@ -369,7 +369,7 @@ export class WS2PCluster {
let i = 0
while (i < peers.length && this.clientsCount() < this.maxLevel1Size) {
const p = peers[i]
const api = p.getWS2P(imCanReachTorEndpoint !== undefined)
const api = p.getWS2P(imCanReachTorEndpoint)
if (api) {
try {
await this.connectToRemoteWS(api.host, api.port, api.path, this.messageHandler, p.pubkey, api.uuid)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment