Skip to content
Snippets Groups Projects
Commit 5a57cc78 authored by Éloïs's avatar Éloïs
Browse files

Merge branch 'dev' into proxy

parents 742e9397 9fe597ee
No related branches found
No related tags found
1 merge request!1178Add WS2PTOR features
...@@ -373,7 +373,7 @@ export class WS2PCluster { ...@@ -373,7 +373,7 @@ export class WS2PCluster {
if (api) { if (api) {
try { try {
// We do not connect to local host // We do not connect to local host
if (!this.server.conf.ws2p || api.uuid !== this.server.conf.ws2p.uuid) { if (!this.server.conf.ws2p || api.uuid !== this.server.conf.ws2p.uuid || p.pubkey !== this.server.conf.pair.pub || api.uuid === '11111111') {
await this.connectToRemoteWS(api.host, api.port, api.path, this.messageHandler, p.pubkey, api.uuid) await this.connectToRemoteWS(api.host, api.port, api.path, this.messageHandler, p.pubkey, api.uuid)
} }
} catch (e) { } catch (e) {
...@@ -401,7 +401,7 @@ export class WS2PCluster { ...@@ -401,7 +401,7 @@ export class WS2PCluster {
// Check if already connected to the pubkey (in any way: server or client) // Check if already connected to the pubkey (in any way: server or client)
const connectedPubkeys = this.getConnectedPubkeys() const connectedPubkeys = this.getConnectedPubkeys()
const shouldAccept = await this.acceptPubkey(peer.pubkey, connectedPubkeys, () => this.clientsCount(), this.maxLevel1Size, (this.server.conf.ws2p && this.server.conf.ws2p.preferedNodes || []), ws2pEnpoint.uuid) const shouldAccept = await this.acceptPubkey(peer.pubkey, connectedPubkeys, () => this.clientsCount(), this.maxLevel1Size, (this.server.conf.ws2p && this.server.conf.ws2p.preferedNodes || []), ws2pEnpoint.uuid)
if (shouldAccept) { if (shouldAccept && (!this.server.conf.ws2p || ws2pEnpoint.uuid !== this.server.conf.ws2p.uuid || peer.pubkey !== this.server.conf.pair.pub || ws2pEnpoint.uuid === '11111111')) {
await this.connectToRemoteWS(ws2pEnpoint.host, ws2pEnpoint.port, ws2pEnpoint.path, this.messageHandler, peer.pubkey) await this.connectToRemoteWS(ws2pEnpoint.host, ws2pEnpoint.port, ws2pEnpoint.path, this.messageHandler, peer.pubkey)
await this.trimClientConnections() await this.trimClientConnections()
} }
...@@ -581,9 +581,8 @@ export class WS2PCluster { ...@@ -581,9 +581,8 @@ export class WS2PCluster {
let accept = priorityKeys.indexOf(pub) !== -1 let accept = priorityKeys.indexOf(pub) !== -1
if (!accept && connectedPubkeys.indexOf(pub) === -1) { if (!accept && connectedPubkeys.indexOf(pub) === -1) {
// Do we have room? // Do we have room?
if (this.isThisNode(pub, targetWS2PUID)) { if (this.server.conf.pair.pub === pub && this.server.conf.ws2p && this.server.conf.ws2p.uuid === targetWS2PUID) {
// We do not connect to local host accept = false
return false
} }
else if (getConcurrentConnexionsCount() < maxConcurrentConnexionsSize) { else if (getConcurrentConnexionsCount() < maxConcurrentConnexionsSize) {
// Yes: just connect to it // Yes: just connect to it
...@@ -624,10 +623,6 @@ export class WS2PCluster { ...@@ -624,10 +623,6 @@ export class WS2PCluster {
return accept return accept
} }
isThisNode(pub:string, uuid:string) {
return !!(this.server.conf.pair.pub === pub && this.server.conf.ws2p && this.server.conf.ws2p.uuid === uuid)
}
isSiblingNode(pub:string, uuid:string) { isSiblingNode(pub:string, uuid:string) {
return !!(this.server.conf.pair.pub === pub && this.server.conf.ws2p && this.server.conf.ws2p.uuid !== uuid) return !!(this.server.conf.pair.pub === pub && this.server.conf.ws2p && this.server.conf.ws2p.uuid !== uuid)
} }
...@@ -756,4 +751,4 @@ export class WS2PCluster { ...@@ -756,4 +751,4 @@ export class WS2PCluster {
} }
} }
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment