Support a custom port for the insecure connection flow

Summary:
1. Remove GK.get('comet_enable_flipper_connection') which does not seem to be needed anymore
2. Support custom ports for the insecure connection flow

Reviewed By: lblasa

Differential Revision: D33632891

fbshipit-source-id: 045d6886ea94e15bff38f2f61c7d5a2c56c39859
This commit is contained in:
Andrey Goncharov
2022-01-18 05:51:51 -08:00
committed by Facebook GitHub Bot
parent c5fa91459f
commit 3865a3d9a2
3 changed files with 43 additions and 7 deletions

View File

@@ -8,7 +8,10 @@
*/
import {FlipperServerConfig} from 'flipper-common';
import {parseFlipperPorts} from './utils/environmentVariables';
import {
parseEnvironmentVariableAsNumber,
parseFlipperPorts,
} from './utils/environmentVariables';
let currentConfig: FlipperServerConfig | undefined = undefined;
@@ -34,6 +37,7 @@ type ServerPorts = {
export function getServerPortsConfig(): {
serverPorts: ServerPorts;
altServerPorts: ServerPorts;
browserPort: number;
} {
let portOverrides: ServerPorts | undefined;
if (process.env.FLIPPER_PORTS) {
@@ -59,6 +63,17 @@ export function getServerPortsConfig(): {
}
}
const portBrowserOverride = parseEnvironmentVariableAsNumber(
'FLIPPER_BROWSER_PORT',
);
if (portBrowserOverride === undefined) {
console.error(
`Ignoring malformed FLIPPER_BROWSER_PORT env variable:
"${process.env.FLIPPER_BROWSER_PORT || ''}".
Example expected format: "1111".`,
);
}
return {
serverPorts: portOverrides ?? {
insecure: 8089,
@@ -68,5 +83,6 @@ export function getServerPortsConfig(): {
insecure: 9089,
secure: 9088,
},
browserPort: portBrowserOverride ?? 8333,
};
}

View File

@@ -12,7 +12,6 @@ import {
ClientDescription,
ClientQuery,
isTest,
GK,
buildClientId,
Logger,
UninitializedClient,
@@ -147,10 +146,9 @@ class ServerController extends EventEmitter implements ServerEventsListener {
TransportType.WebSocket,
);
if (GK.get('comet_enable_flipper_connection')) {
console.info('[conn] Browser server (ws) listening at port: ', 8333);
this.browserServer = await createBrowserServer(8333, this);
}
const browserPort = getServerPortsConfig().browserPort;
console.info('[conn] Browser server (ws) listening at port: ', browserPort);
this.browserServer = await createBrowserServer(browserPort, this);
}
/**