Review fixes

This commit is contained in:
Segev Finer 2023-10-31 00:19:32 +02:00
parent 1f148e9349
commit 0854192dba
2 changed files with 9 additions and 5 deletions

View File

@ -30,6 +30,7 @@ import {
import { ChannelOptions } from './channel-options';
import { GrpcUri, parseUri, splitHostPort, uriToString } from './uri-parser';
import { URL } from 'url';
import { DEFAULT_PORT } from './resolver-dns';
const TRACER_NAME = 'proxy';
@ -189,16 +190,19 @@ export function getProxiedConnection(
if (parsedTarget === null) {
return Promise.resolve<ProxyConnectionResult>({});
}
const targetHostPost = splitHostPort(parsedTarget.path);
if (targetHostPost === null) {
const splitHostPost = splitHostPort(parsedTarget.path);
if (splitHostPost === null) {
return Promise.resolve<ProxyConnectionResult>({});
}
const hostPort = `${splitHostPost.host}:${
splitHostPost.port ?? DEFAULT_PORT
}`;
const options: http.RequestOptions = {
method: 'CONNECT',
path: targetHostPost.host + ':' + (targetHostPost.port != null ? targetHostPost.port : '443'),
path: hostPort,
};
const headers: http.OutgoingHttpHeaders = {
Host: targetHostPost.host + ':' + (targetHostPost.port != null ? targetHostPost.port : '443'),
Host: hostPort,
};
// Connect to the subchannel address as a proxy
if (isTcpSubchannelAddress(address)) {

View File

@ -43,7 +43,7 @@ function trace(text: string): void {
/**
* The default TCP port to connect to if not explicitly specified in the target.
*/
const DEFAULT_PORT = 443;
export const DEFAULT_PORT = 443;
const DEFAULT_MIN_TIME_BETWEEN_RESOLUTIONS_MS = 30_000;