@yz-social/civildefense.io
v4.4.4
Published
Browser app to safely share live sightings on a map.
Downloads
227
Readme
CivilDefense.io
The App
CivilDefense.io lets you report an immediate concern to the public by tapping its location on the map. The locations are shared over anonymous p2p with other users in your area, then fade away over 24 hours. There is no login and no global tracking of your Internet address or physical location.
See here.
The Implementation
Some apps of this type have been removed from mobile app stores, while others remain. CivilDefense.io is implemented as a web page, so that it does not have to rely on an app store.
Additionally, the source code is available right here so that a mirror can be hosted by anyone.
Finally, all mirrors share the same data through peer-to-peer connections, so all reporting is automatically shared among all mirrors, regardless of which mirror the user entered through. There is no central database to be taken down.
The Bigger Project
YZ.social ("wise social") is building a secure, free, and open source, peer-to-peer network for a new class of applications called Axona. The Axona network has no servers, no central database, no single point of failure. It is a true, fully decentralized network constructed, controlled and owned by its users. CivilDefense.io is the first application built on the YZ network.
Running a Portal
Visitors enter network through a "portal", which serves the web pages and connects the user to other peers in the network. Anyone can run such a portal.
A local, private copy for development can be run with:
git clone https://github.com/YZ-social/civildefense.io.git; cd Yz.social
npm install
npm start # Now visit http://localhost:3000Sharing
To allow people visit the page from another device, the server must use https. This is usually done with a front end (aka reverse proxy server) such as nginx or OpenResty, and most commercial setups already operate this way. For example, at civildefense.io and our own mirror at ki1r0y.com, nginx handles https connection handshake and certificate (tcp inbound 443), and passes the request to NodeJS running on port 3000.
What It Does
The application server does a few things:
- It serves the static client files - i.e., the web page.
- It launches one separate NodeJS processes for each logical core of the machine, each with an a network node just like the one that is run in the browser when someone visits the site. These "portal nodes" add to the capacity of the network. The each make outgoing UDP Webrtc connections for each node that connects to them on high-numbered ports.
- NOT IMPLEMENTED IN MIRRORS YET. It provides a means of connecting to the p2p network. Specifically, it provides a Websocket endpoint that deliver Webrtc connection information to an internal connecting node.
- NOT IMPLEMENTED IN MIRRORS YET. It runs a TURN relay (within the web server process). The TURN server listens for setup requests incoming on udp or tcp on 3478. (We do not currently use (D)TLS, which would be 5349.) Additionally, the actual relay traffic happens on incoming udp ports 49152 - 65535.
Building Your Own
This is all done with a very minimal ExpressJS server. The one we provide is in server/app.js. If you already have such a server set up, you can just:
- Add or link public/ to the directory of static client files already being served. E.g.,
- If you want to serve the static client files from an nginx front end, you can specify
root path_to_yz.social_directory/public;in your nginx.conf. - If you want to serve the static client files from an existing ExpressJS app server, you can specify
app.use(express.static(path_to_yz.social_directory/public));
- Fork one or more capacity nodes. Our
app.jsdoes this with:
import cluster from 'node:cluster';
if (cluster.isPrimary) {
for (let i = 0; i < nPortals; i++) cluster.fork();
...
} else {
const { P2PWebNetwork } = await import('../public/javascripts/p2pWebNetwork.js');
const { location:region } = await import('./getLocation.js'); // First invocation caches.
const network = await P2PWebNetwork.create({region});
}- Allow visitors to connect through your portal instead of through 'wss://bridge.axona.net'. COMING SOON. See axona-bridge.
- Run a TURN relay. The portal nodes and visitors to your web page are automatically configured to expect a relay at the default STUN/TURN port (3478). COMING SOON
