MCPcopy Create free account
hub / github.com/nodejs/node / findSuitableEndpoint

Function findSuitableEndpoint

lib/internal/quic/quic.js:4809–4824  ·  view source on GitHub ↗

* Find an existing endpoint from the registry that is suitable for reuse. * @param {SocketAddress} [targetAddress] The address the client will connect * to. If provided, endpoints that are listening on that same address are * excluded to prevent CID namespace collisions (the client's initial

(targetAddress)

Source from the content-addressed store, hash-verified

4807 * @returns {QuicEndpoint|undefined}
4808 */
4809function findSuitableEndpoint(targetAddress) {
4810 for (const endpoint of endpointRegistry) {
4811 if (!endpoint.destroyed &&
4812 !endpoint.closing &&
4813 !endpoint.busy) {
4814 // Don't reuse an endpoint for a connection to itself.
4815 if (targetAddress && endpoint.listening && endpoint.address &&
4816 targetAddress.address === endpoint.address.address &&
4817 targetAddress.port === endpoint.address.port) {
4818 continue;
4819 }
4820 return endpoint;
4821 }
4822 }
4823 return undefined;
4824}
4825
4826/**
4827 * Returns a list of all active endpoints.

Callers 1

processEndpointOptionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected