Skip to content

Commit 953f0d8

Browse files
committed
Add keylog support to the Send API
1 parent e733101 commit 953f0d8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/client/client-types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ export interface RequestOptions {
8282
*/
8383
lookupOptions?: { servers?: string[] };
8484

85+
/**
86+
* A path to a file where TLS key logging information should be written.
87+
*/
88+
keyLogFile?: string;
89+
8590
/**
8691
* An abort signal, which can be used to cancel the in-process request if
8792
* required.

src/client/http-client.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
RequestOptions,
2323
RULE_PARAM_REF_KEY
2424
} from './client-types';
25+
import * as fs from '../util/fs';
2526

2627
export class HttpClient {
2728

@@ -102,6 +103,12 @@ export class HttpClient {
102103
})
103104
});
104105

106+
if (options.keyLogFile) {
107+
request.on('socket', (socket) => {
108+
socket.on('keylog', (line) => fs.appendOrCreateFile(options.keyLogFile!, line));
109+
});
110+
}
111+
105112
options.abortSignal?.addEventListener('abort', () => {
106113
// In older Node versions, this seems to be required to _actually_ abort the request:
107114
request.abort();

0 commit comments

Comments
 (0)