Optional
authenticateOptional
authenticateOptional
connectionOptional
connectionOptional
connectionOptional
connectionOptional
connectionOptional
connectionOptional
connectionOptional
connectionOptional
connectionOptional
connectionOptional
connectionOptional
logger?: LoggerOptional
rpcOptional
rpcReadonly
[initProtected
activeUsed to track the active authentication RPC calls
Protected
activeUsed to rate limit hole punch attempts per IP Address. We use a semaphore to track the number of active hole punch attempts to that address. We Use a semaphore here to allow a limit of 3 attempts per host. To allow concurrent attempts to the same host while limiting the number of different ports. This is mainly used to limit requests to a single target host.
Protected
activeUsed to track active hole punching attempts.
Attempts are mapped by a string of ${host}:${port}
.
This is used to coalesce attempts to a target host and port.
Used to cancel and await punch attempts when stopping to prevent orphaned promises.
Protected
activeUsed track the active nodesConnectionSignalFinal
attempts and prevent orphaned promises.
Used to cancel and await the active nodesConnectionSignalFinal
when stopping.
Protected
authenticateCallback used to generate authentication data when making the authentication call
Protected
authenticateCallback used to authenticate the peer when processing an authentication request from the peer
Readonly
connectionTime used to establish NodeConnection
Readonly
connectionAlpha constant for kademlia The number of the closest nodes to contact initially
Readonly
connectionTime used to find a node using findNodeLocal
.
Readonly
connectionDefault limit used when getting the closest active connections of a node.
Defaults to the nodesGraphBucketLimit
Readonly
connectionInitial delay between punch packets, delay doubles each attempt.
Readonly
connectionMinimum time to wait to garbage collect un-used node connections.
Readonly
connectionScaling factor to apply to Idle timeout
Readonly
connectionTotal number of active bidirectional streams that can be created
Readonly
connectionTotal number of active unidirectional streams that can be created
Readonly
connectionTime interval for sending keep alive messages.
Readonly
connectionTime to keep alive node connection.
Protected
connectionsData structure to store all NodeConnections. If a connection to a node N
does
not exist, no entry for N
will exist in the map. Alternatively, if a
connection is currently being instantiated by some thread, an entry will
exist in the map, but only with the lock (no connection object). Once a
connection is instantiated, the entry in the map is updated to include the
connection object.
A nodeIdString is used for the key here since
NodeIds can't be used to properly retrieve a value from the map.
Protected
keyProtected
loggerProtected
quicProtected
quicProtected
rateUsed to limit signalling requests on a per-requester basis. This is mainly used to limit a single source node making too many requests through a relay.
Readonly
rpcDefault timeout for RPC handlers
Readonly
rpcMax parse buffer size before RPC parser throws a parse error.
Protected
rpcProtected
tlsFor usage with withF, to acquire a connection This unique acquire function structure of returning the ResourceAcquire itself is such that we can pass targetNodeId as a parameter (as opposed to an acquire function with no parameters).
Id of target node to communicate with
ResourceAcquire Resource API for use in with contexts
Protected
acquireThis is the internal acquireConnection for using connections without authentication. For usage with withF, to acquire a connection This unique acquire function structure of returning the ResourceAcquire itself is such that we can pass targetNodeId as a parameter (as opposed to an acquire function with no parameters).
Id of target node to communicate with
ResourceAcquire Resource API for use in with contexts
Protected
addAdds connection to the connections map. Preforms some checks and lifecycle hooks. This code is shared between the reverse and forward connection creation.
Multiple connections can be added for a single NodeId, but the connection
with the 'lowest' connectionId
will be used. The remaining
connections will be left to timeout gracefully.
Protected
authenticateProtected
authenticateProtected
authenticateProtected
authenticationOptional
reason: anyStarts a connection.
Creates multiple connections looking for a single node. Once the connection has been established then all pending connections are cancelled. This will return the first connection made or timeout.
This will start a new connection using a signalling node to coordinate hole punching.
Removes the connection from the connection map and destroys it. If the connectionId is specified then just that connection is destroyed. If no connectionId is specified then all connections for that node are destroyed.
Id of node we are destroying connection to
if true force the connection to end with error.
Optional
connectionIdTarget: stringif specified destroys only the desired connection.
Optional
ctx: Partial<ContextTimedInput>Returns a list of active connections and their address information.
Gets the existing active connection for the target node
Protected
getWill determine how long to keep a node around for.
Timeout is scaled linearly from 1 min to 2 hours based on its bucket. The value will be symmetric for two nodes, they will assign the same timeout for each other.
Protected
handleProtected
handleProtected
handleProtected
handleTriggers the destruction of the NodeConnectionManager
. Since this is only in
response to an underlying problem or close it will force destroy.
Dispatched by the EventNodeConnectionManagerError
event as the
EventNodeConnectionManagerError
-> EventNodeConnectionManagerClose
event path.
Protected
handleDispatches a EventNodeConnectionManagerClose
in response to any NodeConnectionManager
error event. Will trigger stop of the NodeConnectionManager
via the
EventNodeConnectionManagerError
-> EventNodeConnectionManagerClose
event path.
Protected
handleProtected
handleRedispatches QUICSocket
or QUICServer
error events as NodeConnectionManager
error events.
This should trigger the destruction of the NodeConnection
through the
EventNodeConnectionError
-> EventNodeConnectionClose
event path.
Protected
handleProtected
handleProtected
handleThis is used by the NodesConnectionSignalFinal
to initiate the hole punch procedure.
Will validate the message, and initiate hole punching in the background and return immediately.
Attempts to the same host and port are coalesced.
Attempts to the same host are limited by a semaphore.
Active attempts are tracked inside the activeHolePunchPs
set and are cancelled and awaited when the
NodeConnectionManager
stops.
This is used by the NodesConnectionSignalInitial
to initiate a relay request.
Requests can only be relayed to nodes this node is currently connected to.
Requests made by the same node are rate limited, when the limit has been exceeded the request
throws an ErrorNodeConnectionManagerRequestRateExceeded
error.
Active relay attempts are tracked in activeSignalFinalPs
and are cancelled and awaited when the
NodeConnectionManager
stops.
NodeId of the node making the request. Used for rate limiting.
NodeId of the node that needs to initiate hole punching.
Address the target needs to punch to.
base64url
encoded signature
Optional
ctx: Partial<ContextTimedInput>Optional
ctx: Partial<ContextTimedInput>Open up a port in the NAT by sending packets to the target address. The packets will be sent in an exponential backoff dialing pattern and contain random data.
This is only ever done used in the reverse direction to open up the nat for the connection to establish from the forward direction.
This can't know it succeeded, it will continue until timed out or cancelled.
Will initiate a forward authentication call and coalesce
Returns true if the connection has been authenticated
Returns a promise that resolves once the connection has authenticated, otherwise it rejects with the authentication failure
Optional
ctx: Partial<ContextTimedInput>Optional
host?: HostOptional
ipv6Optional
port?: PortOptional
reusePerform some function on another node over the network with a connection. Will either retrieve an existing connection, or create a new one if it doesn't exist. for use with normal arrow function
Id of target node to communicate with
Function to handle communication
Perform some function on another node over the network with a connection. Will either retrieve an existing connection, or create a new one if it doesn't exist. for use with a generator function
Id of target node to communicate with
Generator function to handle communication
Generated using TypeDoc
Constructs the
NodeConnectionManager
.