Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developing Apis to interact with Croc programmatically #673

Open
EggsyOnCode opened this issue Feb 25, 2024 · 6 comments
Open

Developing Apis to interact with Croc programmatically #673

EggsyOnCode opened this issue Feb 25, 2024 · 6 comments

Comments

@EggsyOnCode
Copy link

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
Copy link

SeedDMS commented Apr 4, 2024

+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
Copy link
Owner

schollz commented Apr 6, 2024

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
Copy link

SeedDMS commented Apr 8, 2024

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
Copy link
Owner

schollz commented May 20, 2024

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

@SeedDMS
Copy link

SeedDMS commented May 23, 2024

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
Copy link
Owner

schollz commented May 23, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants