-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FFI refactoring to support client-detected network changes #3343
Comments
Disclaimer: I've not looked at the client code much so take this with a grain of salt 😊 What I'd like to add here is that the clients should code their UI as a pure function of the state returned by connlib very much like MVC with the following "mapping":
This would have the advantage that the clients don't need to keep additional state but can "just" render something based on what connlib returns. Consequences of this design are:
|
I thought some more about this and what impact it may have. I realized that using this pattern, we can also solve a lot of awkwardness around device initialization on the various platforms:
This greatly simplifies the control-flow in connlib because we only need to initialize a new device based on an FD. In fact, that API can be Footnotes
|
list of routes does sound nice. Then the only diffing is in the client, or they could blow up the routing and re-do it, as a simpler implementation. Adding 1 route takes less than 1 ms on my laptop |
We can table the major refactoring for later, but the primary point of this issue is to handle client-detected network changes and propagate this to connlib to react appropriately. |
After chatting more with @conectado just now, we devised the minimum set of changes required to get network updates working reliably across all clients:
I'll take a stab at knocking out the Apple and Android side of this. @ReactorScram -- when that's done, it can be used as an example implementation to replicate for the Windows and Linux clients. @conectado will be starting on the connlib side to handle this within a few days. |
Closing due to discussion being settled on 3/12 |
Chatting with @thomaseizinger to optimize reconnects, we can improve reliability and simplify state management in the clients with some refactoring around how we handle state:
Session.connect
andSession.disconnect
) the clients can call from the app side:update(dns: [String], internet?: boolean)
that is called whenever the OS detects a network interface changeonTunnelReady
onSetInterfaceConfig
etc states into a singleonTunnelStateChange(state: ...)
callback that passes the tunnel state, including whether it's "connecting", "reconnecting", or "disconnected".With the changes above, connlib now manages tunnel state. When it receives a "command" (connect/disconnect/update) it reacts accordingly and then passes the
state
object back to the app. The app can then update UI and its state accordingly.Session.connect(...): Long
Session.update(dns: [String]): Long
Session.disconnect(): Long
onTunnelStateChange(state: struct): Int?
Scenarios to handle (can happen in any order at any frequency)
The text was updated successfully, but these errors were encountered: