schollz / croc

Easily and securely send things from one computer to another :crocodile: :package:
https://schollz.com/software/croc6
MIT License
27.75k stars 1.1k forks source link

Developing Apis to interact with Croc programmatically #673

Closed EggsyOnCode closed 2 months ago

EggsyOnCode commented 7 months ago

Is your feature request related to a problem? Please describe.

I was thinking of developing a website where ppl could drop in their files and retrieve them from the other end using croc. This situation comes in handy for the non technical folk who might not have croc installed as a cli util. That's where a web interface would come in handy.

Describe the solution you'd like To have croc sdk installed on the web server to interface with Croc functionality programmatically.

Describe alternatives you've considered None

Additional context None

SeedDMS commented 6 months ago

+1

My idea was to implement a plugin for a document management systems which contacts a croc relay to retrieve a file. Is there any documentation on how to talk to the relay?

schollz commented 5 months ago

check cli.go to see how to use croc as an API: https://github.com/schollz/croc/blob/v9.6.15/src/cli/cli.go

SeedDMS commented 5 months ago

I was actually hoping for something the describes the protocol between client and relay, because I do not intend to use go but php to access the relay.

schollz commented 4 months ago

you don't need to use Go. but that file describes the protocol in Go code

SeedDMS commented 4 months ago

It's still difficult to collect the parts together. Most of the protocol code appears to be in https://github.com/schollz/croc/blob/v9.6.15/src/croc/croc.go but I'm still missing the overall picture for receiving a file which has been send to a relay.

schollz commented 4 months ago

I'm still missing the overall picture for receiving a file which has been send to a relay

here's the overall picture on how receiving a file with croc works:

  1. when you run croc receive <code>, croc starts by connecting to the relay server using the provided code.

  2. the relay server helps both the sender and receiver establish a connection, even if they are behind different network setups like nat or firewalls.

  3. once connected through the relay, croc sets up an encrypted channel using the same code to ensure the transfer is secure.

  4. croc attempts to switch to a direct peer-to-peer connection for better speed. if that's not possible, it continues using the relay. the file transfer begins, and you will see progress updates in your terminal.

  5. after the file is fully transferred, croc verifies the integrity of the received file to make sure everything is correct.

you can find the main logic for handling this process in croc.go, but it also interacts with several other parts of the codebase for encryption, connection handling, and progress reporting.

github-actions[bot] commented 2 months ago

Stale issue message