mirror of https://github.com/grpc/grpc-node.git
grpc-js: commenting working for node issue 32922
This commit is contained in:
parent
11965fb0af
commit
b9e84f499f
|
@ -22,9 +22,9 @@ import { getDefaultAuthority } from './resolver';
|
||||||
import { parseTarget } from './resolver-dns';
|
import { parseTarget } from './resolver-dns';
|
||||||
import { Socket } from 'net';
|
import { Socket } from 'net';
|
||||||
import * as http from 'http';
|
import * as http from 'http';
|
||||||
import * as http2 from 'http2';
|
|
||||||
import * as tls from 'tls';
|
import * as tls from 'tls';
|
||||||
import * as logging from './logging';
|
import * as logging from './logging';
|
||||||
|
import { SecureClientSessionOptions } from 'http2'
|
||||||
import {
|
import {
|
||||||
SubchannelAddress,
|
SubchannelAddress,
|
||||||
isTcpSubchannelAddress,
|
isTcpSubchannelAddress,
|
||||||
|
@ -161,7 +161,7 @@ export interface ProxyConnectionResult {
|
||||||
export function getProxiedConnection(
|
export function getProxiedConnection(
|
||||||
address: SubchannelAddress,
|
address: SubchannelAddress,
|
||||||
channelOptions: ChannelOptions,
|
channelOptions: ChannelOptions,
|
||||||
connectionOptions: http2.SecureClientSessionOptions
|
connectionOptions: SecureClientSessionOptions
|
||||||
): Promise<ProxyConnectionResult> {
|
): Promise<ProxyConnectionResult> {
|
||||||
if (!('grpc.http_connect_target' in channelOptions)) {
|
if (!('grpc.http_connect_target' in channelOptions)) {
|
||||||
return Promise.resolve<ProxyConnectionResult>({});
|
return Promise.resolve<ProxyConnectionResult>({});
|
||||||
|
@ -206,9 +206,11 @@ export function getProxiedConnection(
|
||||||
' through proxy ' +
|
' through proxy ' +
|
||||||
proxyAddressString
|
proxyAddressString
|
||||||
);
|
);
|
||||||
// The proxy is connecting to a TLS server, so upgrade
|
|
||||||
// this socket connection to a TLS connection.
|
|
||||||
if ('secureContext' in connectionOptions) {
|
if ('secureContext' in connectionOptions) {
|
||||||
|
/* The proxy is connecting to a TLS server, so upgrade this socket
|
||||||
|
* connection to a TLS connection.
|
||||||
|
* This is a workaround for https://github.com/nodejs/node/issues/32922
|
||||||
|
* See https://github.com/grpc/grpc-node/pull/1369 for more info. */
|
||||||
const cts = tls.connect({
|
const cts = tls.connect({
|
||||||
...connectionOptions,
|
...connectionOptions,
|
||||||
host: getDefaultAuthority(realTarget),
|
host: getDefaultAuthority(realTarget),
|
||||||
|
|
|
@ -312,15 +312,15 @@ export class Subchannel {
|
||||||
connectionOptions.createConnection = (authority, option) => {
|
connectionOptions.createConnection = (authority, option) => {
|
||||||
if (proxyConnectionResult.socket) {
|
if (proxyConnectionResult.socket) {
|
||||||
return proxyConnectionResult.socket;
|
return proxyConnectionResult.socket;
|
||||||
|
} else {
|
||||||
|
/* net.NetConnectOpts is declared in a way that is more restrictive
|
||||||
|
* than what net.connect will actually accept, so we use the type
|
||||||
|
* assertion to work around that. */
|
||||||
|
return net.connect(this.subchannelAddress);
|
||||||
}
|
}
|
||||||
/* net.NetConnectOpts is declared in a way that is more restrictive
|
|
||||||
* than what net.connect will actually accept, so we use the type
|
|
||||||
* assertion to work around that. */
|
|
||||||
return net.connect(this.subchannelAddress);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
connectionOptions = Object.assign(
|
connectionOptions = Object.assign(
|
||||||
connectionOptions,
|
connectionOptions,
|
||||||
this.subchannelAddress
|
this.subchannelAddress
|
||||||
|
@ -416,6 +416,10 @@ export class Subchannel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private startConnectingInternal() {
|
private startConnectingInternal() {
|
||||||
|
/* Pass connection options through to the proxy so that it's able to
|
||||||
|
* upgrade it's connection to support tls if needed.
|
||||||
|
* This is a workaround for https://github.com/nodejs/node/issues/32922
|
||||||
|
* See https://github.com/grpc/grpc-node/pull/1369 for more info. */
|
||||||
const connectionOptions: http2.SecureClientSessionOptions =
|
const connectionOptions: http2.SecureClientSessionOptions =
|
||||||
this.credentials._getConnectionOptions() || {};
|
this.credentials._getConnectionOptions() || {};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue