schollz / croc

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

API for custom clients #284

Closed busybox11 closed 3 months ago

busybox11 commented 3 years ago

I was wondering if croc has an API and it seems it doesn't. This may explain why there is no third-party clients out there.

I'd like to use an API that could help creating third-party clients, monitoring services, integrations to other services...

I will probably look forward into croc, and other people may too if there is a public API. GUI clients, web-based versions, and so on could be created by third-party actors - and this will probably increase croc's popularity.

I don't plan to code my own third-party client, but if I have enough free time I will probably take a look at it.

schollz commented 3 years ago

The required methods are publicly exported so you can use croc as a library if you want.

You can find an example in croc itself. First the options are set and then files are sent (similar for receiving).

busybox11 commented 3 years ago

Well, not everyone can code in go, me included.

This was obviously my first thought. I unfortunately don't understand how it works, that's why I'd like to have an API / proper library (to use it in node, python...)

I'll try to get this tho, but it's not easy for me.

Thanks for your time :)

decentral1se commented 3 years ago

Hey also very interested in this from a perspective of developing a Python based GUI for sending files which we want to use croc for. We're currently using magic-wormhole which is cool but the project is lacking a bit of life and we're hoping to keep in touch with developers of the underyling tools. See our current progress over at https://git.vvvvvvaria.org/rra/dropship.

Soooo, yeah, from the perspective of using croc from another language, maybe there is a chance to simply take the compiled binary along but then the output that croc produces is not quite parseable. Especially for the metadata on the sending/downloading. Sooo, some sort of friendly format like JSON for output might be an easy step forward for clients.

Otherwise, can bindings be generated from the golang source? I've had a search around and there certainly seems to be tools like that but I couldn't get any of them producing me Python bindings within a short time and I'm no Go hacker.

Other thing I can think of is using https://grpc.io or something RPC-like which can speak over a local socket and you can generate client code from a message spec. I've seen a bunch of projects getting into that and it seems to work.

decentral1se commented 3 years ago

Related to GUIs and clients:

decentral1se commented 3 years ago

/cc @rscmbbng

github-actions[bot] commented 5 months ago

Stale issue message

rscmbbng commented 5 months ago

Still interested!

schollz commented 4 months ago

@rscmbbng please say more

rscmbbng commented 4 months ago

@rscmbbng please say more

Hi @schollz, thanks for getting back. Basically I'm re-iterating what @decentral1se said in https://github.com/schollz/croc/issues/284#issuecomment-721425941. It would be great to have a way to access all the functionality of croc over a standardized API so we can build clients for it in languages other than Go. These clients could pull a croc binary and build novel interfaces on top of it. We had a fairly advanced Python+GTK prototype going some years ago (https://git.vvvvvvaria.org/rra/dropship) and I know of others that made attempts with Javascript/Electron. These novel clients not only made it more user-friendly to non-technical users but were also doing more than croc does off the shelf such as creating options to quickly retry a failed transfer, giving options to send the same file multiple times, provide a history of transfers etc.

All these efforts stranded partially because it feels to shaky to parse terminal output (even though, if stabilized could be an option), at the same time, croc would be an excellent base for to build really interesting applications around..

schollz commented 4 months ago

I see, it sounds like you need stable command-line output and maybe some more command-line options?

I'm totally fine with this! I'll accept any PR you want. If you want others to help code on it, it would be worth making a new issue detailing exactly what is needed, a "spec" of sorts.