The popular The libtorrent P2P file-sharing ecosystem was announced recently the release of the new version 2.1an update, that consolidates the work of thousands of code commits Over the past few months, it has radically transformed the way content is distributed to integrate the WebTorrent protocol by default, in addition to introducing a completely redesigned disk read/write engine to maximize performance.
The biggest attraction This version features native support for WebTorrent. This technology It extends the traditional BitTorrent protocol by giving it capabilities To create decentralized content distribution networks directly from users' web browsers, using WebRTC for data exchange. This means website developers only need to insert a small snippet of JavaScript code for their visitors to share content with each other seamlessly.
The most fascinating thing about this integration is the creation of borderless hybrid networks, since the Traditional desktop clients based on libtorrent can now connect and exchange parts of files with users who simply have a tab open in their web browser.
In turn, web clients can benefit from the enormous bandwidth of swarms of desktop users operating over conventional TCP and UDP connections. It's worth noting that, when enabled by default, WebRTC support expands the library's attack surface, so developers strongly recommend disabling it during compilation if the final application will not be using this feature.
Optimized performance with the new input/output motor
The physical performance of the storage has received the introduction of a new underlying engine called pread_disk_io. This system It uses the pwritev and preadv system functions to perform atomic read and write operations. in multiple buffers simultaneously. The development team has set this new engine as the default, as it proves to be vastly more efficient when working with mechanical hard drives, network storage, and file systems mounted using FUSE.
For users and servers equipped with ultra-fast solid state drives NVMe, the previous engine, based on in-memory file allocation (mmap), It is still available in the codeThis legacy architecture remains the most optimal and fastest option for modern high-performance storage hardware, and can be activated according to customer needs.
At the structural and dependency level, libtorrent 2.1 takes a leap forward by requiring C++17 for compilation, leaving behind legacy code and adopting a much safer and more modern syntax. In addition, it now requires at least OpenSSL version 1.1.0 with support for Server Name Indication (SNI).
On the other hand, among the Among the most notable optimizations is an improvement in the format of the resumption data (resume data) to take up less disk spaceNative support for peer exchange in anonymous I2P networks and the definitive removal of support for old web seeds under the obsolete BEP 17 standard, prioritizing the more robust BEP 19.
How to install and compile libtorrent 2.1 on Linux
For those who want to implement this new version on their systems, the most direct and up-to-date method is to compile the library from its source code. Since it's a C++ core library, you'll need to prepare your development environment first.
On Debian or Ubuntu-based distributions, you must open your terminal and ensure you have the build tools, CMake, and the Boost and OpenSSL dependencies installed by running the command
sudo apt install build-essential cmake libssl-dev libboost-all-dev
Once the dependencies are prepared, it is essential to clone the official repository from GitHub, making sure to also download the necessary submodules for WebTorrent, which is achieved with the command
git clone --recurse-submodules https://github.com/arvidn/libtorrent.git
Next, enter the downloaded folder with `cd libtorrent`, and create a specific directory to build the binaries by running
mkdir build && cd build
And prepare the build environment by writing
cmake
If you prefer to disable WebTorrent support for security reasons or to keep the library lighter, you can modify the above command using the flag
cmake -Dwebtorrent=OFF
Finally, compile the code by running the `make` command (you can speed it up by adding `-j4` or the number of cores in your processor) and, when the process is finished, install it on your system with administrator privileges using the command
sudo make install
After this, the torrent clients you compile on your computer will use this powerful and revamped base.