elisescu / tty-share

Share your linux or osx terminal over the Internet.
https://tty-share.com/
MIT License
806 stars 87 forks source link

Add CrossOrigin to the service #68

Closed PhearZero closed 1 year ago

PhearZero commented 1 year ago

Adds Cross Origin as an optional flag to allow users to turn off the CORs check.

I've also published the JS interface tty-reciever for convenience. It can be used for custom frontends and also for integrating into larger applications that leverage xterm.js.

📝 Related Issues

PhearZero commented 1 year ago

Hello @elisescu !

Good point, been a while since I've used go and didn't even realize I edited the vendor dir.

Using the library as a backend for xterm.js, sadly I don't think it will work with my use case but still am going to use the project for other things. I have a Turing Pi 2 and developing custom firmware with TTY support. Going to have to rebuild tty-share in C/C++ to make it smaller/lighter, even with my best efforts I only got the binary down to about ~7MB. It does run on the firmware, just a bit heavy on resources. Plus gorilla/WebSocket seems to be on it's way out, really not sure what the go community is going to do?

During the evaluation, I ran into two things that would definitely make it much easier to leverage.

elisescu commented 1 year ago

Thanks for the feedback, @PhearZero.

Regarding the size of the binary (memory consumption) you're right, this is not at all ideal, and I believe it's mostly because the whole frontend code is built in the binary itself so not sure C++ would help much. But I haven't looked very closely to be sure. The main reason I did that was to allow tty-share work locally, without the need of a server and the frontend had to be baked in somewhere, but I'm not sure it's the best approach.

I'm also considering writing a very thin client in Rust or C, but I'd need to think more about it, as I want to add end-to-end encryption as well, and not sure yet how the two would play together.

Regarding:

Allow for "Headless" operation that allows CORs

If by headless you mean what I think you do, that should be already supported via the -headless option.

Are you using a self-hosted instance of tty-proxy ?

PhearZero commented 1 year ago

Awesome! Glad to be able to contribute!

Regarding the size of the binary (memory consumption) you're right, this is not at all ideal, and I believe it's mostly because the whole frontend code is built in the binary itself so not sure C++ would help much.

Was able to only remove 2-3MB and got it down to ~7MB without the frontend and a few deps. Gorilla seems to be the main culprit, which is also understandable.

I'm also considering writing a very thin client in Rust or C, but I'd need to think more about it, as I want to add end-to-end encryption as well, and not sure yet how the two would play together.

This would be amazing, that was the path I started down with libwebsocket!

If by headless you mean what I think you do, that should be already supported via the -headless option.

Headless meaning no-ui, similar to a "Headless Wordpress" where it is only the API resources deployed without the render layer.