跪拜 Guibai
← All articles
Frontend

LocalSend Under the Hood: LAN Discovery, Token-Based Transfer, and a Default-HTTP Gotcha

By 王若风 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The discovery and consent flow LocalSend uses is the same pattern behind AirDrop and Nearby Share, but it works across every desktop and mobile OS and even from a browser. For anyone building LAN transfer tools, the default unencrypted HTTP in the share link is a concrete security decision: it works, but it exposes the transfer unless you enable HTTPS and solve certificate trust.

Summary

LocalSend v1.18.2 works by having each device broadcast its name and connection details on the local network, then having peers connect back to verify reachability and (if encrypted) check certificates before they appear in the device list. The transfer itself separates consent from content: the sender offers a file manifest, the receiver approves per-file, gets a session token for each allowed file, and only then does the sender push actual data. Integrity checks and duplicate upload blocks guard the transfer, and the receiver handles only one sender at a time, which serializes uploads from multiple devices.

The app's in-app browser share defaults to HTTP, not HTTPS, unless you flip an encryption switch and deal with certificate warnings. The separate Web client uses a different discovery path and is not subject to that default. Common failure points include router AP isolation, Windows network classification, Mac/iPhone local network permissions, and proxy or VPN interference; port 53317 must be open for TCP and UDP. The author's own Web client test hit a proxy problem, and the official troubleshooting list suggests temporary encryption or band/position checks when transfers are slow.

Takeaways
— LocalSend v1.18.2 discovers peers by broadcasting device name and connection info, then having peers connect back to verify reachability and certificate before listing them.
— The transfer flow sends a manifest first; the receiver approves individual files, receives a session token for each, and only then does the sender upload the content.
— A receiver processes one sender at a time; a second sender must wait until the current batch is done, including while waiting for user confirmation.
— The in-app browser share feature defaults to HTTP; encryption is available but requires enabling HTTPS and managing browser certificate trust.
— Troubleshooting: router AP isolation, Windows network type, Mac/iPhone local network permissions, VPN/proxy interference, and manual send via LAN IP are the main fixes.
— LocalSend uses port 53317 for TCP and UDP; firewalls must allow both.
— Slow transfers may come from signal and band, or encryption overhead; the official comparison method is to disable encryption on both sides on a trusted network with test files, then restore it.
— Android slow receive has a known file write performance issue linked to saf_stream, marked fixed but may still affect some versions.
Conclusions

LocalSend's design decouples approval from data transfer: the receiver can veto specific files before any content moves, a privacy pattern worth reusing in other file-sharing tools.

The default HTTP in the share link is a deliberate convenience/security trade-off; the article confirms it from source and tests, meaning anyone wrapping this tool must either force HTTPS or make the risk explicit to users.

The one-sender-at-a-time rule makes LocalSend a home tool, not a shared drop-off service; scaling it to multiple concurrent uploads would require a different receiver architecture.

Concepts & terms
AP isolation
A router setting that prevents wireless clients from communicating directly with each other, breaking LAN discovery and transfer.
Local Network permission
A macOS/iOS privacy setting that requires apps to ask for access to the local network before they can discover or be discovered by other devices.
saf_stream
A Flutter package for streaming content from SAF (Storage Access Framework) files; a performance issue in it can slow file writes on Android.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