diff --git a/package-lock.json b/package-lock.json index a4a041154..6d6806a1f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "polykey", - "version": "1.21.1", + "version": "1.21.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "polykey", - "version": "1.21.1", + "version": "1.21.2", "license": "GPL-3.0", "dependencies": { "@matrixai/async-cancellable": "^1.1.1", diff --git a/package.json b/package.json index 41b996ccd..692d73bdb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polykey", - "version": "1.21.1", + "version": "1.21.2", "homepage": "https://polykey.com", "author": "Matrix AI", "contributors": [ diff --git a/src/client/handlers/NodesListConnections.ts b/src/client/handlers/NodesListConnections.ts index 2fcfb8c87..ce86fce50 100644 --- a/src/client/handlers/NodesListConnections.ts +++ b/src/client/handlers/NodesListConnections.ts @@ -37,6 +37,7 @@ class NodesListConnections extends ServerHandler< port: connection.address.port, timeout: connection.timeout ?? -1, usageCount: connection.usageCount, + authenticated: connection.authenticated, }; } }; diff --git a/src/client/types.ts b/src/client/types.ts index d5a180153..fa8a44f30 100644 --- a/src/client/types.ts +++ b/src/client/types.ts @@ -135,6 +135,7 @@ type NodeConnectionMessage = NodeAddressMessage & { hostname: string; usageCount: number; timeout: number; + authenticated: boolean; }; // Gestalts messages diff --git a/src/nodes/NodeConnectionManager.ts b/src/nodes/NodeConnectionManager.ts index f551424c3..fd43bd79a 100644 --- a/src/nodes/NodeConnectionManager.ts +++ b/src/nodes/NodeConnectionManager.ts @@ -1370,6 +1370,7 @@ class NodeConnectionManager { address: { host: Host; port: Port; hostname: Hostname | undefined }; usageCount: number; timeout: number | undefined; + authenticated: boolean; }> { const results: Array<{ nodeId: NodeId; @@ -1378,6 +1379,7 @@ class NodeConnectionManager { address: { host: Host; port: Port; hostname: Hostname | undefined }; usageCount: number; timeout: number | undefined; + authenticated: boolean; }> = []; for (const [nodeIdString, connectionsEntry] of this.connections.entries()) { const nodeId = IdInternal.fromString(nodeIdString); @@ -1385,6 +1387,10 @@ class NodeConnectionManager { for (const connectionId of Object.keys(connections)) { const connectionAndTimer = connections[connectionId]; const connection = connectionAndTimer.connection; + const forwardAuthenticated = + connectionsEntry.authenticatedForward === AuthenticatingState.SUCCESS; + const reverseAuthenticated = + connectionsEntry.authenticatedReverse === AuthenticatingState.SUCCESS; results.push({ nodeId, connectionId: connection.connectionId, @@ -1397,6 +1403,7 @@ class NodeConnectionManager { }, usageCount: connectionAndTimer.usageCount, timeout: connectionAndTimer.timer?.getTimeout(), + authenticated: forwardAuthenticated && reverseAuthenticated, }); } } diff --git a/src/nodes/NodeManager.ts b/src/nodes/NodeManager.ts index 784832bd7..92f39a988 100644 --- a/src/nodes/NodeManager.ts +++ b/src/nodes/NodeManager.ts @@ -192,7 +192,7 @@ class NodeManager { this.logger.debug('Checking connections'); let connectionCount = 0; for (const connection of this.nodeConnectionManager.listConnections()) { - if (connection.primary) { + if (connection.primary && connection.authenticated) { const [bucketId] = this.nodeGraph.bucketIndex(connection.nodeId); if (bucketId === 255) connectionCount++; }