Skip to content

Conversation

doromaraujo
Copy link
Collaborator

@doromaraujo doromaraujo commented Oct 8, 2025

Describe your changes

Allows user to toggle network resources on android client via exported functions.

Since we can't update the routes table on android's tun interface after creating a VPN when a network route change is detected, this also exports a function to renew the tun.Device's file descriptor used in android devices with a new implementation of WireGuard's tun.Device interface.

RenewableTUN is used in place of the created unmonitored tun on client/iface/device/device_android's Create function when passing a tun.Device to WGTunDevice's filteredDevice field. The unmonitored tun is added as a device to RenewableTUN, which manages a queue of tun.Devices internally.

Every call to a tun.Device method implemented by RenewableTUN uses the latest queued tun.Device's implementation.

When renewing a file descriptor in device_android, a new unmonitored tun is created with it, then it is added to RenewableTUN, deferring closure of the oldest tun.Device managed by it.

This also fixes a bug that didn't allow android clients to properly save its current profile's state with the same approach
used in iOS.

Issue ticket number and link

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

pappz and others added 20 commits September 23, 2025 19:29
To return information regarding if the network route is selected for a
given peer or not
Android has the same limitation as iOS in regard to file creation, so
it can't create the state file at the default location returned by
ServiceManager's GetStatePath (/var/lib/netbird/state.json)
Added to iface_create.go and iface_create_darwin.go
Since this is only used in android's context, it throws an error
when those implementations are called
…paths

This was done to lower the amount of parameters passed to
android/client's NewClient function
Copy link

sonarqubecloud bot commented Oct 9, 2025

@doromaraujo doromaraujo requested a review from pappz October 9, 2025 03:14
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.

2 participants