TCP is the only option so remove unused branches

Summary: As TCP is the only option, remove all branches.

Reviewed By: passy

Differential Revision: D48265093

fbshipit-source-id: 174527f05d8a841797fd95256e77fdeb9b2e6ad5
This commit is contained in:
Lorenzo Blasa
2023-08-11 08:19:51 -07:00
committed by Facebook GitHub Bot
parent 47b718d104
commit 7f3f1c0507
4 changed files with 7 additions and 22 deletions

View File

@@ -206,7 +206,6 @@ async function getFlipperServer(
const {readyForIncomingConnections} = await startServer({
staticPath,
entry: 'index.web.dev.html',
tcp: false,
port,
});

View File

@@ -30,7 +30,6 @@ type Config = {
port: number;
staticPath: string;
entry: string;
tcp: boolean;
};
type ReadyForConnections = (
@@ -151,11 +150,6 @@ async function startProxyServer(
// On Windows, a proxy is not created and the server starts
// listening at the specified port.
if (os.platform() === 'win32') {
if (!config.tcp) {
console.warn(
'No port was supplied and domain socket access is not available for non-POSIX systems, falling back to TCP',
);
}
return new Promise((resolve) => {
console.log(`Starting server on http://localhost:${config.port}`);
const readyForIncomingConnections = (
@@ -182,13 +176,11 @@ async function startProxyServer(
await fs.rm(socketPath, {force: true});
}
const proxyServer: proxy | undefined = config.tcp
? proxy.createProxyServer({
const proxyServer: proxy | undefined = proxy.createProxyServer({
target: {host: 'localhost', port: 0, socketPath},
autoRewrite: true,
ws: true,
})
: undefined;
});
console.log('Starting socket server on ', socketPath);
if (proxyServer) {
@@ -230,7 +222,6 @@ async function startProxyServer(
server.listen(socketPath, undefined, () => {
tracker.track('server-started', {
port: config.port,
tcp: config.tcp,
});
resolve();
});
@@ -275,8 +266,6 @@ function addWebsocket(server: http.Server, config: Config) {
// No origin header? The request is not originating from a browser, so should be OK to pass through
// If origin matches our own address, it means we are serving the page.
// Need the token or know that is UDS.
return process.env.SKIP_TOKEN_VERIFICATION ? true : verifyAuthToken(req);
} else {
// For now we don't allow cross origin request, so that an arbitrary website cannot try to
@@ -299,10 +288,8 @@ function addWebsocket(server: http.Server, config: Config) {
const options: ServerOptions = {
noServer: true,
maxPayload: WEBSOCKET_MAX_MESSAGE_SIZE,
verifyClient,
};
if (config.tcp) {
options.verifyClient = verifyClient;
}
const wss = new WebSocketServer(options);
server.on('upgrade', function upgrade(request, socket, head) {

View File

@@ -36,7 +36,7 @@ type ServerBootstrapPerformancePayload = {
type TrackerEvents = {
'server-bootstrap-performance': ServerBootstrapPerformancePayload;
'server-started': {port: number; tcp: boolean};
'server-started': {port: number};
'server-auth-token-verification': {
successful: boolean;
present: boolean;

View File

@@ -208,7 +208,6 @@ async function start() {
staticPath,
entry: `index.web${argv.bundler ? '.dev' : ''}.html`,
port: argv.port,
tcp: true,
});
const t4 = performance.now();