Torrent service with a REST api, specially made for streaming. This is the C++ implementation of the Torrest (golang) project.
In order to build Torrest, you will need C++ (14 or newer) installed and also CMake (at least version 3.17). Additionally, you need a build system to actually schedule builds.
Torrest has several external dependencies. Below is a list of them and the minimum version required:
- range-parser (v1.0.1)
- nlohmann-json (v3.9.0)
- spdlog (v1.9.1)
- oatpp (v1.3.0)
- oatpp-swagger (v1.3.0)
- openssl (1.1.1f)
- boost (1.72.0)
- libtorrent (v1.2.14)
This section describes how to build Torrest using CMake.
For local development, all the project dependencies can be installed automatically by running the
scripts/install_dependencies.sh
script. For a better understanding of how to use the script, run:
./scripts/install_dependencies.sh --help
By default, the install_dependencies.sh
script will use the versions specified in scripts/versions.env
file. In case
you want to modify a version of a dependency, you can simply modify the versions.env
file.
After installing the required dependencies, in order to build Torrest using CMake, simply run the following commands:
cmake -B cmake-build -DCMAKE_BUILD_TYPE=Debug
cmake --build cmake-build --target torrest -- -j "$(nproc)"
Then, the torrest
binary can be found inside the cmake-build
directory. Note, the above command specifies a Debug
build type, however, different CMAKE_BUILD_TYPE
values may be passed (e.g. Release
).
Below is the list of supported CMake build configurations (which are then mapped to macros during the build):
CMake configuration | Default | Maps to macro | Description |
---|---|---|---|
enable_swagger | ON | TORREST_ENABLE_SWAGGER | Enables swagger on http://localhost:8080/swagger/ui endpoint |
with_swagger_local_resources | OFF | OATPP_SWAGGER_RES_PATH | Sets the swagger resources path to the oatpp-swagger directory |
enable_shutdown | ON | TORREST_ENABLE_SHUTDOWN | Enables the shutdown endpoint (http://localhost:8080/shutdown) |
enable_extended_connections | ON | TORREST_EXTENDED_CONNECTIONS | Enables oatpp extended connections |
enable_torrent_buffering_status | OFF | TORREST_ENABLE_TORRENT_BUFFERING_STATUS | Enables torrent buffering status |
One can also cross compile Torrest to the platforms listed in the below table. To do so, multiple docker images were
created (see docker
directory) in order to support this process.
Platform | Size | Dockerfile |
---|---|---|
dev (linux-x64) | docker/dev.Dockerfile | |
android-arm | docker/android-arm.Dockerfile | |
android-arm64 | docker/android-arm64.Dockerfile | |
android-x64 | docker/android-x64.Dockerfile | |
android-x86 | docker/android-x86.Dockerfile | |
darwin-x64 | docker/darwin-x64.Dockerfile | |
linux-armv7 | docker/linux-armv7.Dockerfile | |
linux-arm64 | docker/linux-arm64.Dockerfile | |
linux-x64 | docker/linux-x64.Dockerfile | |
linux-x86 | docker/linux-x86.Dockerfile | |
windows-x64 | docker/windows-x64.Dockerfile | |
windows-x86 | docker/windows-x86.Dockerfile |
In order to build all docker images, simply run the following command:
make -f docker/Makefile build
For building a specific image, run:
make -f docker/Makefile build-<platform>
Similarly, one can also build Torrest using the pre-built docker image. To do so, one needs to use the torrest
target:
make -f docker/Makefile torrest
Or for a specific platform:
make -f docker/Makefile torrest-<platform>
After building Torrest, one can run it like any other binary, that is:
./torrest
Although Torrest doesn't have any required arguments, it accepts optional arguments:
Argument | Type | Default | Description |
---|---|---|---|
-p, --port | uint16 | 8080 | The server listen port |
-s, --settings | string | settings.json | The settings path |
--log-level | string | INFO | The global log level |
-v, --version | n/a | n/a | Print version |
-h, --help | n/a | n/a | Print help message |