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

[fix] insoleet feedbacks

parent 3c90b511
No related branches found
No related tags found
3 merge requests!1222Add startup scripts,!1220Stable/ws2p v1.1 trymerge,!1208Stable/ws2p v1.1
...@@ -103,9 +103,9 @@ export class PeerDTO implements Cloneable { ...@@ -103,9 +103,9 @@ export class PeerDTO implements Cloneable {
let bestWS2PTORVersionAvailable:number = 0 let bestWS2PTORVersionAvailable:number = 0
for (const ep of this.endpoints) { for (const ep of this.endpoints) {
if (canReachTorEp) { if (canReachTorEp) {
let matches:any = ep.match(CommonConstants.WS2PTOR_V2_REGEXP) let matches:RegExpMatchArray | null = ep.match(CommonConstants.WS2PTOR_V2_REGEXP)
if (matches && parseInt(matches[1]) > bestWS2PTORVersionAvailable && (uuidExcluded.indexOf(matches[2]) === -1)) { if (matches && parseInt(matches[1]) > bestWS2PTORVersionAvailable && (uuidExcluded.indexOf(matches[2]) === -1)) {
bestWS2PTORVersionAvailable = matches[1] bestWS2PTORVersionAvailable = parseInt(matches[1])
api = { api = {
version: parseInt(matches[1]), version: parseInt(matches[1]),
uuid: matches[2], uuid: matches[2],
......
...@@ -267,8 +267,7 @@ export class WS2PCluster { ...@@ -267,8 +267,7 @@ export class WS2PCluster {
await this.ws2pServer.close() await this.ws2pServer.close()
} }
this.ws2pServer = await WS2PServer.bindOn(this.server, host, port, this.fifo, (pubkey:string, connectedPubkeys:string[]) => { this.ws2pServer = await WS2PServer.bindOn(this.server, host, port, this.fifo, (pubkey:string, connectedPubkeys:string[]) => {
const privilegedNodes = (this.server.conf.ws2p && this.server.conf.ws2p.privilegedNodes) ? this.server.conf.ws2p.privilegedNodes:[] return this.acceptPubkey(pubkey, connectedPubkeys, [], () => this.servedCount(), this.maxLevel2Peers, this.privilegedNodes(), (this.server.conf.ws2p !== undefined && this.server.conf.ws2p.privilegedOnly))
return this.acceptPubkey(pubkey, connectedPubkeys, [], () => this.servedCount(), this.maxLevel2Peers, privilegedNodes, (this.server.conf.ws2p !== undefined && this.server.conf.ws2p.privilegedOnly))
}, this.keyPriorityLevel, this.messageHandler) }, this.keyPriorityLevel, this.messageHandler)
this.host = host this.host = host
this.port = port this.port = port
...@@ -285,7 +284,7 @@ export class WS2PCluster { ...@@ -285,7 +284,7 @@ export class WS2PCluster {
clientsCount() { clientsCount() {
let count = 0 let count = 0
for (const ws2pid of Object.keys(this.ws2pClients)) { for (const ws2pid in this.ws2pClients) {
if (this.ws2pClients[ws2pid].connection.pubkey != this.server.conf.pair.pub) { if (this.ws2pClients[ws2pid].connection.pubkey != this.server.conf.pair.pub) {
count++ count++
} }
...@@ -295,7 +294,7 @@ export class WS2PCluster { ...@@ -295,7 +294,7 @@ export class WS2PCluster {
numberOfConnectedPublicNodesWithSameKey() { numberOfConnectedPublicNodesWithSameKey() {
let count = 0 let count = 0
for (const ws2pid of Object.keys(this.ws2pClients)) { for (const ws2pid in this.ws2pClients) {
if (this.ws2pClients[ws2pid].connection.pubkey === this.server.conf.pair.pub) { if (this.ws2pClients[ws2pid].connection.pubkey === this.server.conf.pair.pub) {
count++ count++
} }
...@@ -307,6 +306,14 @@ export class WS2PCluster { ...@@ -307,6 +306,14 @@ export class WS2PCluster {
return (this.ws2pServer) ? this.ws2pServer.countConnexions():0 return (this.ws2pServer) ? this.ws2pServer.countConnexions():0
} }
privilegedNodes() {
if (this.server.conf.ws2p && this.server.conf.ws2p.privilegedNodes) {
return this.server.conf.ws2p.privilegedNodes
} else {
return []
}
}
async connectToRemoteWS(endpointVersion:number, host: string, port: number, path:string, messageHandler:WS2PMessageHandler, expectedPub:string, ws2pEndpointUUID:string = ""): Promise<WS2PConnection> { async connectToRemoteWS(endpointVersion:number, host: string, port: number, path:string, messageHandler:WS2PMessageHandler, expectedPub:string, ws2pEndpointUUID:string = ""): Promise<WS2PConnection> {
const uuid = nuuid.v4() const uuid = nuuid.v4()
let pub = expectedPub.slice(0, 8) let pub = expectedPub.slice(0, 8)
......
...@@ -430,7 +430,7 @@ export class WS2PConnection { ...@@ -430,7 +430,7 @@ export class WS2PConnection {
return this.errorDetected(WS2P_ERR.ALREADY_AUTHENTICATED_BY_REMOTE) return this.errorDetected(WS2P_ERR.ALREADY_AUTHENTICATED_BY_REMOTE)
} }
else if ( else if (
typeof data.pub !== "string" || typeof data.sig !== "string" || typeof data.challenge !== "string" || (this.ws2pVersion > 1 && data.ws2pId !== "string") ) { typeof data.pub !== "string" || typeof data.sig !== "string" || typeof data.challenge !== "string" || (this.ws2pVersion > 1 && typeof data.ws2pId !== "string") ) {
await this.errorDetected(WS2P_ERR.AUTH_INVALID_ASK_FIELDS) await this.errorDetected(WS2P_ERR.AUTH_INVALID_ASK_FIELDS)
} else { } else {
if (this.expectedPub && data.pub !== this.expectedPub) { if (this.expectedPub && data.pub !== this.expectedPub) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment