/torrest-cpp

c++ implementation of torrest - a torrent streaming engine with a REST api

Primary LanguageC++MIT LicenseMIT

torrest-cpp

Build Status cross-build Codacy Badge Total alerts Language grade: C/C++

Torrent service with a REST api, specially made for streaming. This is the C++ implementation of the Torrest (golang) project.

Requirements

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.

Dependencies

Torrest has several external dependencies. Below is a list of them and the minimum version required:

Building

This section describes how to build Torrest using CMake.

Installing dependencies

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.

Compiling Torrest

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).

Build Configurations

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

Cross Compiling

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) dev docker/dev.Dockerfile
android-arm android-arm docker/android-arm.Dockerfile
android-arm64 android-arm64 docker/android-arm64.Dockerfile
android-x64 android-x64 docker/android-x64.Dockerfile
android-x86 android-x86 docker/android-x86.Dockerfile
darwin-x64 darwin-x64 docker/darwin-x64.Dockerfile
linux-armv7 linux-armv7 docker/linux-armv7.Dockerfile
linux-arm64 linux-arm64 docker/linux-arm64.Dockerfile
linux-x64 linux-x64 docker/linux-x64.Dockerfile
linux-x86 linux-x86 docker/linux-x86.Dockerfile
windows-x64 windows-x64 docker/windows-x64.Dockerfile
windows-x86 windows-x86 docker/windows-x86.Dockerfile

Building images

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>

Cross compiling Torrest

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>

Running Torrest

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