Skip to content

feat: add Tor connectivity with embedded SOCKS5 proxy#59

Merged
barrydeen merged 1 commit intomainfrom
feat/tor-connectivity
Feb 27, 2026
Merged

feat: add Tor connectivity with embedded SOCKS5 proxy#59
barrydeen merged 1 commit intomainfrom
feat/tor-connectivity

Conversation

@barrydeen
Copy link
Copy Markdown
Owner

Summary

  • Embeds Tor runtime via kmp-tor, routing all network traffic (relay WebSockets, NIP-05, NIP-11, image loading, media uploads, zaps) through a SOCKS5 proxy when enabled
  • Centralizes OkHttpClient creation in HttpClientFactory with DNS leak prevention — custom Dns resolver forces hostname resolution through the SOCKS5 tunnel so the Tor exit node resolves DNS
  • Adds onion icon toggle in the navigation drawer (next to theme toggle) with status colors: purple when connected, spinner when bootstrapping, red on error
  • Supports .onion relay addresses when Tor is active, allows ws:// for onion hosts
  • Persists Tor state across app restarts, hot-swaps RelayPool clients on toggle

Test plan

  • Toggle Tor on in drawer — spinner appears during bootstrap, icon turns purple when connected
  • Verify relay connections succeed through Tor (check Console screen)
  • Toggle Tor off — relays reconnect directly
  • Kill and relaunch app with Tor previously enabled — Tor auto-starts
  • Add a .onion relay URL while Tor is on — should be accepted
  • Verify images load through Tor (slower but functional)

Route all network traffic through Tor when enabled — relay WebSockets,
NIP-05, NIP-11, image loading, media uploads, and zaps. Uses kmp-tor
to embed the Tor runtime with automatic SOCKS5 port discovery.

- Add TorManager singleton for Tor lifecycle management
- Add HttpClientFactory to centralize OkHttpClient creation with
  Tor proxy and DNS leak prevention (custom Dns resolver forces
  hostname resolution through SOCKS5 tunnel)
- Migrate all OkHttpClient creation sites to use HttpClientFactory
- Add Tor-aware Coil image loading via Call.Factory
- Support .onion relay addresses when Tor is active
- Add onion icon toggle in navigation drawer with status indication
- Persist Tor enabled state across app restarts
- RelayPool hot-swaps clients on Tor state changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@barrydeen barrydeen merged commit 123dd14 into main Feb 27, 2026
@barrydeen barrydeen deleted the feat/tor-connectivity branch March 4, 2026 01:28
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.

1 participant