Skip to content
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

wip: re-architect how we initialize the TUN device #4159

Closed
wants to merge 3 commits into from

Conversation

thomaseizinger
Copy link
Member

Currently, the callbacks for initializing and updating the TUN device create a lot of back-and-forth control flow that is hard to follow. This PR presents the cornerstones of a different design that I deem simpler to understand.

The key differences are:

  • Tunnel has an update_tun function that allows setting a new TUN device. Essentially Tun is now just an AsyncRead + AsyncWrite so that could be further abstracted. I think that would be good because we end up with less conditional dependencies.
  • All platforms now use the callbacks to update the state about the device and routes. Receiving a callback for on_set_interface_config means the portal has given us new IPs. We set those IPs on the TUN device in a platform-specific way. For example, for Linux, this means talking to netlink, for Android and iOS/MacOS, this means forwarding to the main app.
  • The devices are initialized in a platform-specific way. For Linux, iOS and MacOS, we can initialize it right away as part of booting up the Session. For Android, we have to wait for the file-descriptor from the first callback.
  • I haven't looked closely at Windows yet but it also seems like we can initialize it right away there.

Copy link

vercel bot commented Mar 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
firezone ⬜️ Ignored (Inspect) Visit Preview Mar 20, 2024 2:45am

Copy link

github-actions bot commented Mar 15, 2024

Terraform Cloud Plan Output

Plan: 9 to add, 8 to change, 9 to destroy.

Terraform Cloud Plan

@thomaseizinger thomaseizinger force-pushed the refactor/connlib/no-error-on-tunnel-ready branch 3 times, most recently from a98c40d to 44200aa Compare March 19, 2024 00:11
Base automatically changed from refactor/connlib/no-error-on-tunnel-ready to main March 20, 2024 02:20
@thomaseizinger
Copy link
Member Author

Closing this in favor of several smaller PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant