Commit Graph

397 Commits

Author SHA1 Message Date
Lorenzo Blasa
1d29e06b76 Use better API to return JSON from endpoint
Summary: ^

Reviewed By: antonk52

Differential Revision: D49537411

fbshipit-source-id: d5cabcf1c22d57fc47e1e80cbf0edb70effee308
2023-09-22 08:17:48 -07:00
Lorenzo Blasa
bdf5065f10 Expose info endpoint
Summary:
Expose an endpoint to retrieve server environment information.

We can use version information and process number to aid engineers with troubleshooting Flipper.

Reviewed By: antonk52

Differential Revision: D49537325

fbshipit-source-id: 511fe4441638f91cd35f13706ceeeb515051416b
2023-09-22 08:17:48 -07:00
Pascal Hartig
fcd21111a0 Do not prefer ipv4 dns results
Summary: This is the default from Node 17 onwards and should unblock problems we're seeing on some people's machines.

Reviewed By: lblasa

Differential Revision: D49415859

fbshipit-source-id: c15ab82e69db4916838228324a9739c95f3562f3
2023-09-22 06:25:35 -07:00
Lorenzo Blasa
b856180530 Use HTTP shutdown instead
Summary: Use the newly exposed HTTP shutdown API. It is simpler.

Reviewed By: antonk52

Differential Revision: D49499264

fbshipit-source-id: 2d81db1d1a66c0b7550ee1245e51d8f1a8671aa6
2023-09-21 06:59:22 -07:00
Lorenzo Blasa
6df27824b7 Expose HTTP shutdown API
Summary: Expose the shutdown API via the HTTP server.

Reviewed By: ivanmisuno

Differential Revision: D49496840

fbshipit-source-id: df2045edc89e9feabe74b4b513f973d137323d0f
2023-09-21 06:09:19 -07:00
Lorenzo Blasa
0540d240c0 Remove usage of server enabled
Summary: Used last year to GK server usage. This is obsolete so is safe to remove.

Reviewed By: ivanmisuno

Differential Revision: D49414625

fbshipit-source-id: 9eeff932c59c90dff829e4c6c83bad43a0fd74e3
2023-09-20 04:10:39 -07:00
Lorenzo Blasa
9e219b07d8 Fix Loading page
Summary:
The existing loading page was not behaving the way it was intended. The previous implementation triggered a page reload which made the whole retry mechanism useless.

Instead, a new endpoint was defined to expose whether the server is ready or not. Use this instead as a way of knowing whether we are good to reload the page.

Reviewed By: passy

Differential Revision: D49314749

fbshipit-source-id: eb67765d7deab8610fa5d31e710070da43a18c1c
2023-09-15 05:29:40 -07:00
Lorenzo Blasa
045ccec154 Host name verification is not needed
Summary:
There's no need to perform host name verification as we use token-based authentication.

So, remove it.

Original security review: https://docs.google.com/document/d/16iXypCQibPiner061SoaQUFUY9tLVAEpkKfV_hUXI7c/edit#heading=h.kpbj4pk75925

Reviewed By: passy

Differential Revision: D49313595

fbshipit-source-id: 9da1eefa87e5b774d653ab2c5db6f95c51af482d
2023-09-15 05:29:40 -07:00
Lorenzo Blasa
8062e2c9e5 Generate auth token
Summary: Generate auth token on whenever we load the secure server config,  and add more logs.

Reviewed By: antonk52

Differential Revision: D49272857

fbshipit-source-id: 1e549a8bfd7926e9a44b9480432e92ee3c0162b2
2023-09-14 07:04:59 -07:00
Lorenzo Blasa
2b4c631652 Certificate and token generation fixes
Summary:
A few things need to be done which are on this change:

- Certificate generation should execute as an atomic operation, hence, it needs to be synchronised.
- Do not generate client token as part of certificate generation. This causes a deadlock now.
- Add more logs for troubleshooting

Reviewed By: aigoncharov

Differential Revision: D49269624

