Skip to content
/ kedge Public

A bittorrent engine base on libtorrent-rasterbar with RESTful API

License

Notifications You must be signed in to change notification settings

liut/kedge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kedge

A bittorrent engine base on libtorrent-rasterbar with RESTful API

JSON APIs

  • GET /api/session current session information, 200
  • GET /api/session/stats statistices of session, 200
  • PUT /api/session/toggle toggle session pause and resume, 200
  • GET /api/torrents show all torrents, 200
  • POST /api/torrents new task with torrent file in body, 204 | 500
  • GET /api/torrent/{infohash} show a torrent status, 200 | 404
  • GET /api/torrent/{infohash}/{act} act=(files|peers), 200 | 404
  • HEAD /api/torrent/{infohash}, 204 | 404
  • DELETE /api/torrent/{infohash} remove a torrent, 204 | 404
  • PUT /api/torrent/{infohash}/{act} act=(toggle|start) toggle a torrent or force start, 204
  • GET /api/sync Websocket only! response using JSON-patch format (see velox).

note: infohash has 40 bytes string with hex format

If you want to experience these APIs please check the official web UI kedge-svelte that support them.

Plans

  • Support for Add a new task by magnet link.
  • Support optional actions such as moving folder when task is completed.
  • Split logs with alert types?.
  • Pause and resume torrents.
  • Support base32 format infohash.
  • API with authorization.

API Test with cURL

add a torrent

curl -v -X POST \
	--url http://localhost:16180/api/torrents \
	-H 'Content-Type: application/x-bittorrent' \
	-H 'Content-Length: 30786' \
	--data-binary @debian-11.1.0-amd64-netinst.iso.torrent

curl -v -X POST \
	--data-raw 'magnet:?xt=urn:btih:LYJSQPMNZA4JJ6UJTNDQF4IU3SVWW43O&dn=debian-mac-10.10.0-amd64-netinst.iso&xl=351272960&tr=http%3A%2F%2Fbttracker.debian.org%3A6969%2Fannounce' \
	http://localhost:16180/api/torrents

show all torrents

curl http://localhost:16180/api/torrents | jq

check a torrent exist with infohash

curl -v -I http://localhost:16180/api/torrent/5e13283d8dc83894fa899b4702f114dcab6b736e

drop a torrent (with data optional)

curl -v -X DELETE \
	http://localhost:16180/api/torrent/5e13283d8dc83894fa899b4702f114dcab6b736e
# or
curl -v -X DELETE \
	http://localhost:16180/api/torrent/5e13283d8dc83894fa899b4702f114dcab6b736e/with_data

toggle session pause and resume

curl -v -X PUT http://localhost:16180/api/session/toggle
# response {"isPaused":true} or {"isPaused":false}

pause and resume a torrent

# toggle a torrent puase or resume
curl -v -X PUT \
	http://localhost:16180/api/torrent/7cf55428325617fdde910fe55b79ab72be937924/toggle
# force start a torrent
curl -v -X PUT \
	http://localhost:16180/api/torrent/7cf55428325617fdde910fe55b79ab72be937924/start

show session stats

curl http://localhost:16180/api/stats | jq

Dependencies

Components

Build

Prepare for macOS

sudo port install cmake clang-11 llvm-11
sudo port install zlib bzip2 openssl

Prepare for debian/ubuntu

sudo apt install cmake automake libtool pkg-config libgnutls28-dev libcurl4-gnutls-dev zlib1g-dev
sudo apt install clang-11 libc++-11-dev libclang-11-dev

Install boost & libtorrent

echo 'using clang : 11.0 : : <cxxflags> -std=c++17 -O2 -no-pie -fPIC ;' >> ~/user-config.jam

export CPPFLAGS='-std=c++17 -no-pie -fPIC'

# download boost and uncompress it into ~/tmp
cd ~/tmp/boost_1_76_0/
./bootstrap.sh --prefix=/opt/boost --with-toolset=clang

./b2 -j12 --build-dir=build --prefix=/opt/boost --with=all cxxstd=17 toolset=clang link=static runtime-link=static variant=release threading=multi install
cd tools/build
./b2 -j12 --build-dir=build --prefix=/opt/boost --with=all cxxstd=17 toolset=clang variant=release install

# donwload libtorrent and uncompress it into ~/tmp
# Or git clone -b RC_1_2 https://github.com/arvidn/libtorrent.git
cd libtorrent

/opt/boost/bin/b2 -j12 --prefix=/opt/lt12 cxxstd=17 variant=release crypto=openssl link=static runtime-link=static install

Compile

test -e build && rm -rf build
mkdir build && cd build
cmake ..
make -j4

Run

# show help
./build/kedge -h
# create and edit .env for config
touch .env
env `cat .env 2>/dev/null | xargs` ./build/kedge

About

A bittorrent engine base on libtorrent-rasterbar with RESTful API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published