@@ -20,6 +20,16 @@ export interface SocketMetadata {
2020 [ key : string ] : any ;
2121}
2222
23+ export interface SocketTimingData {
24+ initialSocket : number ; // Initial raw socket time, since unix epoch
25+
26+ // High-precision timestamps:
27+ initialSocketTimestamp : number ;
28+ tunnelSetupTimestamp ?: number ; // Latest CONNECT completion, if any
29+ tlsConnectedTimestamp ?: number ; // Latest TLS handshake completion, if any
30+ lastRequestTimestamp ?: number ; // Latest request or websocket request time, if any
31+ }
32+
2333declare module 'net' {
2434 interface Socket {
2535 /**
@@ -47,15 +57,7 @@ declare module 'net' {
4757 * Our recordings of various timestamps, used for monitoring &
4858 * performance analysis later on
4959 */
50- [ SocketTimingInfo ] ?: {
51- initialSocket : number ; // Initial raw socket time, since unix epoch
52-
53- // High-precision timestamps:
54- initialSocketTimestamp : number ;
55- tunnelSetupTimestamp ?: number ; // Latest CONNECT completion, if any
56- tlsConnectedTimestamp ?: number ; // Latest TLS handshake completion, if any
57- lastRequestTimestamp ?: number ; // Latest request or websocket request time, if any
58- }
60+ [ SocketTimingInfo ] ?: SocketTimingData ;
5961
6062 // Set on TLSSocket, defined here for convenient access on _all_ sockets
6163 [ TlsMetadata ] ?: TlsSocketMetadata ;
@@ -101,22 +103,22 @@ declare module 'tls' {
101103}
102104
103105declare module 'http2' {
104- class Http2Session {
106+ interface Http2Session {
105107 // session.socket is cleared before error handling kicks in. That's annoying,
106108 // so we manually preserve the socket elsewhere to work around it.
107109 initialSocket ?: net . Socket ;
108110 }
109111
110- class ServerHttp2Stream {
112+ interface ServerHttp2Stream {
111113 // Treated the same as net.Socket, when we unwrap them in our combo server:
112- [ LastHopEncrypted ] ?: net . Socket [ typeof LastHopEncrypted ] ;
113- [ LastTunnelAddress ] ?: net . Socket [ typeof LastTunnelAddress ] ;
114- [ SocketTimingInfo ] ?: net . Socket [ typeof SocketTimingInfo ] ;
114+ [ LastHopEncrypted ] ?: boolean ;
115+ [ LastTunnelAddress ] ?: string ;
116+ [ SocketTimingInfo ] ?: SocketTimingData ;
115117 [ SocketMetadata ] ?: SocketMetadata ;
116118 }
117119}
118120
119121export type SocketIsh < MinProps extends keyof net . Socket & keyof tls . TLSSocket > =
120122 streams . Duplex &
121123 Partial < Pick < net . Socket , MinProps > > &
122- Partial < Pick < tls . TLSSocket , MinProps > > ;
124+ Partial < Pick < tls . TLSSocket , MinProps > > ;
0 commit comments