fbshipit-source-id: 071a8e5b895198730b7d914cc4622837e9094e2f
2023-09-14 04:15:18 -07:00
Lorenzo Blasa
cf599f9c3c Move launch further down, temporarily
Summary: Attempt to fix an ongoing issue whereas there's a race condition generating certificates

Reviewed By: passy

Differential Revision: D49237915

fbshipit-source-id: 2383b20cb6ba786166d5e70206b5fff846ed1211
2023-09-13 11:52:46 -07:00
Lorenzo Blasa
4cdbfff7fb Remove useless tag
Summary: ^

Reviewed By: antonk52

Differential Revision: D49193961

fbshipit-source-id: a51bd8b274a7f6f3bf3cdd7d3ff665430bf7bc3a
2023-09-13 04:06:58 -07:00
Lorenzo Blasa
3292945887 Launch should be blocking and at a later stage
Summary: This should be a blocking call and done later as it depends on the FlipperServerConfig to be set.

Reviewed By: antonk52

Differential Revision: D49193650

fbshipit-source-id: 4f74ca5de30b7f992880bbb9032792fd713203b7
2023-09-13 04:06:58 -07:00
Lorenzo Blasa
93d94c9fc3 More logs around certificates and token generation
Summary: Useful for triaging defects

Reviewed By: passy

Differential Revision: D49186779

fbshipit-source-id: 743746444ce6e28753434a63d1bee2989cf4f66a
2023-09-13 04:06:58 -07:00
Pascal Hartig
cd392929e0 FLIPPER_DISABLE_KEYTAR env var to use in-memory impl
Summary: Changelog: FLIPPER_DISABLE_KEYTAR env var can be used to force in-memory implementation

Reviewed By: lblasa

Differential Revision: D49183501

fbshipit-source-id: 4ce886303678485673750417b09f272dd3f66623
2023-09-12 04:21:41 -07:00
Pascal Hartig
777632b841 Add logging and fallback for failing vpnless requests
Summary:
If a requests fails due to lack of allow-listing or other incompatibilities, we will now fall back to VPN mode while logging an error that will hopefully end up at the plugin owner.

For this, there's a new `vpnMode` option on every request that can also be used to enforce a particular type.

There's a lot of verbose logging that's turned off by default but very handy when debugging. Also potentially useful for plugin authors that are looking into request issues.

Reviewed By: lblasa

Differential Revision: D49023365

fbshipit-source-id: 755393063e379587feda9ae13973877780a1d987
2023-09-11 03:28:06 -07:00
Anton Kastritskiy
4439411d29 bump or ignore types packages
Reviewed By: LukeDefeo

Differential Revision: D48782825

