mirror of https://github.com/grpc/grpc-node.git
Merge pull request #1381 from murgatroid99/grpc-js_proxy_fixes_final
grpc-js: Fix the final proxy bugs
This commit is contained in:
commit
4946b418b4
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@grpc/grpc-js",
|
"name": "@grpc/grpc-js",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"description": "gRPC Library for Node - pure JS implementation",
|
"description": "gRPC Library for Node - pure JS implementation",
|
||||||
"homepage": "https://grpc.io/",
|
"homepage": "https://grpc.io/",
|
||||||
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
|
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,8 @@ class SecureChannelCredentialsImpl extends ChannelCredentials {
|
||||||
}
|
}
|
||||||
|
|
||||||
_getConnectionOptions(): ConnectionOptions | null {
|
_getConnectionOptions(): ConnectionOptions | null {
|
||||||
return this.connectionOptions;
|
// Copy to prevent callers from mutating this.connectionOptions
|
||||||
|
return { ...this.connectionOptions };
|
||||||
}
|
}
|
||||||
_isSecure(): boolean {
|
_isSecure(): boolean {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ export function mapProxyName(
|
||||||
return {
|
return {
|
||||||
target: {
|
target: {
|
||||||
scheme: 'dns',
|
scheme: 'dns',
|
||||||
path: proxyInfo.address
|
path: proxyInfo.address,
|
||||||
},
|
},
|
||||||
extraOptions: extraOptions,
|
extraOptions: extraOptions,
|
||||||
};
|
};
|
||||||
|
|
@ -207,23 +207,33 @@ export function getProxiedConnection(
|
||||||
' through proxy ' +
|
' through proxy ' +
|
||||||
proxyAddressString
|
proxyAddressString
|
||||||
);
|
);
|
||||||
resolve({
|
|
||||||
socket,
|
|
||||||
realTarget: parsedTarget,
|
|
||||||
});
|
|
||||||
if ('secureContext' in connectionOptions) {
|
if ('secureContext' in connectionOptions) {
|
||||||
/* The proxy is connecting to a TLS server, so upgrade this socket
|
/* The proxy is connecting to a TLS server, so upgrade this socket
|
||||||
* connection to a TLS connection.
|
* connection to a TLS connection.
|
||||||
* This is a workaround for https://github.com/nodejs/node/issues/32922
|
* This is a workaround for https://github.com/nodejs/node/issues/32922
|
||||||
* See https://github.com/grpc/grpc-node/pull/1369 for more info. */
|
* See https://github.com/grpc/grpc-node/pull/1369 for more info. */
|
||||||
const cts = tls.connect({
|
const remoteHost = getDefaultAuthority(parsedTarget);
|
||||||
...connectionOptions,
|
|
||||||
host: getDefaultAuthority(parsedTarget),
|
const cts = tls.connect(
|
||||||
|
{
|
||||||
|
host: remoteHost,
|
||||||
|
servername: remoteHost,
|
||||||
socket: socket,
|
socket: socket,
|
||||||
}, () => {
|
...connectionOptions,
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
trace(
|
||||||
|
'Successfully established a TLS connection to ' +
|
||||||
|
options.path +
|
||||||
|
' through proxy ' +
|
||||||
|
proxyAddressString
|
||||||
|
);
|
||||||
resolve({ socket: cts, realTarget: parsedTarget });
|
resolve({ socket: cts, realTarget: parsedTarget });
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
cts.on('error', () => {
|
||||||
|
reject();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
resolve({
|
resolve({
|
||||||
socket,
|
socket,
|
||||||
|
|
|
||||||
|
|
@ -322,10 +322,11 @@ export class Subchannel {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
connectionOptions = Object.assign(
|
connectionOptions = {
|
||||||
connectionOptions,
|
...connectionOptions,
|
||||||
this.subchannelAddress
|
...this.subchannelAddress,
|
||||||
);
|
};
|
||||||
|
|
||||||
/* http2.connect uses the options here:
|
/* http2.connect uses the options here:
|
||||||
* https://github.com/nodejs/node/blob/70c32a6d190e2b5d7b9ff9d5b6a459d14e8b7d59/lib/internal/http2/core.js#L3028-L3036
|
* https://github.com/nodejs/node/blob/70c32a6d190e2b5d7b9ff9d5b6a459d14e8b7d59/lib/internal/http2/core.js#L3028-L3036
|
||||||
* The spread operator overides earlier values with later ones, so any port
|
* The spread operator overides earlier values with later ones, so any port
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue