grpc-js: Add channel option to enable TLS tracing

This commit is contained in:
Michael Lumish 2023-07-14 10:45:20 -07:00
parent 6b036f3350
commit cb11e66c59
3 changed files with 11 additions and 0 deletions

View File

@ -57,6 +57,10 @@ export interface ChannelOptions {
'grpc-node.max_session_memory'?: number;
'grpc.service_config_disable_resolution'?: number;
'grpc.client_idle_timeout_ms'?: number;
/**
* Set the enableTrace option in TLS clients and servers
*/
'grpc-node.tls_enable_trace'?: number;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;
}
@ -91,6 +95,7 @@ export const recognizedOptions = {
'grpc-node.max_session_memory': true,
'grpc.service_config_disable_resolution': true,
'grpc.client_idle_timeout_ms': true,
'grpc-node.tls_enable_trace': true,
};
export function channelOptionsEqual(

View File

@ -427,6 +427,8 @@ export class Server {
serverOptions,
creds._getSettings()!
);
secureServerOptions.enableTrace =
this.options['grpc-node.tls_enable_trace'] === 1;
http2Server = http2.createSecureServer(secureServerOptions);
http2Server.on('secureConnection', (socket: TLSSocket) => {
/* These errors need to be handled by the user of Http2SecureServer,

View File

@ -677,6 +677,7 @@ export class Http2SubchannelConnector implements SubchannelConnector {
connectionOptions = {
...connectionOptions,
...address,
enableTrace: options['grpc-node.tls_enable_trace'] === 1,
};
/* http2.connect uses the options here:
@ -760,6 +761,9 @@ export class Http2SubchannelConnector implements SubchannelConnector {
connectionOptions.servername = hostPort?.host ?? targetPath;
}
}
if (options['grpc-node.tls_enable_trace']) {
connectionOptions.enableTrace = true;
}
}
return getProxiedConnection(address, options, connectionOptions).then(