metahashorg / Node-Torrent

This repository contains the torrent node source code written in C++.
4 stars 2 forks source link
node

MetaHash torrent node

This repository contains the torrent node source code written in C++. There are two internal libraries: libmicrohttpd2 and libmhsupport used in this code.

Pre-built binary for Ubuntu 18 (20 is also suitable) available here: releases.

Requirements

cmake > 3.8
gcc > 8.0
libevent 2.1.8

Build

Please be informed that you can build torrent in /tmp (temporary directory) as described below or you can build it in /opt directory.

Please follow these steps to build and run Torrent on Ubuntu:

  1. Preparation

sudo apt install software-properties-common sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt update

sudo apt install gcc-8 g++-8 liburiparser-dev libssl-dev libevent-dev git automake libtool texinfo make libgmp-dev libcurl4-openssl-dev libgcrypt20-dev libgnutls28-dev libboost-dev libre2-dev libgoogle-perftools-dev

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-8 sudo update-alternatives --config gcc

2. Get and compile latest cmake
```shell
cd /tmp
wget https://github.com/Kitware/CMake/releases/download/v3.13.0/cmake-3.13.0.tar.gz
tar zxfv cmake-3.13.0.tar.gz
cd cmake-3.13.0
./bootstrap
./configure
make -j$(nproc)
sudo make install
  1. Get and compile libevent
    cd /tmp
    wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
    tar zxfv libevent-2.1.8-stable.tar.gz
    cd libevent-2.1.8-stable
    ./configure
    make -j$(nproc)
    sudo make install
  2. Get and compile libmicrohttpd2

Please note: you must use this libmicrohttpd2 library, because the original libmicrohttpd library has no all functions available which are necessary for running Torrent.

cd /tmp
git clone https://github.com/metahashorg/libmicrohttpd2
cd libmicrohttpd2
./bootstrap
./configure
make -j$(nproc)
sudo make install
  1. Get and compile libmhsupport
    cd /tmp
    git clone https://github.com/metahashorg/libmhsupport
    cd libmhsupport/build
    ./build.sh
    sudo make install
  2. Build Torrent Node
    cd /tmp
    git clone https://github.com/metahashorg/Node-Torrent.git torrent_node
    cd torrent_node/build
    git checkout master
    git submodule update --init
    cmake .. && make

Update torrent to recent version

  1. Stop running torrent:
    kill `ps axuwf|grep torrent_node|grep -v grep|awk '{print $2}'`
  2. Go to directory where you've cloned torrent_node, for example
cd /tmp/torrent_node

git pull
cd build
rm -rf
cmake ..
make -j$(nproc)
  1. Start torrent:
    ./torrent_node torrent_config

Script for starting, stopping, restarting.

Script torrent.sh for the following operations with Metahash torrent application:

Note: default workdir is /opt/torrent. If you’ve install torrent to another location please change workdir in script.

Usage script

RUN script as follows:

./torrent.sh status

Run torrent

To run torrent, you have to add the file containing your private key to the folder containing torrent (/opt/torrent). The file’s name must be as follows: yourkey.raw.prv. Сlick here for information about where to get the private key.

Example: 0x007ff2d508be12392be5a381ca07b55c8fd02d09192a9b5cf4.raw.prv

Besides, you have to configure your config file (/opt/torrent/config.conf). To do it, add the row with the name of your file containing private key or, if the row sign_key = ... already exists, replace the private key with your key in it.

Example: sign_key = "0x007ff2d508be12392be5a381ca07b55c8fd02d09192a9b5cf4".