Browser-to-browser networking built on WebTorrent. Web service bug-out bag. Messageboard demo. Bugout demo.
- Easily send messages directly between browsers.
- Write servers that run in a browser tab.
- Host backend services without a VPS, domain or SSL cert.
- Easy to deploy & "self-hosted" servers by leaving a browser tab open.
- Client-server over WebRTC instead of HTTPS.
The old way:
The new way:
Bugout is a humble attempt to re-decentralize the web a little.
This is a functional prototype. It's pre-alpha quality software. It will allow people to connect directly to your browser from outside your network. Be careful.
Demos | Install | Use | API documentation | Server boilerplate | Deploy headless
Demos
Install
Using npm:
npm i bugout
Script tag:
<script src="https://chr15m.github.io/bugout/bugout.min.js"></script>
Clojurescript:
:install-deps false
:npm-deps {"bugout" "chr15m/bugout"}
:foreign-libs [{:file "node_modules/bugout/docs/bugout.min.js"
:provides ["cljsjs.bugout"]
:global-exports {cljsjs.bugout Bugout}}]
(:require [cljsjs.bugout :as Bugout])
Use
var Bugout = require("bugout");
To create a Bugout server that runs in a browser tab:
var b = new Bugout();
alert(b.address());
b.register("ping", function(address, args, callback) {
args.hello = "Hello from " + b.address();
callback(args);
});
localStorage["bugout-server-seed"] = b.seed;
To start a client connection specify the server's public key to connect to (b.address()
from the server):
var b = new Bugout("server-public-key");
b.on("server", function(address) {
b.rpc("ping", {"hello": "world"}, function(result) {
console.log(result);
});
});
localStorage["bugout-seed"] = JSON.stringify(b.seed);
Both clients and servers can interact with other connected clients:
b.on("message", function(address, message) {
console.log("message from", address, "is", message);
});
b.send({"hello": "all!"});
b.send(clientaddress, "Hello!");
b.on("seen", function(address) {
});
b.close();
Note that you can connect to a generic peer-to-peer swarm without a server by simply using a non-public-key identifier which can be any string as long as it's the same for every client connecting:
var b = new Bugout("some shared swarm identifier");
Boilerplate
The quick-start boilerplate server in a single HTML file will quickly get you up and running with your own Bugout server.
Options
See the API documentation for options.
Turn on debug logging
localStorage.debug = "bugout";
Deploy
Bugout servers can deployed and run inside of browser tabs on long running PCs but you can also deploy them "headless" more like traditional servers. There are a couple of ways of doing that as follows:
Headless browser server
Bugout launcher is a nodejs based helper script to launch and run your Bugout servers from the command line using a headless browser instance.
Nodejs
Check out the nodejs demo for an example of running a Bugout service under Node. Note that the wrtc
library is not that stable at the time of writing and running Bugout in headless Chrome or Firefox seems to work better. Bugout servers running inside nodejs obviously won't have access to browser facilities like localStorage.
Stay updated
Subscribe at bugout.network for updates and new releases.
The FAMGA virus
Infected with the FAMGA virus everybody's eating brains. Time to grab yr bugout box & hit the forest.