Skip to content

Commit 8e6dcdb

Browse files
committed
feat: listConnections now shows if the connection is authenticated
1 parent 9fc515e commit 8e6dcdb

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

src/client/handlers/NodesListConnections.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class NodesListConnections extends ServerHandler<
3737
port: connection.address.port,
3838
timeout: connection.timeout ?? -1,
3939
usageCount: connection.usageCount,
40+
authenticated: connection.authenticated,
4041
};
4142
}
4243
};

src/client/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ type NodeConnectionMessage = NodeAddressMessage & {
135135
hostname: string;
136136
usageCount: number;
137137
timeout: number;
138+
authenticated: boolean;
138139
};
139140

140141
// Gestalts messages

src/nodes/NodeConnectionManager.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,7 @@ class NodeConnectionManager {
13701370
address: { host: Host; port: Port; hostname: Hostname | undefined };
13711371
usageCount: number;
13721372
timeout: number | undefined;
1373+
authenticated: boolean;
13731374
}> {
13741375
const results: Array<{
13751376
nodeId: NodeId;
@@ -1378,13 +1379,18 @@ class NodeConnectionManager {
13781379
address: { host: Host; port: Port; hostname: Hostname | undefined };
13791380
usageCount: number;
13801381
timeout: number | undefined;
1382+
authenticated: boolean;
13811383
}> = [];
13821384
for (const [nodeIdString, connectionsEntry] of this.connections.entries()) {
13831385
const nodeId = IdInternal.fromString<NodeId>(nodeIdString);
13841386
const connections = connectionsEntry.connections;
13851387
for (const connectionId of Object.keys(connections)) {
13861388
const connectionAndTimer = connections[connectionId];
13871389
const connection = connectionAndTimer.connection;
1390+
const forwardAuthenticated =
1391+
connectionsEntry.authenticatedForward === AuthenticatingState.SUCCESS;
1392+
const reverseAuthenticated =
1393+
connectionsEntry.authenticatedReverse === AuthenticatingState.SUCCESS;
13881394
results.push({
13891395
nodeId,
13901396
connectionId: connection.connectionId,
@@ -1397,6 +1403,7 @@ class NodeConnectionManager {
13971403
},
13981404
usageCount: connectionAndTimer.usageCount,
13991405
timeout: connectionAndTimer.timer?.getTimeout(),
1406+
authenticated: forwardAuthenticated && reverseAuthenticated,
14001407
});
14011408
}
14021409
}

src/nodes/NodeManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class NodeManager {
192192
this.logger.debug('Checking connections');
193193
let connectionCount = 0;
194194
for (const connection of this.nodeConnectionManager.listConnections()) {
195-
if (connection.primary) {
195+
if (connection.primary && connection.authenticated) {
196196
const [bucketId] = this.nodeGraph.bucketIndex(connection.nodeId);
197197
if (bucketId === 255) connectionCount++;
198198
}

0 commit comments

Comments
 (0)