How Open Transfer apps find each other, pair, and send files directly to
the devices a person picks. Anything that speaks this protocol can join a
network of Open Transfer devices — the desktop apps, the Android app and the
CLI all run the same Python implementation (discovery.py, mesh.py,
mesh_api.py).
| Term | Meaning |
|---|---|
| app | A device running Open Transfer. Has a stable id (d- + 24 hex), an HTTP server, and announces itself. |
| owner | The person using an app on that device — requests from 127.0.0.1. Accepts or declines incoming files. |
| visitor | A browser on a device without the app (opened an app’s link / QR code). Gets an id w-… in a signed session cookie. The app it opened sends and receives on its behalf. |
flowchart LR
subgraph Wi-Fi
A[Mac app] <-- HTTP --> B[Windows app]
A <-- HTTP --> C[Android app]
B <-- HTTP --> C
P((Phone browser)) -- opens link of --> C
end
Apps talk to each other directly. A visitor’s files travel visitor → its app → receiver (one hop through the app it is connected to).
239.255.77.77, port 47823 (admin-scoped, TTL 1 — never leaves the LAN).{"app": "open-transfer", "v": 1, "type": "announce",
"id": "d-3f…", "name": "Sonu’s MacBook", "form": "computer", "platform": "macos",
"port": 5000, "rev": 7, "ver": "3.0.0"}
type is announce | reply | find | bye. The peer’s address is the
datagram’s source IP, never a field in the packet. A bye counts at once
only from the address we hold for that device; from any other address we say
hello to the device there first, and it’s gone only if it doesn’t answer. rev changes when the
app’s visitors or name change, prompting others to fetch its info.
find — “whoever has Add device open, answer”: {"type": "find", "id": "d-…"}.
Nothing about the code is sent. An app whose Add device screen is open answers
with a reply, and its announcements and /info carry "pairing": true while
it stays open.
Multicast is often blocked (guest Wi-Fi, some routers, Docker). So apps also:
POST /api/devices, --peer HOST:PORT), andGET /info (0.8 s timeout, their
own port, 5000 and known devices’ ports): when entering a code finds
nobody, and when their own addresses change (a hotspot, a new lease) while
a paired device isn’t here. A paired device found that way moves only on
proof (§4).An app’s addresses are those of its interfaces too, not just the route out: on a device that is the hotspot, the hotspot address is often on neither. Mobile-data, VPN and container interfaces are left out.
An app is nearby while it was heard from in the last 15 s; unpaired apps are forgotten after 2 minutes, paired ones stay listed as “Not nearby”.
All under /api/p2p/v1, JSON unless noted. No PIN is needed (the PIN guards
the web UI); every transfer still needs the receiver’s consent. Requests
between paired apps carry a signature (§4).
| Request | Purpose |
|---|---|
GET /info |
{id, name, form, platform, port, version, accepts, visitors: [{id, name, form, platform}]} (visitors hidden when a PIN is set and the caller isn’t paired) |
POST /hello body = caller’s info |
Registers the caller (address = TCP peer address); returns /info plus you: {reachable} once it has tried to reach the caller — how a PC learns that others can’t connect to it (usually its firewall) |
POST /offers |
Offer files (below) → 201 {id, secret, state, reason} (reason says why, when it is declined straight away) |
GET /offers/<id> + X-OT-Secret |
{state, reason, files: [{state, received}]} |
PUT /offers/<id>/files/<n> + X-OT-Secret, Content-Length |
Raw file bytes → 201 {file} (small files) |
PUT /offers/<id>/files/<n> + X-OT-Secret, Content-Range |
One 2 MiB piece of a big file → 308 {received, ranges} until complete, then 201. Pieces may arrive in any order; the receiver stages them sparsely and publishes atomically |
GET /offers/<id>/files/<n>/status + X-OT-Secret |
Staged bytes/ranges for one incoming file (sender resumes the missing pieces) |
DELETE /offers/<id> + X-OT-Secret |
Sender cancels |
POST /pair/begin, POST /pair/prove |
Pairing (§3) |
POST /unpaired (signed) {id} |
The sender unpaired this device: it forgets the sender too (here only, not its sync network) and the owner’s page says “X unpaired this device. Pair again…”. An unsigned or forged one is 403. A signed offer from an app this one no longer trusts gets 403 peer_unpaired (“Pair again to send to it”), never a plain or unverified fallback |
POST /clip (signed) |
A clipboard item shared by hand (both sides must allow each other) |
POST /sync (signed) {env} |
A sync/1 envelope: clip, introduction, revocation or join, sealed for this device |
POST /sync/forward (signed) {to, env} |
Pass a sealed clip on to to (one hop) when the sender can’t reach it |
POST /api/p2p/v1/offers
{"from": {"id": "d-sender…", "name": "Gaming PC", "form": "computer", "platform": "windows", "port": 5000},
"origin": {"id": "w-visitor…", "name": "Pixel 8", "form": "phone", "platform": "android"},
"to": "d-receiver…",
"files": [{"name": "IMG_0001.jpg", "size": 2481331, "mime": "image/jpeg"}]}
from is the app making the request; origin is who is actually sending
(the app’s owner, or one of its visitors).to is the receiving app’s own id (its owner) or one of its visitors.--max-size up front (state: "declined" with a reason if they don’t fit).kx (its per-run X25519 key, in /info and
hellos) the offer carries
"enc": {"v": 2, "salt": "<64 hex>", "eph": "<a fresh X25519 key>", "kx": "<the receiver's key it used>", "meta": "<sealed names>"}
and the receiver answers "enc": 2, "eph": "<its fresh X25519 key>", "confirm": "<HMAC>":
a handshake per transfer, whose session key encrypts every file
(ot-file/2). Between paired apps the offer is
signed and the handshake is keyed by the pair key too (authenticated);
between unpaired apps it isn’t (“encrypted, not verified”). The plain
files carry placeholder names. The PUT body is the file’s AES-256-GCM
records (Content-Length = size + 16 per 64 KiB record); with
Content-Range the range stays in plaintext positions and the body is
those whole records. /verify takes {"mac": …} instead of the bare
checksum. A kx from an earlier run is refused (400). If the receiver
advertised kx and the answer lacks "enc": 2 or a valid confirm, the
sender refuses and withdraws the offer.States: pending → accepted → receiving → done, or declined,
expired (no answer in 120 s), canceled, failed. Offers to an owner from
a paired app (and with --auto-accept) start as accepted. With
--paired-only, offers from unpaired apps are refused (403). With
“Encrypted transfers only” (--encrypted-only or the owner’s switch), an
offer without a usable enc block is refused (403 encrypted_only, with
what to do), and the sender doesn’t offer to an app it can’t encrypt to.
The sender polls GET /offers/<id> until it leaves pending, then uploads
each file with PUT. The receiver streams it to a .part file and publishes
it atomically; the byte count must equal the offered size. If the receiver
cancels, further reads fail and the upload gets 410.
The sender’s own browser uploads each file once to its app
(PUT /api/send/<job>/files/<n>). The app streams the bytes to every
accepting receiver at the same time — each receiver has its own thread and a
bounded queue; a receiver that takes no data for 60 s is dropped without
stalling the others. Nothing is staged on the sender’s disk.
When the receiver is a browser (a visitor) and the sender is a page too (any visitor, or an app’s own window), the file goes straight between the two browsers over a WebRTC data channel; the apps only carry the two connection messages:
sender page → its app POST /api/signal {job, target, kind: "offer", sdp}
its app → receiver's app POST /api/p2p/v1/signal {dir: "to_receiver", session, secret, kind, sdp, n, mac}
receiver page ← its app GET /api/signals (announced by "signals": n in /api/state)
receiver page → its app POST /api/signal {session, kind: "answer", sdp}
… → sender's app POST /api/p2p/v1/signal {dir: "to_sender", job, target, secret, kind, sdp, n, mac}
409 otherwise), and only from its two ends:
app-to-app messages carry the offer’s secret.n (1, 2, … per direction) and
mac = HMAC-SHA256 under HKDF(transfer key, salt, "open-transfer-signal/1|sender|receiver|target")
of the JSON array [dir, receiver's session id, sender's job id, target, kind, sdp, n].
A missing or wrong MAC, or an n not above the last one taken, is 403:
the SDP (DTLS fingerprint, ICE candidates) can’t be changed, moved to another
transfer or receiver, or replayed (encryption.md).
A plain transfer (an older app) has no MAC, as before..local candidates included).{"t":"file", i, name, size, mime}, raw 64 KiB
chunks with back-pressure, {"t":"end", i}; the receiver answers
{"t":"done", i} and reports progress to its app
(POST /api/incoming/<id>/direct). The sender reports its side with
POST /api/send/<job>/targets/<id>/direct (trying / progress / done /
failed); while a target is trying the app doesn’t stream to it.failed and the file goes through the apps as usual.Blob) until saved, so
direct transfers are capped at 1 GB; larger ones go through the apps.Pairing runs SRP-6a (RFC 5054: 2048-bit group, SHA-256) over the
short-lived 6-digit code, and leaves both apps with a shared 32-byte key. A is
the app showing the code, B the one entering it; the SRP identity is
"<idA>|<idB>".
B → A POST /pair/begin {device: B-info}
A → B {salt, b: B (hex), device: A-info}
B → A POST /pair/prove {id: B, a: A (hex), m1: M1}
A → B {m2: M2}
key = HMAC-SHA256(K, "open-transfer-pair-key/2|<idA>|<idB>")
K is SRP’s session key; M1 and M2 prove each side has it. Someone who
sees every message can’t test a guess offline (not even the right code), and
someone pretending to be A or B gets one guess per attempt.
A accepts the code only while its Add device screen is open: the page
renews a 30-second window while it shows, and opening it shows a fresh code.
A rate-limits proofs (5 per minute per address) and shows a new code after 10
wrong guesses, after every successful pairing, and every 10 minutes. Keys are
stored in <state>/trusted.json, sealed with a vault key from the OS keystore
(encryption.md). An app from before SRP answers
/pair/begin with 404, and B says to update it.
Entering a code without an address: B sends a multicast find and asks every
device it knows for /info, then runs SRP with those showing "pairing": true
(devices it isn’t paired with first).
The QR code in “Add a device” is http://<ip>:<port>/?pair=<code> (+ &join=<token> with a PIN set: 10 minutes, never the PIN).
Every app’s Scan its QR code (under Add device → Enter a code) reads it with the device’s camera and pairs as above: the Android app with its own scanner, the desktop windows and browsers with any camera they have (built-in or USB, switchable), decoding with BarcodeDetector or, where there’s none, jsQR. The camera is asked for only when a scan starts and let go when it ends (found, Cancel, the sheet closed, the page hidden); entering the code is always there. A phone camera simply opens it,
which signs that browser in as a trusted visitor (its sends to the owner
are accepted automatically).
Requests from a paired app carry:
X-OT-From: d-sender…
X-OT-Auth: <unix time>:<hex HMAC-SHA256(key, "open-transfer/1\n<time>\n<METHOD>\n<path>\n<sender>\n<sha256(body)>")>
Receivers accept signatures within ±120 s and refuse a signature they have already seen. A valid signature makes an offer from that app’s owner auto-accepted; anything else is treated as a stranger (asked first).
Anyone on the Wi-Fi can send an announcement carrying a paired app’s id, so for a paired app the address (and anything else the packet says) changes only on proof:
POST /hello it signed (§4) arriving from the new address, orPOST /hello there with challenge (random hex) and to (the host:port
it dialled). The answer must carry
proof = hex HMAC-SHA256(key, "open-transfer-move/1|<challenge>|<prover>|<verifier>|<to>").
An app answers only when to is one of its own addresses and ports, so a
challenge relayed to the real app proves nothing for the relay’s address.
At most one challenge per app and address every 30 s.Apps that aren’t paired move as before (there’s no key to prove anything with). Older apps don’t answer challenges; their own signed hellos still move them.
relay-chunks/, and the sending app forwards
big files to each receiving app piece-by-piece with per-piece retry..zip through the normal pipeline.