syncthing-android: Android API level 30 breaks interface address discovery
API level 30(Android 11) will be mandatory starting November 2021 for apps on the PlayStore but seems to break golangs interface address discovery: https://github.com/golang/go/issues/40569
This seems to be an intended privacy related change which directly affects how golangs stdlib retrieves addresses for an interface:
NetworkInterface.getHardwareAddress()
returnsnull
for every interface.- Apps cannot use the
bind()
function onNETLINK_ROUTE
sockets.- The
ip
command does not return information about interfaces.- Apps cannot send
RTM_GETLINK
messages.
Source: https://developer.android.com/training/articles/user-data-ids#mac-11-plus
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 18 (14 by maintainers)
Alternative workaround, which I prefer over rooting:
192.168.0.231
.quic://192.168.0.231
instead ofdefault
.This turns discovery off completely.
https://github.com/golang/go/pull/61089 might solve our remaining problems on Android but so far local discovery should work with next syncthing-android release.
Did some research this morning, and it seems to me that the best way forward is to adopt the tailscale workaround, which uses the higher-level APIs recommended by the Android docs. Is it just lack of time preventing this from being addressed?
The workarounds are fine for home networks, but I’m currently traveling with two Android devices and using ST for syncing travel plans/documents The hotel wifis tend to disallow UPnP, so even global discovery doesn’t work. Of course I can still do the workarounds, but I have to redo them each time we return to the hotel which is tedious. Not complaining; just describing a use case. 😉
If this is still open after my vacation, I could contribute a PR.
For anyone struggling: running syncthing as root on Android is a workaround, but please remember that it’s very inadvisable.
Maybe the IP address discovery issue could be partially worked around if Syncthing detected that there’s an
ip
binary/symlink available (provided by e.g. Busybox (I tested that binary in a terminal and it returned everything needed, without root))? Of course, this still requires a rooted phone, but doesn’t require Syncthing to run as root on its own. Note that this is still just a workaround, not a solution for most users.We could have an endpoint to set extra external addresses for announcement though, in addition to one populating the discovery cache. I could even see other potential uses for it (peeps running it in k8s behind a load balancer etc).
But both local and global discovery take the source of the packets as the address if none is given, that should work for most cases on mobile as well? We just lose out on announcing our LAN addresses…
We already have a wrapper which is able to access this APIs. It’s probably easier to leverage our REST API and allow external sources to feed syncthing with discovered IPs.