From d0db358eba543c1b8bce70c0db77a805c8bc8629 Mon Sep 17 00:00:00 2001 From: ghost Date: Thu, 31 Aug 2023 22:21:43 +0300 Subject: [PATCH] move trackers list to json config file --- README.md | 9 ++++++--- src/config/app.php.example | 21 --------------------- src/config/trackers.json | 16 ++++++++++++++++ src/public/action.php | 17 ++++++++++------- src/public/edit.php | 12 +++++++----- src/public/index.php | 12 +++++++----- src/public/magnet.php | 12 +++++++----- src/public/node.php | 32 ++++++++++++++++++-------------- 8 files changed, 71 insertions(+), 60 deletions(-) create mode 100644 src/config/trackers.json diff --git a/README.md b/README.md index 5c17ae6..466f22d 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,11 @@ YGGtracker uses [Yggdrasil](https://github.com/yggdrasil-network/yggdrasil-go) I #### Trackers - * `http://[201:23b4:991a:634d:8359:4521:5576:15b7]/announce` [stats](http://[201:23b4:991a:634d:8359:4521:5576:15b7]/stats) - * `http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/announce` [stats](http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/stats) +Initial trackers defined in [trackers.json](#). + +* Application appends trackers to all download links and magnet forms +* Trackers not in list will be cropped by the application filter +* Feel free to PR new yggdrasil tracker instance! #### Requirements @@ -115,7 +118,7 @@ git checkout -b my-pr-branch-name #### Feedback -Feel free to [share](https://github.com/YGGverse/YGGtracker/issues) your ideas and bug reports! +[https://github.com/YGGverse/YGGtracker/issues](https://github.com/YGGverse/YGGtracker/issues) #### Community diff --git a/src/config/app.php.example b/src/config/app.php.example index c38aa62..30d697c 100644 --- a/src/config/app.php.example +++ b/src/config/app.php.example @@ -109,27 +109,6 @@ define('COMMENT_DEFAULT_PUBLIC', false); define('COMMENT_MIN_LENGTH', 1); define('COMMENT_MAX_LENGTH', 1000); -// Trackers -define('TRACKER_LINKS', (object) - [ - 'Tracker 1' => (object) - [ - 'url' => 'http://[201:23b4:991a:634d:8359:4521:5576:15b7]/yggtracker', - 'announce' => 'http://[201:23b4:991a:634d:8359:4521:5576:15b7]/announce', - 'stats' => 'http://[201:23b4:991a:634d:8359:4521:5576:15b7]/stats', - 'scrape' => 'http://[201:23b4:991a:634d:8359:4521:5576:15b7]/scrape', - ], - 'Tracker 2' => (object) - [ - 'url' => false, - 'announce' => 'http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/announce', - 'stats' => 'http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/stats', - 'scrape' => 'http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/scrape', - ], - // ... - ] -); - // Yggdrasil define('YGGDRASIL_URL_REGEX', '/^0{0,1}[2-3][a-f0-9]{0,2}:/'); // thanks to @ygguser (https://github.com/YGGverse/YGGo/issues/1#issuecomment-1498182228 ) diff --git a/src/config/trackers.json b/src/config/trackers.json new file mode 100644 index 0000000..8d47c85 --- /dev/null +++ b/src/config/trackers.json @@ -0,0 +1,16 @@ +[ + { + "description":"YGGtracker instance, yggdrasil-only connections", + "url":"http://[201:23b4:991a:634d:8359:4521:5576:15b7]/yggtracker", + "announce":"http://[201:23b4:991a:634d:8359:4521:5576:15b7]/announce", + "stats":"http://[201:23b4:991a:634d:8359:4521:5576:15b7]/stats", + "scrape":"http://[201:23b4:991a:634d:8359:4521:5576:15b7]/scrape" + }, + { + "description":"Yggdrasil-only torrent tracker, operated by jeff", + "url":false, + "announce":"http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/announce", + "stats":"http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/stats", + "scrape":"http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/scrape" + } +] \ No newline at end of file diff --git a/src/public/action.php b/src/public/action.php index adb2d24..c852ac7 100644 --- a/src/public/action.php +++ b/src/public/action.php @@ -472,9 +472,10 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false) $link[] = $url; } - foreach (TRACKER_LINKS as $tracker => $value) + // Append trackers.json + foreach (json_decode(file_get_contents(__DIR__ . '/../config/trackers.json')) as $tracker) { - $link[] = sprintf('tr=%s', urlencode($value->announce)); + $link[] = sprintf('tr=%s', urlencode($tracker->announce)); } /// Acceptable Source @@ -759,11 +760,13 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
- $value) { ?> - - / - - | + $tracker) { ?> + announce) && !empty($tracker->stats)) { ?> + + / + + | + | diff --git a/src/public/edit.php b/src/public/edit.php index 88c1df4..207b034 100644 --- a/src/public/edit.php +++ b/src/public/edit.php @@ -634,11 +634,13 @@ else {
- $value) { ?> - - / - - | + $tracker) { ?> + announce) && !empty($tracker->stats)) { ?> + + / + + | + | diff --git a/src/public/index.php b/src/public/index.php index c564894..9a41a77 100644 --- a/src/public/index.php +++ b/src/public/index.php @@ -395,11 +395,13 @@ echo '' . PHP_EOL ?>
- $value) { ?> - - / - - | + $tracker) { ?> + announce) && !empty($tracker->stats)) { ?> + + / + + | + | diff --git a/src/public/magnet.php b/src/public/magnet.php index ff6ab77..7251660 100644 --- a/src/public/magnet.php +++ b/src/public/magnet.php @@ -466,11 +466,13 @@ echo '' . PHP_EOL ?>
- $value) { ?> - - / - - | + $tracker) { ?> + announce) && !empty($tracker->stats)) { ?> + + / + + | + | diff --git a/src/public/node.php b/src/public/node.php index a792b55..2fe437b 100644 --- a/src/public/node.php +++ b/src/public/node.php @@ -182,17 +182,19 @@ else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROV - $settings) { ?> + $tracker) { ?> - + - $value) { ?> - - - - - - + $value) { ?> + + + + + + + + @@ -210,11 +212,13 @@ else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROV
- $value) { ?> - - / - - | + $tracker) { ?> + announce) && !empty($tracker->stats)) { ?> + + / + + | + |