fbshipit-source-id: 00c46fa609847272b48f8f4476291666e9251c95
2023-09-04 14:52:34 -07:00
Anton Kastritskiy
806d684ddc Script to verify @types/* versions
Summary:
We recently raised a concern that for some packages types/* version is different than the package we are using. This can cause runtime errors as typescript can suggest usage that no longer reflects current API of a library. To combat this issue we decided to add a CI check to verify that major versions of types and a libriary match.

This script will be refined if in the next few diffs

Reviewed By: LukeDefeo

Differential Revision: D48779652

fbshipit-source-id: 2a826ba9d00565563553f04cd809ae0638db6282
2023-09-01 09:54:49 -07:00
Lorenzo Blasa
819c75c126 Verify server certificates before returning existing token
Summary:
If the server certificates have expired, then the returned token will no longer be valid as soon as the certificates are renewed.

So, validate this before returning any existing token.

This was not an issue before, as launching used to be the last step during bootstrapping.

Reviewed By: antonk52

Differential Revision: D48902334

fbshipit-source-id: 2458aa0df806db245994ee742f42bff47a533e23
2023-09-01 04:52:09 -07:00
Lorenzo Blasa
4e7a6a70cc Server shutdown only if no errors
Summary:
The socket will close as the endpoint is terminating the connection.

Status code 1000 and 1001 are used for normal closures. Either the connection is no longer needed or the endpoint is going away i.e. browser navigating away from the current page.

WS RFC: https://www.rfc-editor.org/rfc/rfc6455

Reviewed By: LukeDefeo

Differential Revision: D48896696

fbshipit-source-id: 22070ae34b7f35d35589db06108feb718e73e866
2023-09-01 03:25:26 -07:00
Lorenzo Blasa
457767c7cc Ready needs to be able to handle asynchronous code
Summary:
A previous diff introduced the isReady state as to make it possible to serve HTML content sooner than we are ready.

This worked great on debugging. As I was testing a release, it was discovered that there was a race condition and the server was not ready when it was already handling upgrade events.

To solve this, I've added another state flag in the form of a promise.

This one, can be waited on. This is used then during upgrade events as we can safely wait until the server is ready to accept incoming connections before proceeding with the upgrade.

Problem is shown below:

{F1080003241}
{F1080003356}

Reviewed By: passy

Differential Revision: D48829453

fbshipit-source-id: e148a392bbe66dd91710e32871e270c8950e25c2
2023-08-30 09:52:00 -07:00
Lorenzo Blasa
2858259497 Launch early, even if not ready
Summary:
Flipper Launcher downloads, unpacks, launches Flipper, and closes itself.

This is fine except for the fact that Flipper may be initiating and thus there's a gap of a few seconds until engineers see the main Flipper UI.

This change improves this by launching earlier, even if just showing a loading page until Flipper is actually ready.

Reviewed By: passy, aigoncharov

Differential Revision: D48824479

fbshipit-source-id: aa6147a09f313d80592c9b08d089660ba73773a4
2023-08-30 05:08:26 -07:00
Lorenzo Blasa
3e8f94ceda iOS get devices/targets/simulators cleanup
Summary: ^

Reviewed By: passy

Differential Revision: D48781211

fbshipit-source-id: 71133c07d15ca6a380d85e582d55cbdb192b5a19
2023-08-30 04:24:05 -07:00
Lorenzo Blasa
0045f15e2a isAvailable to isIdbAvailable
Summary: Make it more clear what are we checking about.

Reviewed By: aigoncharov

Differential Revision: D48781145

fbshipit-source-id: c3c03b407dc7f47730a3fb80de769243768b34ec
2023-08-30 04:24:05 -07:00
Lorenzo Blasa
03c0874f30 Query devices should be async
Summary: ^

Reviewed By: aigoncharov

Differential Revision: D48781102

fbshipit-source-id: c987be90c7bca7dbab40a89b389ee86ef2230393
2023-08-30 04:24:05 -07:00
Pascal Hartig
d4d8c965eb Show iOS version in launcher
Summary:
A little hacky because we currently have too many implementations for getting devices but lblasa is working on cleaning this up. Once that's done, we should add some tests for this.

Changelog: Show the iOS version of simulators in the launcher window

Reviewed By: lblasa

Differential Revision: D48777923

fbshipit-source-id: 18846520feba8eb10b6417f87bd802ffaabb1dff
2023-08-29 04:55:46 -07:00
Lorenzo Blasa
ef6e3df9df Remove the client from error log
Summary: Removing this information from the error as it will cause duplicated error tasks.

Reviewed By: passy

Differential Revision: D48646678

fbshipit-source-id: 26e5525318b4720568275a5086df00f21b7d2836
2023-08-24 10:05:17 -07:00
Lorenzo Blasa
865d551f8e Increase max payload size
Summary: ^

Reviewed By: passy, antonk52

Differential Revision: D48644784

fbshipit-source-id: 2cd0aeed94c31553243e1b335adbd4089feb0d7e
2023-08-24 10:05:17 -07:00
Lorenzo Blasa
1360e906f8 Centralise sessionId to a dedicated place
Summary:
The sessionId is just uuid() which is held by the config. This changes moves that to a single place.

This achieves two goals:
1) Makes it very clear where is created and what value it holds
2) It allows us to know the sessionId even before the config is available. This becomes useful as we can start logging to Scribe earlier.

Reviewed By: passy

Differential Revision: D48601829

fbshipit-source-id: c54d86d76f0b58d2b59f8dd1c45d7f345c4a84c3
2023-08-24 06:18:39 -07:00
Lorenzo Blasa
6405a7bfdd Hook with FB logger
Summary:
This change replaces the existing logging infra with the one defined and exposed in flipper-server-core.

Functionality remains the same with the addition of having support for Scribe.

Reviewed By: aigoncharov

Differential Revision: D48515246

fbshipit-source-id: 7970f6ad069821ee4f15136adc8da40d0b1fb0c7
2023-08-24 06:18:39 -07:00
Lorenzo Blasa
87bf73f1d5 FBLogger for flipper-server-core
Summary: ^

Reviewed By: passy

Differential Revision: D48557327

fbshipit-source-id: 0112dec9a1a7f0afddcc459459a9278bbbeb3fc7
2023-08-24 06:18:39 -07:00
Pascal Hartig
bb4090f529 Make intern headers configurable
Summary: The one-off hack for slog makes this hard to refactor, so I've added a headers field, putting the caller in charge of this.

Reviewed By: LukeDefeo

Differential Revision: D48564065

fbshipit-source-id: f8e78e9b8597fd3131bf3741197e6179807ad5da
2023-08-23 07:40:49 -07:00
Pascal Hartig
d484fb964c Add CPE X2P lookup support
Summary:
Basically a one-to-one conversion of https://www.internalfb.com/code/fbsource/[3171372e9b534c2ea0f318800cbd6de421e9d2d1]/fbcode/common/rust/cpe/src/

This is the information we need to connect to the local x2p daemon that allows us to talk to interngraph without vpn.

Reviewed By: lblasa

Differential Revision: D48562550

fbshipit-source-id: 8abff11f8ef76b16f6700eb89edabdb284306bb1
2023-08-23 07:40:49 -07:00
Lorenzo Blasa
c93a781247 ScribeMessage can now be used instead
Summary: As the type is now defined in flipper-common, it can be used.

Reviewed By: antonk52

Differential Revision: D48557043

fbshipit-source-id: 3838a189e431718cd1438d2dad5d7034d34bb93b
2023-08-23 07:15:29 -07:00
Lorenzo Blasa
17cfa0e571 Session Id moved to server config
Summary:
Session Id should be shared between client and server, but it was defined deep in the client (redux store).

The proposed solution presented below is to move the session id to the server configuration. By doing this, it becomes available to both server and client VERY early in the application life-cycle for both Electron and non-Electron builds.

Reviewed By: LukeDefeo

Differential Revision: D48520367

fbshipit-source-id: ca959b27ab18b1a2e4cd2fac1d28545664f1b514
2023-08-22 05:16:20 -07:00
Pascal Hartig
7dad33a626 Fix keytar types
Summary: The linter otherwise wants us to remove `awaits` which are in fact required.

Reviewed By: lblasa

Differential Revision: D48467534

fbshipit-source-id: 355aee4bc22098086600b85edf58c8ed077b8aaf
2023-08-21 04:00:56 -07:00
Lorenzo Blasa
3f37d29b95 Reintroduce timeout and is production check
Summary:
For dev, let's not kill the server.
Also, reintroduce a timeout of 60 seconds before disconnecting.

Reviewed By: antonk52

Differential Revision: D48432317

fbshipit-source-id: bac6f67101e5be481af06a5ea6ccb3b3134c4075
2023-08-17 13:46:08 -07:00
Lorenzo Blasa
ff6f98fc0d Import File implementation
Summary: Implementation was missing for the browser. This provides a default implementation.

Reviewed By: aigoncharov

Differential Revision: D48311198

fbshipit-source-id: fd067600f571234e0fbccfb90853b62f175ff8fb
2023-08-14 11:33:06 -07:00
Lorenzo Blasa
b5ed57b7d0 Remove UDS and thus the need for a proxy server
Summary: This change removes the UDS support and thus the need for having a proxy server.

Reviewed By: antonk52

Differential Revision: D48265244

fbshipit-source-id: c76bb4afba63959ddd17901b3887aa278b000beb
2023-08-11 08:19:51 -07:00
Lorenzo Blasa
7f3f1c0507 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
2023-08-11 08:19:51 -07:00
Lorenzo Blasa
bdc2d5f6eb If there are no connected clients, shutdown immediately
Summary: Instead of delaying the shutdown by a set timer, immediately shutdown.

Reviewed By: antonk52

Differential Revision: D48264571

fbshipit-source-id: 5e6556f2ecafb7cf9a19b3075e72f2be1abf9f95
2023-08-11 08:19:51 -07:00
Lorenzo Blasa
f93da44ee5 Remove idb device polling record
Summary:
If listing devices is successful, then don't record the event
as this is triggered every X amount of seconds.

Reviewed By: antonk52

Differential Revision: D47995681

fbshipit-source-id: 2d0fa68fd7b9c4ce74bad9e8cc0296691d9b8880
2023-08-11 08:19:51 -07:00
Andrey Goncharov
3b99e386a2 Fix comment
Reviewed By: LukeDefeo

Differential Revision: D48191671

fbshipit-source-id: 6978e831f48ffe4e8a8c6e71b819205cb3868966
2023-08-09 14:15:33 -07:00
Lorenzo Blasa
4e998ac083 Get OS by inspecting command
Summary: Commands can be idb or adb. If no ClientQuery is provided, set the OS accordingly.

Reviewed By: antonk52

Differential Revision: D47990745

fbshipit-source-id: 3e38b6ecb0a8ea21e584c1d6eff6feb53dd2cfab
2023-08-02 07:56:17 -07:00
Lorenzo Blasa
2c24ec9f5d Add OS to record
Summary: OS will become useful later on, add it.

Reviewed By: antonk52

Differential Revision: D47989161

fbshipit-source-id: 3615544051b163b77f87e5c52e6ac9cae8c478d4
2023-08-02 07:56:17 -07:00
Lorenzo Blasa
d43173a8df adb kill-server
Summary: Introduce a new command to allow killing adb

Reviewed By: antonk52

Differential Revision: D47988522

fbshipit-source-id: bb4f17faa7f9b31b9d42e45c0ce39b3f5d98f4b3
2023-08-02 07:56:17 -07:00
Luke De Feo
eaf5b4c246 Dont kill flipper server when no clients connect and is dev
Summary: This is quite annoying and causes may un needed reboots of flipper server while developing

Reviewed By: antonk52

Differential Revision: D47949842

fbshipit-source-id: c2f18e16a4933e4209e74f51978cb7d05b80ee11
2023-08-01 10:32:29 -07:00
Lorenzo Blasa
430a42ec7a Send connectivity logs to scuba
Summary:
^

A dashboard to display the logs from a user session will be built next.

Reviewed By: antonk52

Differential Revision: D47944634

fbshipit-source-id: fb9e53981de5abb401c93c47cdec68f72c944b94
2023-08-01 03:45:05 -07:00
Lorenzo Blasa
830ac6eac9 All logs to be emitted
Summary: Error logs were missing, they're now reported.

Reviewed By: antonk52

Differential Revision: D47944591

fbshipit-source-id: a1f5515dded7c2e8955522e12554cd5f520d4c88
2023-08-01 03:45:05 -07:00
Lorenzo Blasa
143fe0e719 Cmd failures should be displayed as errors too
Summary:
Styles are applied depending on entry type. This was an issue when we had 'cmd' as a type too.

So, let's simplify and keep type to denote info, warning, or errors.

Later on we can add a different tag if we want to differentiate between logs, command, others.

Reviewed By: passy

Differential Revision: D47912857

fbshipit-source-id: 213a0768a95f63cbd692ba96f6745ab740346a58
2023-07-31 05:16:54 -07:00