File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,7 @@ import {
11
11
OngoingRequest ,
12
12
RawPassthroughEvent ,
13
13
TlsConnectionEvent ,
14
- TlsSocketMetadata ,
15
- TlsTimingEvents
14
+ TlsSocketMetadata
16
15
} from '../types' ;
17
16
18
17
// We store a bunch of metadata that we directly attach to sockets, TLS
@@ -27,6 +26,11 @@ export const ClientErrorInProgress = Symbol('client-error-in-progress');
27
26
export const SocketTimingInfo = Symbol ( 'socket-timing-info' ) ;
28
27
export const SocketMetadata = Symbol ( 'socket-metadata' ) ;
29
28
29
+ export type SocketMetadata = {
30
+ tags ?: string [ ] ;
31
+ [ key : string ] : any ;
32
+ }
33
+
30
34
declare module 'net' {
31
35
interface Socket {
32
36
/**
@@ -78,10 +82,7 @@ declare module 'net' {
78
82
* setup that will then be visible on all 'response' event data (for
79
83
* example) later on.
80
84
*/
81
- [ SocketMetadata ] ?: {
82
- tags ?: string [ ] ;
83
- [ key : string ] : any ;
84
- }
85
+ [ SocketMetadata ] ?: SocketMetadata ;
85
86
}
86
87
}
87
88
@@ -121,6 +122,7 @@ declare module 'http2' {
121
122
[ LastHopEncrypted ] ?: net . Socket [ typeof LastHopEncrypted ] ;
122
123
[ LastTunnelAddress ] ?: net . Socket [ typeof LastTunnelAddress ] ;
123
124
[ SocketTimingInfo ] ?: net . Socket [ typeof SocketTimingInfo ] ;
125
+ [ SocketMetadata ] ?: SocketMetadata ;
124
126
}
125
127
}
126
128
@@ -333,6 +335,6 @@ export function buildSocketTimingInfo(): Required<net.Socket>[typeof SocketTimin
333
335
return { initialSocket : Date . now ( ) , initialSocketTimestamp : now ( ) } ;
334
336
}
335
337
336
- export function getSocketMetadataTags ( socket : net . Socket | undefined ) {
338
+ export function getSocketMetadataTags ( socket : { [ SocketMetadata ] ?: SocketMetadata } | undefined ) {
337
339
return ( socket ?. [ SocketMetadata ] ?. tags || [ ] ) . map ( ( tag : string ) => `socket-metadata:${ tag } ` ) ;
338
340
}
You can’t perform that action at this time.
0 commit comments