Skip to content

Commit e870757

Browse files
committed
wip: exploring the code
[ci skip]
1 parent e0733ab commit e870757

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/nodes/NodeConnectionManager.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ type ConnectionAndTimer = {
5252
connection: NodeConnection;
5353
timer: Timer | null;
5454
usageCount: number;
55+
authenticatedForward: boolean;
56+
authenticatedReverse: boolean;
5557
};
5658

5759
type ConnectionsEntry = {
@@ -76,8 +78,6 @@ const abortPendingConnectionsReason = Symbol(
7678
'abort pending connections reason',
7779
);
7880

79-
// TODO: modify this to handle network authentication logic
80-
8181
/**
8282
* NodeConnectionManager is a server that manages all node connections.
8383
* It manages both initiated and received connections.
@@ -189,8 +189,8 @@ class NodeConnectionManager {
189189
protected quicServer: QUICServer;
190190

191191
/**
192-
* Data structure to store all NodeConnections. If a connection to a node n does
193-
* not exist, no entry for n will exist in the map. Alternatively, if a
192+
* Data structure to store all NodeConnections. If a connection to a node `N` does
193+
* not exist, no entry for `N` will exist in the map. Alternatively, if a
194194
* connection is currently being instantiated by some thread, an entry will
195195
* exist in the map, but only with the lock (no connection object). Once a
196196
* connection is instantiated, the entry in the map is updated to include the
@@ -745,6 +745,7 @@ class NodeConnectionManager {
745745
},
746746
ctx,
747747
);
748+
// FIXME: How do we even handle cancellation here if we stop the NCM?
748749
this.addConnection(nodeConnection.validatedNodeId, nodeConnection);
749750
// Dispatch the connection event
750751
const connectionData: ConnectionData = {
@@ -882,6 +883,8 @@ class NodeConnectionManager {
882883
return await this.createConnection([nodeIdTarget], host, port, ctx);
883884
}
884885

886+
// TODO: this needs to hook up authentication logic for the forward and reverse.
887+
// How do we handle timeouts for this?
885888
/**
886889
* Adds connection to the connections map. Preforms some checks and lifecycle hooks.
887890
* This code is shared between the reverse and forward connection creation.
@@ -914,6 +917,8 @@ class NodeConnectionManager {
914917
connection: nodeConnection,
915918
timer: null,
916919
usageCount: 0,
920+
authenticatedForward: false,
921+
authenticatedReverse: false,
917922
};
918923

919924
// Adding the new connection into the connection map
@@ -926,6 +931,7 @@ class NodeConnectionManager {
926931
await this.destroyConnection(nodeId, false, connectionId),
927932
delay: this.getStickyTimeoutValue(nodeId, true),
928933
});
934+
// TODO: only update the active connection once the authentication has been completed.
929935
entry = {
930936
activeConnection: connectionId,
931937
connections: {
@@ -945,6 +951,7 @@ class NodeConnectionManager {
945951
// Updating existing entry
946952
entry.connections[connectionId] = newConnAndTimer;
947953
// If the new connection ID is less than the old then replace it
954+
// TODO: only update the active connection once the authentication has been completed.
948955
if (entry.activeConnection > connectionId) {
949956
entry.activeConnection = connectionId;
950957
}
@@ -1005,6 +1012,7 @@ class NodeConnectionManager {
10051012
// Check if the active connection was removed.
10061013
if (connections[connectionsEntry.activeConnection] == null) {
10071014
// Find the new lowest
1015+
// TODO: filter out only the authenticated connections when picking the next lowest
10081016
connectionsEntry.activeConnection = remainingKeys.sort()[0];
10091017
}
10101018
}

src/nodes/NodeManager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ class NodeManager {
641641
try {
642642
return await Promise.any([findBySignal, findByDirect, findByMDNS]);
643643
} catch (e) {
644+
// TODO: definitely fix this while I'm here..
644645
// FIXME: check error type and throw if not connection related failure
645646
return;
646647
} finally {

0 commit comments

Comments
 (0)