Track secure connection attempts

Summary: Same as previous diff but for TLS attempts.

Reviewed By: antonk52

Differential Revision: D46220897

fbshipit-source-id: 9495c39edffbdebe0ba21ec7320b63bad8759dde
This commit is contained in:
Lorenzo Blasa
2023-05-26 08:02:12 -07:00
committed by Facebook GitHub Bot
parent 8065313949
commit 135d3e3aa8
2 changed files with 15 additions and 15 deletions

View File

@@ -213,7 +213,6 @@ export class ServerController
} }
onConnectionClosed(clientId: string) { onConnectionClosed(clientId: string) {
// TODO: track connections closed.
this.removeConnection(clientId); this.removeConnection(clientId);
} }
@@ -222,22 +221,20 @@ export class ServerController
} }
onSecureConnectionAttempt(clientQuery: SecureClientQuery): void { onSecureConnectionAttempt(clientQuery: SecureClientQuery): void {
// TODO: track secure connection attempt.
const strippedClientQuery = (({device_id, ...o}) => o)(clientQuery); const strippedClientQuery = (({device_id, ...o}) => o)(clientQuery);
let id = buildClientId({device_id: 'unknown', ...strippedClientQuery}); let id = buildClientId({device_id: 'unknown', ...strippedClientQuery});
const tracker = this.timestamps.get(id); const timestamp = this.timestamps.get(id);
if (tracker) { if (timestamp) {
this.timestamps.delete(id); this.timestamps.delete(id);
} }
id = buildClientId(clientQuery); id = buildClientId(clientQuery);
this.timestamps.set(id, { this.timestamps.set(id, {
secureStart: Date.now(), secureStart: Date.now(),
...tracker, ...timestamp,
}); });
this.logger.track( tracker.track(
'usage', 'app-connection-secure-attempt',
'trusted-request-handler-called',
(({csr, ...o}) => o)(clientQuery), (({csr, ...o}) => o)(clientQuery),
); );

View File

@@ -9,6 +9,14 @@
import {getLogger} from 'flipper-common'; import {getLogger} from 'flipper-common';
type AppConnectionPayload = {
app: string;
os: string;
device: string;
device_id: string;
medium: number | undefined;
};
type TrackerEvents = { type TrackerEvents = {
'server-started': {port: number; tcp: boolean}; 'server-started': {port: number; tcp: boolean};
'server-auth-token-verification': { 'server-auth-token-verification': {
@@ -18,13 +26,8 @@ type TrackerEvents = {
}; };
'server-socket-already-in-use': {}; 'server-socket-already-in-use': {};
'server-proxy-error': {error: string}; 'server-proxy-error': {error: string};
'app-connection-created': { 'app-connection-created': AppConnectionPayload;
app: string; 'app-connection-secure-attempt': AppConnectionPayload;
os: string;
device: string;
device_id: string;
medium: number | undefined;
};
}; };
class ServerCoreTracker { class ServerCoreTracker {