Croc is a tool that allows any 2 computers to simply and securely transfer files and folders.
Most of the time, the 2 computers are behind NAT, and does not have IPv6, so file transfers uses schollz’s own funded public relay and that costs him $40-50/month.1
We can run our own relay and host it on VPS, but that also cost money just for hosting a relay. We instead try to use Cloudflare Tunnel to allow 2 computers to discover each other and transfer files using Cloudflare as relay.
Sending side
Croc requires a minimum of 2 ports for relay,2 so we need 2 ingress for each port.
Download and install cloudflared
- Download cloudflared.
- Authenticate cloudflared.
cloudflared tunnel login
- Create a tunnel.
cloudflared tunnel create croc-tunnel
Setup Cloudflare Tunnel
- Create a
config.yaml
file.
|
|
- Run Cloudflare Tunnel.
cloudflared tunnel run
Setup Croc
The --local
flag will make Croc a sender and relay at the same time.
The --code
flag stops Croc from making a new code everytime, setting it to 123456
.
The --ports
flag will specify what ports do Croc will run. Since Croc will try to use ports 9009-9013, we need to set it to only use 2 ports.
- Send file using Croc.
croc --local send --code 123456 --ports 9009,9010 file.ext
Receiving side
The receiving side requires cloudflared because Cloudflare only tunnels HTTP, not TCP that Croc need, so in order to tunnel TCP, cloudflared must be present at the receiving side.3
Download cloudflared.
Connect communication port to Cloudflare Tunnel using cloudflared access.
cloudflared access tcp --hostname croc-coms.example.com --url localhost:9009
a. For Linux, you can use
nohup
for background execution.nohup cloudflared access tcp --hostname croc-coms.example.com --url localhost:9009 &
Connect data port to Cloudflare Tunnel using cloudflared access.
cloudflared access tcp --hostname croc-data.example.com --url localhost:9010
The --ip
flag will specify which IP to connect, since Cloudflare Tunnel exposes the tunnel on localhost, we connect to localhost.
- Receive file using Croc.
croc --local --ip 127.0.0.1:9009 123456