(options: MakeConnectionOptions)
| 355 | type MakeConnectionOptions = ConnectionOptions & { existingSocket?: Stream }; |
| 356 | |
| 357 | function parseSslOptions(options: MakeConnectionOptions): TLSConnectionOpts { |
| 358 | const result: TLSConnectionOpts = parseConnectOptions(options); |
| 359 | // Merge in valid SSL options |
| 360 | for (const name of LEGAL_TLS_SOCKET_OPTIONS) { |
| 361 | if (options[name] != null) { |
| 362 | (result as Document)[name] = options[name]; |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | if (options.existingSocket) { |
| 367 | result.socket = options.existingSocket; |
| 368 | } |
| 369 | |
| 370 | // Set default sni servername to be the same as host |
| 371 | if (result.servername == null && result.host && !net.isIP(result.host)) { |
| 372 | result.servername = result.host; |
| 373 | } |
| 374 | |
| 375 | return result; |
| 376 | } |
| 377 | |
| 378 | export async function makeSocket(options: MakeConnectionOptions): Promise<Stream> { |
| 379 | const useTLS = options.tls ?? false; |
no test coverage detected