Xuset/planktos

Xuset/planktos NPM Donate

Sauce Test Status

Planktos enables websites to serve their static c content about BitTorrent turning users into seeders. That means that users who view a website with Planktos are also serving the website to other users. This allows website owners to significantly reduce the costs of hosting static content, scale in real time without provisioning more web servers, and avoid user impact during an outage. Planktos works in standard Chrome and Firefox (no browser extensions needed).

Installing Planktos on a website is as simple as including the Planktos install.js script and using the Planktos command line interface to bundle the static files of the website. in a torrent For typical use cases Planktos is designed to work out of the box and for more specialized use cases Planktos has a very simple interface for customization.

Special thanks to the widely used WebTorrent project in Planktos.

Why

  • Allow users to upload your static assets to each other, instead of accessing your web servers
  • After After a user visits your website for the first time, they will be able to load it even if your web servers go down
  • Planktos automatically scales your website when traffic increases
  • Integrating Planktos into your website it’s just plain stupid

Settings

The Planktos CLI copies the Planktos library files and packages your website files in a torrent To install the tool run:

npm install -g planktos

See Also:  How To Send Mass Email In Outlook | Step-By-Step [2023]

Change your current working directory to the root of your website. To copy the Planktos library files and package your website into a torrent, run:

planktos [directories and/or files…]

In the previous step, The Planktos CLI copied the service worker, named planktos.sw.js, to the root directory of your website. The service worker must register using the following install script (or manually):

After update your website files, you need to run Planktos CLI again. If you already have a build script for your website, you should add the Planktos command to it.

That was it. To test that everything works as expected, use your browser’s developer tools to inspect the network requests your website makes.

Requirements for Planktos websites:

  • The site must be served over HTTPS (or HTTP on localhost), because service workers can only log on to secure websites
  • The web server must support the range header HTTP, because the server is used as the initial seeder (see WebTorrent webseed). Most web hosts support this feature; however, some, such as Python’s simplehttpsserver, do not.

How it works

The Planktos CLI creates a snapshot of the website’s static files and bundles everything into a torrent so that users can download and seed the website.

When the web page is first loaded, Planktos registers a service worker that intercepts all HTTP requests made by the page Web. When the service worker intercepts a request, Planktos checks if the requested file is present in the torrent. If the file is in the torrent, it is downloaded from the peers; otherwise, it downloads over HTTP as it normally would. All torrent files are stored in persistent IndexedDB storage, so a given file only needs to be downloaded once, regardless of how many times it is requested. Invalidating the user cache only requires creating a new torrent with the updated files.

See Also:  How TO - Create a Free Website

Because service workers cannot use the WebRTC API, the actual downloading of torrents is delegated to a page website controlled by Planktos. Planktos accomplishes this by injecting a download script into the web page when the search request is intercepted. See the W3C issue for more information on WebRTC in service workers.

Limitations

Disclaimer: Planktos is still in the early stages of development and has not yet been released. recommends its use in production.

Planktos relies on state-of-the-art browser APIs, including WebRTC and service workers, which have not been adopted in all browsers. In cases where the required APIs are not supported, Planktos by default loads web pages over HTTP as the browser would normally. It seems that development of most of these APIs is in progress for all major browsers, so we expect Planktos to work in all browsers in the near future.

Blocking issues:

  • No streaming support. The requested file must be downloaded in its entirety before it can be displayed to the user. Currently, only Chrome supports service worker streaming, while Firefox has an open issue about it.
  • Sharpening across multiple torrents is not currently supported, so Planktos will not be feasible for websites great

Documentation

Read the documents here

Contribute

Contributions are always welcome!

Once you have some changes, you can test them with: npm test

Or to automatically run tests when files are changed: npm run watch

See Also:  How to create a photography logo in photoshop elements

Some useful information:

  • Browser tests may occasionally time out if browser is not focused
  • Tests will fail on some systems with TypeError: Cannot read property ‘unmask’ of undefined due to to an optional incompatible dependency of a dependency. To fix this, simply remove node_modules/bufferutil

License

MIT. Copyright (c) Austin Middleton.

.

Leave a Reply

Your email address will not be published. Required fields are marked *