$ account webtorrent
WebTorrent is a JavaScript library implementing BitTorrent client and seeding behavior for both Node.js and browsers. At runtime, a WebTorrent instance accepts torrent identifiers (magnet links, info hashes, .torrent files), parses them into metadata, discovers peers via DHT, HTTP/UDP trackers, LSD, and PEX, then negotiates connections over TCP/uTP in Node or WebRTC in the browser. The engine orchestrates a block-request pipeline, verifies piece hashes, writes chunks into pluggable chunk stores (fs, fsa, memory), and exposes files as streams, HTTP endpoints, or Service Worker responses. It also seeds existing files/buffers back to the swarm. This repo is not the standalone CLI; it is the core client library consumed by webtorrent-cli and desktop applications. Architecturally, the code follows a modular small-package style: central WebTorrent and Torrent classes coordinate discovery, peer management, and piece selection, while focused helpers handle transport factories, shared listener pools, piece-range selection, rarest-first availability, and HTTP/Service Worker streaming. It depends on the established BitTorrent ecosystem: bittorrent-dht, bittorrent-tracker, bittorrent-protocol, create-torrent, parse-torrent, torrent-discovery, ut_metadata, ut_pex, and optional native utp-native. Browser/runtime variation is handled through package.json browser/chromeapp aliases and webpack builds. The test suite exercises real network workflows over local DHT/tracker/LSD and direct IP connections, covering PE/MSE encryption, metadata exchange, web seeds, blocklists, seeding while downloading, throttling, and server streaming. Code quality is generally strong, though lib/torrent.js is large and contains legacy comments/TODOs, and there are stale tests referencing a removed swarm module. Overall, this is a high-craft, production-grade P2P streaming library with several genuinely reusable internal components.
This repository provides a robust, production-ready implementation of a BitTorrent tracker, including both client and server components. The client can announce to HTTP, UDP, and WebSocket trackers to discover peers in a swarm, while the server can track multiple swarms, respond to announce and scrape requests, and expose statistics via a web interface. The architecture is modular, with separate tracker protocol implementations (HTTP, UDP, WebSocket) inheriting from a common base class, and a server that manages swarms using an LRU cache for peer storage. The codebase is well-tested, uses modern ESM modules, and is actively maintained as part of the WebTorrent ecosystem. It is primarily a library for Node.js, but also supports browser usage via bundlers.