croc
croc copied to clipboard
Developing Apis to interact with Croc programmatically
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
+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?
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
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.
you don't need to use Go. but that file describes the protocol in Go code
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.
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:
-
when you run
croc receive <code>
, croc starts by connecting to the relay server using the provided code. -
the relay server helps both the sender and receiver establish a connection, even if they are behind different network setups like nat or firewalls.
-
once connected through the relay, croc sets up an encrypted channel using the same code to ensure the transfer is secure.
-
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.
-
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.
Stale issue message