* 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)
| 4807 | * @returns {QuicEndpoint|undefined} |
| 4808 | */ |
| 4809 | function 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. |
no outgoing calls
no test coverage detected