honestly just guess what it does. You're probably right.
README.md

tsbridge #

Go module bound to Kotlin with gomobile. Serves a webapp directory over HTTP (the repo's webapp/ by default) and reverse-proxies WebSocket upgrades to the configured Intiface Central WebSocket server.

The webapp is not embedded here: the handler serves whatever directory it is given (-webapp for the desktop runner; the Android app unpacks the webapp bundled in its APK assets, or a folder the user picked from phone storage), so the running webapp can be swapped without touching tsbridge.

Android interface workaround (tailscale#17311) #

On Android, tsnet.(*Server).Start fails with netlinkrib: permission denied: Go's net.Interfaces() opens netlink route sockets, which Android SELinux denies to apps (issue open as of 2026-10, https://github.com/tailscale/tailscale/issues/17311).

The workaround (ifgetaddrs_android.go) implements netmon.InterfaceGetter over libc getifaddrs(3) — permitted on Android, the same path java.net.NetworkInterface uses — and registers it via the public netmon.RegisterInterfaceGetter in init(). No forked tailscale, no custom toolchain, no JNI. Build-tagged android && cgo; other platforms use the default enumeration (ifgetaddrs_other.go).

Reference implementation mirrored: https://github.com/GlassOnTin/Haven/blob/main/rclone-android/go/tsbridge/tsbridge.go

Android constraints handled here #

  • Android has no /tmp and no TMPDIR: Start sets TMPDIR to the caller-provided cache dir before tsnet starts.
  • os.UserConfigDir() errors on Android: tsnet's Dir is always set explicitly to the caller-provided state dir (context.getFilesDir() on the Kotlin side).
  • gomobile binds only simple types: the exported surface is Start/Stop/ Status/ServePlain/SetCORS with strings/ints/bools; state is a package-level singleton and Status() returns JSON.
  • The server serves on :443 (userspace netstack needs no privileges) and additionally serves the same handler over plain HTTP on :80, so the webapp and its WebSocket proxy work at http://<domain>/ too. The webapp picks ws: or wss: from location.protocol, so no client-side change is involved. If the :80 listener cannot be set up the HTTPS listener keeps serving and the failure is logged in the status ring buffer.
  • / is dual-purpose, mirroring Intiface Central's own server (which accepts WebSocket upgrades on any path, and is dialed without one by clients such as Intiface Central desktop's Repeater mode): WebSocket upgrades on any path are reverse-proxied to Intiface on localhost, plain requests get the static webapp (and /healthz).
  • CORS is off by default and controlled by SetCORS(bool) (the Android app's "Allow other web pages" toggle, the desktop runner's -cors flag). When on, the request Origin is reflected on every response — including WebSocket handshakes, which browsers do not preflight — so any web page on any origin may open the proxy. Credentials are never granted, Vary: Origin guards caches, and preflight answers carry a deliberately short Access-Control-Max-Age (5 minutes) so browsers stop trusting the permissive policy shortly after the user turns it off.
  • TLS certs are provisioned by our own code (certs.go), not by tsnet's ListenTLS: on Android upstream stubs the localapi cert endpoint with 404 "disabled on android" (tailscale#18245), which makes ListenTLS unusable there. Instead we run the ACME dns-01 order ourselves with tailscale's tempfork/acme client against Let's Encrypt and publish the _acme-challenge TXT via the documented local.Client.SetDNS escape hatch. Certs + the ACME account key are cached under <stateDir>/certs/ (persistent → stays under issuance rate limits), and a renewal goroutine re-issues at 2/3 of the cert lifetime.
  • Start's authKey accepts a Tailscale OAuth client secret (tskey-client-...); tsnet's feature/oauthkey package (imported via the condregister side-effect import in tsnet v1.104.1) mints an auth key via the OAuth2 client-credentials flow. That requires AdvertiseTags to be non-empty, hence Start's tags parameter.

Pinned versions #

  • tailscale.com v1.104.1 (requires Go ≥ 1.27.1; devshell has Go 1.27.2)
  • golang.org/x/mobile v0.0.0-20261011034528-197770444867 (gomobile/gobind installed by the flake shell hook into .tools/bin, and added to go.mod as a tool directive as modern gomobile requires)
  • Vendored webapp dependency: buttplug@5.0.2 dist/web/buttplug.mjs, SHA-256 b88615f07a501191e44e083b0cbd47b20d0f979de8b71b8c53be37f8ea67c6d8

Build / test #

go test ./...     # handler + WS proxy + healthz unit tests
go vet ./...
gomobile bind -target=android -androidapi 26 -o ../app/libs/tsbridge.aar .