Skip to content

AirDrop to the PC - #9

Merged
betoxf merged 1 commit into
mainfrom
feat/airdrop-to-pc
Oct 24, 2026
Merged

betoxf merged 1 commit into
mainfrom
feat/airdrop-to-pc

Conversation

@betoxf

@betoxf betoxf commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Stacked on #8 (it builds on that branch; GitHub retargets this to main when #8 merges).

What changes

Files AirDropped to the Mac move on to the PC's Downloads folder when you were working on the PC. Windows can't receive AirDrop, so the Mac relays it:

  • The Mac watches ~/Downloads for new files that AirDrop marked (quarantine agent sharingd). Normal downloads are left alone, and so is anything that was there before MagicInput started.
  • Once a file stops growing, the Mac offers it to the PC. The PC takes it if the Mac's user is working on the PC (the Mac's pointer or keyboard is there), or if the PC's own keyboard or mouse was used more recently than the Mac's. When the PC's input is driving the Mac, the file stays on the Mac.
  • The PC saves it in Downloads under a safe, free name (photo (2).heic if taken) and shows it in Explorer. After the PC confirms it has the whole file, the Mac removes its copy. If anything fails, the file stays on the Mac.
  • airdrop = "auto" | "always" | "never" in the Mac's config (default auto).

Transport: each file goes over a TCP connection of its own, with the same pairing-code encryption. It opens with Offer instead of a hello, then sends Data pieces and gets a Received receipt back, so a big file never holds up the pointer. The control connection doesn't change and there's no protocol bump. A PC on 0.5.0 rejects the offer, and the file stays on the Mac.

Validation

  • cargo test: 20 passed. New tests: a 150 KB file crosses in pieces and lands under a free name with no part file left over; a declined offer leaves the file with the sender; unsafe names (../, :*?, CON) are cleaned.
  • cargo check --target x86_64-pc-windows-gnu: no warnings.
  • On the real Mac and PC: a simulated AirDrop (a 300 KB file with the sharingd quarantine mark) moved from the Mac's Downloads to the PC's within a few seconds with the same SHA-256. The PC logged its decision (used 14 s ago here, 30 min ago there). A file without the mark stayed on the Mac. A real AirDrop from an iPhone is still to be tried.

🤖 Generated with Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agentic security review of the AirDrop-to-PC relay found one medium issue: received files are written to Downloads without preserving OS origin marks (MOTW/quarantine).

Open in Web View Automation 

Sent by Cursor Security Agent: Security Reviewer

Comment thread src/net.rs
let name = safe_name(name);
let part = dir.join(format!("{name}.{}.magicinput", PART.fetch_add(1, Ordering::SeqCst)));
let r = (|| -> Res<PathBuf> {
let mut file = File::create(&part)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Agentic Security Review
Severity: MEDIUM

Inbound AirDrop files are written into Downloads with File::create and then revealed in Explorer/Finder. The send path only relays files that already carry a macOS sharingd quarantine mark, but that origin mark is not copied onto the saved file (no Windows Zone.Identifier / MOTW, no com.apple.quarantine on the receiver). After a successful receipt the Mac copy is deleted, so the quarantined original is gone.

Impact: A nearby AirDrop sender (including AirDrop set to Everyone) can land an executable or Office/HTML payload in the PC Downloads folder without SmartScreen, Office Protected View, or Gatekeeper seeing an origin mark, while MagicInput highlights the unmarked file.

Fix in Cursor Fix in Web

Reviewed by Cursor Security Reviewer for commit 58f5969. Configure here.

…oads

The Mac watches ~/Downloads for new files marked by sharingd (AirDrop). Once
one stops growing it is offered to the PC over a connection of its own (Offer
instead of a hello, then Data pieces and a Received receipt), so a big file
never holds up the pointer. The PC takes it when the Mac's user is working on
the PC (the pointer or the keyboard is there) or when its own input was used
more recently than the Mac's, saves it to Downloads under a safe, free name
and shows it in Explorer. The Mac removes its copy after the receipt.
airdrop = auto | always | never in the Mac's config. The control connection
is unchanged, so no protocol bump; an older PC just leaves files on the Mac.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@betoxf
betoxf force-pushed the feat/airdrop-to-pc branch from 58f5969 to bc138ef Compare October 24, 2026 16:37
@betoxf
betoxf changed the base branch from fix/keyboard-stays-native to main October 24, 2026 16:37
@betoxf
betoxf merged commit f231388 into main Oct 24, 2026
5 checks passed
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