From c90eb5073c83527eb9f191c56450ec1f4903c1fa Mon Sep 17 00:00:00 2001 From: plucury Date: Tue, 10 Mar 2020 21:54:00 +0800 Subject: [PATCH] avoid add trackers for private torrents --- README.md | 13 ++++++++----- tracker-add-auto.sh | 9 ++++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index bb75ba8..e144ad2 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,11 @@ A: Yes, host=host:port or host=http(s?)://host:port/transmission/
Changelog - + ``` +Mar 10, 2020 +avoid add trackers for private torrents + Mar 27, 2019 add tracker-add-auto-router.sh script for routers now tracker file saved in tmp directory until update web source @@ -57,9 +60,9 @@ Take image `docker pull andrewmhub/transmission-tracker-add` ```docker run --net=host -d -e HOSTPORT=localhost:9091 -e TR_AUTH=user:password --name=transmission-tracker-add andrewmhub/transmission-tracker-add:latest``` -if you need another torrent tracker list then use docker run env +if you need another torrent tracker list then use docker run env -`-e TORRENTLIST=https://raw.githubusercontent.com/user/trackerslist/master/mylist.txt` +`-e TORRENTLIST=https://raw.githubusercontent.com/user/trackerslist/master/mylist.txt` you have transmission daemon in docker then read [Docker Documentation Network](https://docs.docker.com/network/) @@ -89,7 +92,7 @@ systemctl status transmission-tracker-add.service CGroup: /system.slice/transmission-tracker-add.service ├─19102 /bin/bash /opt/bin/add-trackers-auto.sh └─31204 sleep 5 - + ``` #### * Simple way (for routers) @@ -98,7 +101,7 @@ Requirements: curl, transmission-remote Download script and make it executable: -Edit settings for transmission set rpc-enabled, rpc-username and rpc-password +Edit settings for transmission set rpc-enabled, rpc-username, rpc-password and your pt trackers ``` wget --no-check-certificate -O tracker-add-auto-router.sh https://raw.githubusercontent.com/AndrewMarchukov/tracker-add/master/tracker-add-auto-router.sh diff --git a/tracker-add-auto.sh b/tracker-add-auto.sh index 44c417e..78ea34d 100644 --- a/tracker-add-auto.sh +++ b/tracker-add-auto.sh @@ -2,6 +2,8 @@ # Get transmission credentials and ip or dns address auth=user:password host=localhost +trackers=https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt +pt_trackers=() while true ; do sleep 25 @@ -9,7 +11,7 @@ add_trackers () { torrent_hash=$1 id=$2 trackerslist=/tmp/trackers.txt -for base_url in https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt ; do +for base_url in $trackers ; do if [ ! -f $trackerslist ]; then curl -o "$trackerslist" "${base_url}" fi @@ -39,6 +41,11 @@ for id in $ids ; do add_date_t="$(date -d "$add_date" "+%Y-%m-%d %H:%M")" dater="$(date "+%Y-%m-%d %H:%M")" dateo="$(date -d "1 minutes ago" "+%Y-%m-%d %H:%M")" + tracker0="$(transmission-remote "$host" --auth="$auth" -t "$id" -it|sed -n '2,2p'|awk '{print $3}'|awk -F : '{print $2}'|sed -e 's/\/\///')" + if [[ " ${pt_trackers[@]} " =~ " $tracker0 " ]]; then + echo "skip id=" $id $tracker0 + continue + fi if [ ! -f "/tmp/TTAA.$id.lock" ]; then if [[ "( "$add_date_t" == "$dater" || "$add_date_t" == "$dateo" )" ]]; then