diff --git a/.github/workflows/bittorrent-tracker_ci.yml b/.github/workflows/bittorrent-tracker_ci.yml deleted file mode 100644 index ffb3440c..00000000 --- a/.github/workflows/bittorrent-tracker_ci.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: BitTorrent Tracker - -on: - push: - branches: - - 'main' - paths: - - 'bittorrent-tracker/**' - workflow_dispatch: - -jobs: - - bittorrent-tracker: - name: Deploy BitTorrent Tracker Image - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3.4.0 - - name: Publish Docker Image - uses: openzim/docker-publish-action@v10 - with: - image-name: kiwix/bittorrent-tracker - on-master: latest - restrict-to: kiwix/container-images - context: bittorrent-tracker - registries: ghcr.io - credentials: - GHCRIO_USERNAME=${{ secrets.GHCR_USERNAME }} - GHCRIO_TOKEN=${{ secrets.GHCR_TOKEN }} diff --git a/bittorrent-tracker/Dockerfile b/bittorrent-tracker/Dockerfile deleted file mode 100644 index 75cdc11c..00000000 --- a/bittorrent-tracker/Dockerfile +++ /dev/null @@ -1,41 +0,0 @@ -FROM debian:bullseye-slim -LABEL org.opencontainers.image.source https://github.com/kiwix/container-images - -WORKDIR /tmp - -# All-in-One RUN for a very small image size (< 5 MB) -RUN apt update 2> /dev/null \ - && apt install -y --no-install-recommends ca-certificates gcc g++ make git cvs cron xml2 zlib1g-dev curl unzip \ - # dumb-init for docker - && curl -SLO https://github.com/Yelp/dumb-init/archive/refs/tags/v1.2.5.zip \ - && unzip v1.2.5.zip && cd dumb-init-1.2.5 && make \ - && mv dumb-init /usr/bin/dumb-init && cd - && rm -rf ./dumb-init-1.2.5 \ - # lobowfat - && cvs -d :pserver:cvs@cvs.fefe.de:/cvs -z9 co libowfat \ - && cd libowfat \ - && make \ - && cd ../ \ - # opentracker - && git clone git://erdgeist.org/opentracker \ - && cd opentracker \ - && for feature in COMPRESSION_GZIP ACCESSLIST_WHITE IP_FROM_QUERY_STRING IP_FROM_PROXY ; \ - do pattern="#FEATURES+=-DWANT_${feature}" ; sed -i -e "/${pattern}/s/^#//g" Makefile ; \ - done \ - && make \ - # cleanup post-compile - && rm -rf /tmp/libowfat \ - && mv /tmp/opentracker/opentracker /bin/ \ - && mkdir -p /etc/opentracker/ \ - && touch /etc/opentracker/whitelist.txt \ - # cleanup build dependencies - && apt remove -y --purge gcc g++ make git cvs zlib1g-dev unzip \ - && apt clean -y \ - && rm -rf /var/lib/apt/lists/* - -COPY ./build_whitelist.sh /etc/cron.hourly/build-whitelist -COPY ./entrypoint.sh /usr/sbin/entrypoint - -EXPOSE 6969 - -ENTRYPOINT ["/usr/bin/dumb-init", "--", "entrypoint"] -CMD ["opentracker", "-r", "https://kiwix.org", "-w", "/etc/opentracker/whitelist.txt"] diff --git a/bittorrent-tracker/README.md b/bittorrent-tracker/README.md deleted file mode 100644 index 918e0a98..00000000 --- a/bittorrent-tracker/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# Kiwix tracker - -This is the private [BitTorrent](https://en.wikipedia.org/wiki/BitTorrent) tracker of the Kiwix organisation. - -It tries to make the best use of the famous [opentracker](https://erdgeist.org/arts/software/opentracker/). - -## Run - -```bash -$docker run -d --name bittorrent-tracker -p 6969:6969/udp -p 6969:6969 -v \ - offline_whitelisted_files.tsv:/etc/opentracker/offline_whitelisted_files.tsv ghcr.io/kiwix/bittorrent-tracker` -``` - -This will bind the port `6969` to the docker container (UDP and TCP) and you're good to go. - -The `offline_whitelisted_files.tsv` keeps track of which files are -published at https://library.kiwix.org/. It can be empty at start, but -will be populated over time. - -This file is then used (indirectly) by opentracker to know which -torrent can be whitelisted. - -## Thanks & Donations -[Best wishes to the creators of opentracker!](http://erdgeist.org/arts/software/opentracker/) -opentracker is _beerware_ so feel free to donate those guys a drink ;-) diff --git a/bittorrent-tracker/blacklist.txt b/bittorrent-tracker/blacklist.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/bittorrent-tracker/build_whitelist.sh b/bittorrent-tracker/build_whitelist.sh deleted file mode 100755 index df08a6e7..00000000 --- a/bittorrent-tracker/build_whitelist.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh - -set -e - -echo "(re)building whitelist" - -OFFLINE_WHITELISTED_FILES=/etc/opentracker/offline_whitelisted_files.tsv -OPENTRACKER_WHITELIST=/etc/opentracker/whitelist.txt - -SORTED_ONLINE_META4_URLS=/dev/shm/online_meta4_urls.tsv -SORTED_OFFLINE_META4_URLS=/dev/shm/offline_meta4_urls.tsv -NEW_META4_URLS=/dev/shm/new_meta4_urls.tsv -NEW_OFFLINE_WHITELISTED_FILES=/dev/shm/new_offline_whitelisted_files.tsv - -echo "> Retrieving published Metalink URLs from Library OPDS feed" -ONLINE_META4_URLS=$(curl --silent -L -H "Accept-Encoding: gzip" 'https://library.kiwix.org/catalog/v2/entries?count=-1' | gunzip | xml2 | grep '/feed/entry/link/@href=http.*meta4' | cut -f 2 -d '=') -echo "${ONLINE_META4_URLS}" | sort > $SORTED_ONLINE_META4_URLS - -echo "> Extracting Metalink URLs from Local List" -if [ -s "${OFFLINE_WHITELISTED_FILES}" ] ; then - cat "${OFFLINE_WHITELISTED_FILES}" | cut -f 2 | sort > $SORTED_OFFLINE_META4_URLS -else - touch $SORTED_OFFLINE_META4_URLS -fi - -echo "> Extracting new Metalink URLs" -comm -13 $SORTED_OFFLINE_META4_URLS $SORTED_ONLINE_META4_URLS > $NEW_META4_URLS -if [ ! -s $NEW_META4_URLS ] ; then echo "> none, done." ; exit 0 ; fi - -echo "> Retrieving BitTorrent hashes" -CONTENT="" -rm -f $NEW_OFFLINE_WHITELISTED_FILES -echo "" -for META4_URL in $(cat $NEW_META4_URLS) -do - BTIH_URL=$(echo $META4_URL | sed 's/meta4$/btih/') - set +e - BTIH_DATA=$(curl --silent --fail $BTIH_URL) - bith_res=$? - set -e - if [ "$bith_res" != "0" ]; then - echo ".... Skipping $META4_URL (not ready)" - continue - fi - BTIH_DATA=$(echo $BTIH_DATA | sed 's/ /\t/') - CURRENT_TIME=$(date +%s) - retrieved=$((retrieved+1)) - echo "\e[1A\e[K> retrieved… $retrieved" - echo "${CURRENT_TIME}\t${META4_URL}\t${BTIH_DATA}" >> $NEW_OFFLINE_WHITELISTED_FILES -done -if [ ! -s $NEW_OFFLINE_WHITELISTED_FILES ] ; then exit 0 ; fi - -echo "> Merging with Local List" -cat $NEW_OFFLINE_WHITELISTED_FILES >> "${OFFLINE_WHITELISTED_FILES}" - -echo "> Creating Opentracker Whitelist of hashes" -cat "${OFFLINE_WHITELISTED_FILES}" | cut -f 3 | sort -u > "${OPENTRACKER_WHITELIST}" - -tpid=$(pidof opentracker) || true -if [ ! -z "$tpid" ]; then - echo "> Requesting opentracker to reload whitelist" - kill -s HUP $tpid -fi diff --git a/bittorrent-tracker/entrypoint.sh b/bittorrent-tracker/entrypoint.sh deleted file mode 100755 index 63ede263..00000000 --- a/bittorrent-tracker/entrypoint.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -set -e - -echo "Building whitelist…" -/etc/cron.hourly/build-whitelist - -echo "Starting cron..." -service cron start - -echo "Starting opentracker…" -exec "$@" diff --git a/bittorrent-tracker/opentracker.conf b/bittorrent-tracker/opentracker.conf deleted file mode 100644 index 1e1b264e..00000000 --- a/bittorrent-tracker/opentracker.conf +++ /dev/null @@ -1,106 +0,0 @@ -# opentracker config file -# - -# I) Address opentracker will listen on, using both, tcp AND udp family -# (note, that port 6969 is implicite if ommitted). -# -# If no listen option is given (here or on the command line), opentracker -# listens on 0.0.0.0:6969 tcp and udp. -# -# The next variable determines if udp sockets are handled in the event -# loop (set it to 0, the default) or are handled in blocking reads in -# dedicated worker threads. You have to set this value before the -# listen.tcp_udp or listen.udp statements before it takes effect, but you -# can re-set it for each listen statement. Normally you should keep it at -# the top of the config file. -# -# listen.udp.workers 4 -# -# listen.tcp_udp 0.0.0.0 -# listen.tcp_udp 192.168.0.1:80 -# listen.tcp_udp 10.0.0.5:6969 -# -# To only listen on tcp or udp family ports, list them this way: -# -# listen.tcp 0.0.0.0 -# listen.udp 192.168.0.1:6969 -# -# Note, that using 0.0.0.0 for udp sockets may yield surprising results. -# An answer packet sent on that socket will not necessarily have the -# source address that the requesting client may expect, but any address -# on that interface. -# - -# II) If opentracker runs in a non-open mode, point it to files containing -# all torrent hashes that it will serve (shell option -w) -# -# access.whitelist /etc/opentracker/whitelist.txt -# -# or, if opentracker was compiled to allow blacklisting (shell option -b) -# -# access.blacklist /etc/opentracker/blacklist.txt -# -# It is pointless and hence not possible to compile black AND white -# listing, so choose one of those options at compile time. File format -# is straight forward: "\n\n..." -# -# If you do not want to grant anyone access to your stats, enable the -# WANT_RESTRICT_STATS option in Makefile and bless the ip addresses -# allowed to fetch stats here. -# -# access.stats 192.168.0.23 -# -# There is another way of hiding your stats. You can obfuscate the path -# to them. Normally it is located at /stats but you can configure it to -# appear anywhere on your tracker. -# -# access.stats_path stats - -# III) Live sync uses udp multicast packets to keep a cluster of opentrackers -# synchronized. This option tells opentracker which port to listen for -# incoming live sync packets. The ip address tells opentracker, on which -# interface to join the multicast group, those packets will arrive. -# (shell option -i 192.168.0.1 -s 9696), port 9696 is default. -# -# livesync.cluster.listen 192.168.0.1:9696 -# -# Note that two udp sockets will be opened. One on ip address 0.0.0.0 -# port 9696, that will join the multicast group 224.0.42.23 for incoming -# udp packets and one on ip address 192.168.0.1 port 9696 for outgoing -# udp packets. -# -# As of now one and only one ip address must be given, if opentracker -# was built with the WANT_SYNC_LIVE feature. -# - -# IV) Sync between trackers running in a cluster is restricted to packets -# coming from trusted ip addresses. While source ip verification is far -# from perfect, the authors of opentracker trust in the correct -# application of tunnels, filters and LAN setups (shell option -A). -# -# livesync.cluster.node_ip 192.168.0.4 -# livesync.cluster.node_ip 192.168.0.5 -# livesync.cluster.node_ip 192.168.0.6 -# -# This is the admin ip address for old style (HTTP based) asynchronus -# tracker syncing. -# -# batchsync.cluster.admin_ip 10.1.1.1 -# - -# V) Control privilege drop behaviour. -# Put in the directory opentracker will chroot/chdir to. All black/white -# list files must be put in that directory (shell option -d). -# -# -# tracker.rootdir /usr/local/etc/opentracker -# -# Tell opentracker which user to setuid to. -# -# tracker.user nobody -# - -# VI) opentracker can be told to answer to a "GET / HTTP"-request with a -# redirect to another location (shell option -r). -# -tracker.redirect_url https://kiwix.org diff --git a/bittorrent-tracker/whitelist.txt b/bittorrent-tracker/whitelist.txt deleted file mode 100644 index e69de29b..00000000