So, I’ve had this strange idea that could be very cool.
Prelude
Really, I’ve been playing around with building desktop-like applications, backed by Bash CGI-scripts, as you can see in the previous posts. I’ve re-implemented serious parts of the typical I/O interactions of shell scripts generically in CGI(read/write files, fifos, spawn commands, etc.), and applications in general, in CGI. This all got started from upgrading my LXC scripts to work in the browser, and they setup Linux containers(and VM’s!) in an automated way.
I’d even like to host a version of my scripts publicly, but that wouldn’t be safe(It’s basically a control panel for a server, after all).
But writing a lot of JS, and thinking about what parts of an application belong in the browser vs. the CGI-scripts has gotten me wondering:
Maybe we can just get an entire Linux VM in the browser(which I know is possible, because it’s been done before, I might even use those projects), that then can host the Website and my scripts for a cool demo?
Doubts
This would leave you with a very sad Linux VM: Little memory, no networking, slow performance, etc. - Well, little memory and slow performance isn’t that bad, but no networking makes this VM kind of useless for anything serious. Also, it stops to exist once the user closes the browser tab. There are JS Linux VM’s out there that have network connectivity through a proxy and just limit you to one connection per IP and a few KB/s(but I really don’t want to become an ISP).
I think with some clever browser hacks, we can get some networking and some semblance of permanence.
The idea is this:
Visit a website, and gets a terminal to a Linux VM, running in Javascript in the local browser tab.
On tab close, pause/shutdown the VMs, then serialize the VMs, and send it peer-to-peer to another browser using WebRTC(peerjs).
This other browser could then continue to run the VM if trusted, or just store it’s state(possibly encrypted) for later.
You can return later and run your own VM again, or just access it remotely.
You could even network the running VMs together using the same WebRTC mechanism.
And as a side-effect(main-effect?) this could enable the completely free hosting of small (Linux) VMs that run in your browser, or in the browsers of others, with permanent(within limits) storage, and (limited) network access.
The idea is to always leave at least a single trusted, reachable browser-tab open somewhere, so your trusted VMs can have CPU time and internet access. You could easily provide that yourself from any browser tab(if possibly only for a limited time). And when you do that you could also host another VM for somebody else. Maybe you don’t want to be the exit-point of traffic for somebody else, but you could still host them if their traffic exits from another peer.
You could host from a desktop, phone, server or anything else that can open a webpage and has any internet connection(no dedicated IP needed, WebRTC + STUN/TURN).
Because basically all you need to do to participate is leave a tab open, and one can measure how long somebody has a tab open and how many VMs he hosts, one could calculate a leaderboard.
Maybe this could be something cool? What do you guys think? Could I get this done in the remainder of January? LET ME KNOW.