Code Monkey home page Code Monkey logo

Comments (5)

thomaseizinger avatar thomaseizinger commented on May 28, 2024

I think the following idea is relevant here: #3343 (comment).

from firezone.

jamilbk avatar jamilbk commented on May 28, 2024

This would be a one-off callback from connlib -> JVM, probably wouldn't need to updateTunnelState?

from firezone.

thomaseizinger avatar thomaseizinger commented on May 28, 2024

This would be a one-off callback from connlib -> JVM

I think we should not do one-off callbacks. In fact, I think the only "callback" we should do is updateTunnelState. I am saying "callback" because I have this vision that it is not implemented as a callback but instead, the connlib interface is essentially a Stream<Item = State> that gets continuously read by client-specific crates (like connlib-android). These crates can then either use a callback or something else to talk across the FFI boundary1.

We should really try to implement the clients such that they always respond to state updates. In this particular case, the Android app knows when it is creating a file descriptor (when it creates the new VPN service), it doesn't need to be told by connlib when to do that :)

The goal of what I linked above is that:

  • connlib only ever emits its current state
  • clients display that
  • user input calls "commands" on the connlib session
  • client state only changes as a result of a new connlib state

If we keep the data flow unidirectional like this, it will be very difficult to program bugs into the client! :)

Footnotes

  1. On Windows for example, the stream could directly be read by the client, no need for going through a callback-based interface. Even on other platforms, one could imagine to just return an Iterator or directly the Stream and the client-code does the polling.

from firezone.

jamilbk avatar jamilbk commented on May 28, 2024

@thomaseizinger Yeah that makes sense.

This is a platform-specific thing needed on Android for protecting the datagram socket for each channel that gets opened, not the file descriptor (we already call protect on that).

Apple's network stack already does this for us, and on Linux we can perform this directly with fwmark.

On Android however we can only do it on the JVM side of the boundary.

Would this mean issuing a state update from connlib -> JVM for each channel we need to open? That would be a no-op for the other platforms?

Maybe it'll help to start defining the schema for the state object connlib sends back. The UDP datagram socket could be an optional field sent to the JVM.

from firezone.

thomaseizinger avatar thomaseizinger commented on May 28, 2024

Ah I see! Once snownet is integrated, we only have two UDP file-descriptors, one for IP4 and one for IP6 but yes, we could make them part of the state so clients have access to them.

Maybe it'll help to start defining the schema for the state object connlib sends back. The UDP datagram socket could be an optional field sent to the JVM.

Unless we plan to emitting state updates prior to launching the tunnel, we should always have two defined as binding to the sockets is pretty much the very first thing we do.

from firezone.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.