Skip to content

Commit

Permalink
Merge pull request #2507 from murgatroid99/grpc-js_tls_trace
Browse files Browse the repository at this point in the history
grpc-js: Add channel option to enable TLS tracing
  • Loading branch information
murgatroid99 authored Jul 31, 2023
2 parents 8f1a48c + cb11e66 commit ff25a75
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/grpc-js/src/channel-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions packages/grpc-js/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,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,
Expand Down
4 changes: 4 additions & 0 deletions packages/grpc-js/src/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ export class Http2SubchannelConnector implements SubchannelConnector {
connectionOptions = {
...connectionOptions,
...address,
enableTrace: options['grpc-node.tls_enable_trace'] === 1,
};

/* http2.connect uses the options here:
Expand Down Expand Up @@ -795,6 +796,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(
Expand Down

0 comments on commit ff25a75

Please sign in to comment.