Secure, Peer-to-Peer File Transfer Made Simple with WebRTC
Ever needed to send a file directly to someone without uploading it to a server first? Maybe it's a large build artifact, a sensitive log file, or you just want lower latency and more privacy than a cloud service offers. WebRTC is the powerful technology that enables peer-to-peer video and audio in browsers, but harnessing it for raw data transfer can be a chore.
That's where file-transfer-go comes in. It's a definitive, open-source tool that cuts through the complexity, giving you a straightforward way to set up secure, peer-to-peer data transfer over WebRTC.
What It Does
In short, file-transfer-go is a command-line tool that establishes a direct connection between two machines for sending files. One machine acts as the sender, the other as the receiver. They connect via a WebRTC peer connection, facilitated by a lightweight signaling server (which only helps set up the connection and doesn't touch your data). Once the handshake is complete, the file data flows directly between the two peers, encrypted by default via WebRTC's DTLS.
Why It's Cool
The magic here is in the simplicity and the architecture. The project leverages the robust, built-in security of WebRTC (think encryption, congestion control) and applies it to general-purpose file transfer. You get a direct "pipe" between two computers, even if they're both behind different firewalls or NATs, thanks to WebRTC's ICE framework.
It's also refreshingly un-opinionated. It's a Go binary, so it runs nearly anywhere. There's no bulky UI or complex configuration—just a simple CLI for a specific job. This makes it perfect for automation scripts, quick transfers between your own devices, or as a reference implementation if you're looking to build peer-to-peer features into your own apps.
How to Try It
Getting started is straightforward. You'll need Go installed to build it from source.
-
Clone and build:
git clone https://github.com/MatrixSeven/file-transfer-go cd file-transfer-go go build -o file-transfer -
Run the signaling server (required for initial handshake):
./file-transfer serverKeep this running in a terminal. By default, it listens on
:8080. -
In a second terminal, start the receiver:
./file-transfer receive -o ./downloaded_fileThis will generate a peer ID. Take note of it.
-
In a third terminal, send a file:
./file-transfer send -peer [RECEIVER_PEER_ID] -file [PATH_TO_YOUR_FILE]
The receiver will show the connection progress, and your file will be written to the specified output path. The data never passes through the signaling server.
Final Thoughts
file-transfer-go is one of those utility projects that just feels right. It solves a clear problem with a modern protocol, without over-engineering it. For developers, it's either a ready-to-use tool for your own file-sharing needs or a fantastic, readable codebase to learn how WebRTC data channels work in practice. Next time you're about to drag a file into a cloud uploader, consider spinning this up instead for a faster, more private transfer.
@githubprojects
Repository: https://github.com/MatrixSeven/file-transfer-go