Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Planktos enables websites to serve their static content over bittorrent from the users of the website. This allows site owners to offset declining ad revenue by utilizing the user's bandwidth and scale easier since downloads get faster with more peers. Planktos works in vanilla Chrome and Firefox by using service workers to intercept http requests, and webtorrent to download the requested files from other users over bittorrent. Installing planktos into a website is as simple as registering the planktos service worker and creating a torrent that holds the static assets (or the entire site if it's completely static).
The planktos command line tool copies the neccessary library files, and it packages the website's files into a torrent. To install the tool run:
npm install -g planktos
Now change your current working directory to the directory you want to be served by planktos. The library files and service worker file need to be copied into this directory which can be done by running:
planktos --lib-only
The service worker needs to be registered which can be done by including this script:
<script src="/planktos/install.js"></script>
The final step is packaging the files into a torrent so it can be served over bittorrent which is done by running:
planktos [directories or files...]
If no files or directories are passed, planktos includes everything in the current working directory. Everything is setup now, and to test that everything is working open up the dev tools in look in the network tab. After modifying the website's files, the torrent can be repackaged by running the above command again.
There are a few things to keep in mind when using planktos:
Once the planktos service worker is installed, it intercepts all http requests made by the browser. When a fetch request is intercepted, planktos looks to see if the requested file is in the torrent for the website. If it is, planktos responds with the file's data it retreived over bittorrent. If the requested file is not in the torrent, the request goes to the webserver over http like it would without planktos installed. Planktos uses the awesome webtorrent project for everything bittorrent. One gotcha you may have noticed is that webtorrent relies on WebRTC for it's peer connections, and the WebRTC api is not accessible from within service workers. Planktos gets around this by injecting a downloader script in the initial webpage request which handles all the webtorrent downloading and seeding operations since this cannot be done in a service worker currently. See the W3C issue for more info on WebRTC in web workers.
If the browser does not have service worker support than everything goes over http like it would without planktos.
Planktos is still early on in developement, and is not recomended for production use yet. Some issues that are holding back production use are:
MIT. Copyright (c) Austin Middleton.
FAQs
Serving websites over bittorrent
The npm package planktos receives a total of 8 weekly downloads. As such, planktos popularity was classified as not popular.
We found that planktos demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.