* @param {EndpointOptions|QuicEndpoint|undefined} endpoint * @param {boolean} reuseEndpoint * @param {boolean} forServer * @param {SocketAddress} [targetAddress] * @returns {QuicEndpoint}
(endpoint,
reuseEndpoint = true,
forServer = false,
targetAddress)
| 4849 | * @returns {QuicEndpoint} |
| 4850 | */ |
| 4851 | function processEndpointOption(endpoint, |
| 4852 | reuseEndpoint = true, |
| 4853 | forServer = false, |
| 4854 | targetAddress) { |
| 4855 | if (isQuicEndpoint(endpoint)) { |
| 4856 | // We were given an existing endpoint. Use it as-is. |
| 4857 | return endpoint; |
| 4858 | } |
| 4859 | if (endpoint !== undefined) { |
| 4860 | // We were given endpoint options. If reuse is enabled, we could |
| 4861 | // look for a matching endpoint, but endpoint options imply the |
| 4862 | // caller wants specific configuration. Create a new one. |
| 4863 | return new QuicEndpoint(endpoint); |
| 4864 | } |
| 4865 | // No endpoint specified. Try to reuse an existing one if allowed. |
| 4866 | if (reuseEndpoint && !forServer) { |
| 4867 | const existing = findSuitableEndpoint(targetAddress); |
| 4868 | if (existing !== undefined) return existing; |
| 4869 | } |
| 4870 | return new QuicEndpoint(); |
| 4871 | } |
| 4872 | |
| 4873 | /** |
| 4874 | * Validate and extract identity options (keys, certs) from an SNI entry. |
no test coverage detected
searching dependent graphs…