Skip to content

request ACCESS_LOCAL_NETWORK when enabling open proxy on all interfaces#1748

Merged
bitmold merged 7 commits into
guardianproject:masterfrom
munzzyy:fix-lan-permission-request
Jul 6, 2026
Merged

request ACCESS_LOCAL_NETWORK when enabling open proxy on all interfaces#1748
bitmold merged 7 commits into
guardianproject:masterfrom
munzzyy:fix-lan-permission-request

Conversation

@munzzyy

@munzzyy munzzyy commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #1743

The "Open Proxy on All Interfaces" setting makes Tor bind its SOCKS port to 0.0.0.0 (TorConfig.kt), which on Android 17 needs the ACCESS_LOCAL_NETWORK permission. Right now we only ever request that permission from the kindness mode UPnP dialog, so flipping this setting on an API 37 device just produces a proxy that nothing on the LAN can actually reach - no prompt, no error, it just doesn't work.

What this does:

  • Moved needsAccessLocalNetworkPermission() out of UPnPDialogFragment and into NetworkUtils, so it's shared instead of duplicated. UPnPDialogFragment and SnowflakeProxyWrapper now call the shared version.
  • SettingsPreferenceFragment now hooks the "Open Proxy on All Interfaces" checkbox: turning it on triggers a permission request first (same grant / deny / "permanently denied -> app settings" flow the kindness dialog already uses), and the checkbox only gets checked once the permission is actually granted.
  • TorConfig.build() falls back to a localhost-only SOCKSPort if the preference is on but the permission isn't (e.g. revoked after the fact in system settings), so we never emit a 0.0.0.0 config nothing can reach.
  • One new string for the permission rationale toast.

Verified by reading through the existing kindness-mode permission flow and mirroring it exactly, and by checking every call site of the old UPnPDialogFragment.needsAccessLocalNetworkPermission (there were two: the dialog itself and SnowflakeProxyWrapper) to make sure both got updated. I don't have a Java/Gradle toolchain in this environment so I couldn't build or run this - I'd appreciate someone testing the actual permission dialog on an API 37 emulator/device before merge. I also haven't tested the LAN end-to-end (a second device actually connecting through the opened proxy), just that the config and permission flow line up.

Comment thread app/src/main/java/org/torproject/android/util/NetworkUtils.kt
@bitmold bitmold self-assigned this Jul 6, 2026
@bitmold bitmold added the Android 17 concerned with devices running API 37, new permissions and changes that broke after an OS upgrade label Jul 6, 2026
…es on Android 17+

the open proxy on all interfaces setting binds the SOCKS proxy to
0.0.0.0, which needs ACCESS_LOCAL_NETWORK on Android 17. we only asked
for that permission in kindness mode, so toggling this setting on API
37+ silently produced a proxy nothing on the LAN could reach.

moved the permission check out of UPnPDialogFragment into NetworkUtils
so both kindness mode and the settings screen share it. the settings
toggle now requests the permission before committing, same
grant/deny/repeated-denial flow as the kindness dialog. TorConfig also
falls back to a localhost-only SOCKSPort if the pref is on but the
permission isn't, so a revoked grant can't leave the proxy silently
unreachable.

fixes guardianproject#1743
@bitmold
bitmold force-pushed the fix-lan-permission-request branch from 503bc3c to c57d730 Compare July 6, 2026 17:12
@bitmold

bitmold commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Rebased with master and reviewing now...

bitmold added 6 commits July 6, 2026 13:20
- Repeat duplicating the preference key as a string literal
- Use @RequiresApi annotation for Android 17 code
- Only set the listener on the open proxy preference if API 37+
A Toast didnt display the whole text, and doesn't explain the immediate
prompting of the vague "Access Nearby Devices" system permission dialog
of duplicating it across UPnPFragment+SettingsPrefFragment, etc
revoked the permission outside of the app.
@bitmold

bitmold commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

@munzzyy Thank you so much for implementing this and for making your first contribution to Orbot! This was a very high quality PR and I'm very grateful for it. ⭐

Normally, I'd ask you to make some changes to this PR and provide feedback, but since we have a release coming out very soon - I made them myself. All of your core logic was solid, but I made the following changes/refactors:

  • Used an AlertDialog instead of a Toast when using the open proxy on all interfaces setting. You couldn't see the whole message as a Toast, and it disappears before showing the unfortunately very vague and scary "access nearby devices" system prompt Android 17 uses for local network access
  • Unset the preference in Orbot's settings UI if the user revoked it
  • Prefs.openProxyOnAllInterfaces now takes a Context and checks for the permission if API 37+. I moved your logic for this from TorConfig to Prefs.
  • Moved the now duplicated logic to open Orbot's settings to one place

I'm definitely open to any future improvements around this if you have further suggestions/opinions.

Thanks again for making Orbot better ❤️

@bitmold
bitmold merged commit 2730b64 into guardianproject:master Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Android 17 concerned with devices running API 37, new permissions and changes that broke after an OS upgrade

Projects

None yet

Development

Successfully merging this pull request may close these issues.

open proxy on all interface breaks on Android 17

3 participants