Browse Source

move trackers list to json config file

main
ghost 1 year ago
parent
commit
d0db358eba
  1. 9
      README.md
  2. 21
      src/config/app.php.example
  3. 16
      src/config/trackers.json
  4. 13
      src/public/action.php
  5. 8
      src/public/edit.php
  6. 8
      src/public/index.php
  7. 8
      src/public/magnet.php
  8. 16
      src/public/node.php

9
README.md

@ -10,8 +10,11 @@ YGGtracker uses [Yggdrasil](https://github.com/yggdrasil-network/yggdrasil-go) I
#### Trackers #### Trackers
* `http://[201:23b4:991a:634d:8359:4521:5576:15b7]/announce` [stats](http://[201:23b4:991a:634d:8359:4521:5576:15b7]/stats) Initial trackers defined in [trackers.json](#).
* `http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/announce` [stats](http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/stats)
* 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 #### Requirements
@ -115,7 +118,7 @@ git checkout -b my-pr-branch-name
#### Feedback #### 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 #### Community

21
src/config/app.php.example

@ -109,27 +109,6 @@ define('COMMENT_DEFAULT_PUBLIC', false);
define('COMMENT_MIN_LENGTH', 1); define('COMMENT_MIN_LENGTH', 1);
define('COMMENT_MAX_LENGTH', 1000); 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 // 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 ) 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 )

16
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"
}
]

13
src/public/action.php

@ -472,9 +472,10 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
$link[] = $url; $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 /// Acceptable Source
@ -759,12 +760,14 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="column width-100 text-center margin-y-8"> <div class="column width-100 text-center margin-y-8">
<?php foreach (TRACKER_LINKS as $name => $value) { ?> <?php foreach (json_decode(file_get_contents(__DIR__ . '/../config/trackers.json')) as $i => $tracker) { ?>
<a href="<?php echo $value->announce ?>"><?php echo $name ?></a> <?php if (!empty($tracker->announce) && !empty($tracker->stats)) { ?>
<a href="<?php echo $tracker->announce ?>"><?php echo sprintf('Tracker %s', $i + 1) ?></a>
/ /
<a href="<?php echo $value->stats ?>"><?php echo _('Stats') ?></a> <a href="<?php echo $tracker->stats ?>"><?php echo _('Stats') ?></a>
| |
<?php } ?> <?php } ?>
<?php } ?>
<a href="<?php echo WEBSITE_URL ?>/node.php"><?php echo _('Node') ?></a> <a href="<?php echo WEBSITE_URL ?>/node.php"><?php echo _('Node') ?></a>
| |
<a href="<?php echo WEBSITE_URL ?>/index.php?rss"><?php echo _('RSS') ?></a> <a href="<?php echo WEBSITE_URL ?>/index.php?rss"><?php echo _('RSS') ?></a>

8
src/public/edit.php

@ -634,12 +634,14 @@ else {
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="column width-100 text-center margin-y-8"> <div class="column width-100 text-center margin-y-8">
<?php foreach (TRACKER_LINKS as $name => $value) { ?> <?php foreach (json_decode(file_get_contents(__DIR__ . '/../config/trackers.json')) as $i => $tracker) { ?>
<a href="<?php echo $value->announce ?>"><?php echo $name ?></a> <?php if (!empty($tracker->announce) && !empty($tracker->stats)) { ?>
<a href="<?php echo $tracker->announce ?>"><?php echo sprintf('Tracker %s', $i + 1) ?></a>
/ /
<a href="<?php echo $value->stats ?>"><?php echo _('Stats') ?></a> <a href="<?php echo $tracker->stats ?>"><?php echo _('Stats') ?></a>
| |
<?php } ?> <?php } ?>
<?php } ?>
<a href="<?php echo WEBSITE_URL ?>/node.php"><?php echo _('Node') ?></a> <a href="<?php echo WEBSITE_URL ?>/node.php"><?php echo _('Node') ?></a>
| |
<a href="<?php echo WEBSITE_URL ?>/index.php?rss"><?php echo _('RSS') ?></a> <a href="<?php echo WEBSITE_URL ?>/index.php?rss"><?php echo _('RSS') ?></a>

8
src/public/index.php

@ -395,12 +395,14 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="column width-100 text-center margin-y-8"> <div class="column width-100 text-center margin-y-8">
<?php foreach (TRACKER_LINKS as $name => $value) { ?> <?php foreach (json_decode(file_get_contents(__DIR__ . '/../config/trackers.json')) as $i => $tracker) { ?>
<a href="<?php echo $value->announce ?>"><?php echo $name ?></a> <?php if (!empty($tracker->announce) && !empty($tracker->stats)) { ?>
<a href="<?php echo $tracker->announce ?>"><?php echo sprintf('Tracker %s', $i + 1) ?></a>
/ /
<a href="<?php echo $value->stats ?>"><?php echo _('Stats') ?></a> <a href="<?php echo $tracker->stats ?>"><?php echo _('Stats') ?></a>
| |
<?php } ?> <?php } ?>
<?php } ?>
<a href="<?php echo WEBSITE_URL ?>/node.php"><?php echo _('Node') ?></a> <a href="<?php echo WEBSITE_URL ?>/node.php"><?php echo _('Node') ?></a>
| |
<a href="<?php echo WEBSITE_URL ?>/index.php?rss<?php echo $request->query ? sprintf('&query=%s', urlencode($request->query)) : false ?>"><?php echo _('RSS') ?></a> <a href="<?php echo WEBSITE_URL ?>/index.php?rss<?php echo $request->query ? sprintf('&query=%s', urlencode($request->query)) : false ?>"><?php echo _('RSS') ?></a>

8
src/public/magnet.php

@ -466,12 +466,14 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="column width-100 text-center margin-y-8"> <div class="column width-100 text-center margin-y-8">
<?php foreach (TRACKER_LINKS as $name => $value) { ?> <?php foreach (json_decode(file_get_contents(__DIR__ . '/../config/trackers.json')) as $i => $tracker) { ?>
<a href="<?php echo $value->announce ?>"><?php echo $name ?></a> <?php if (!empty($tracker->announce) && !empty($tracker->stats)) { ?>
<a href="<?php echo $tracker->announce ?>"><?php echo sprintf('Tracker %s', $i + 1) ?></a>
/ /
<a href="<?php echo $value->stats ?>"><?php echo _('Stats') ?></a> <a href="<?php echo $tracker->stats ?>"><?php echo _('Stats') ?></a>
| |
<?php } ?> <?php } ?>
<?php } ?>
<a href="<?php echo WEBSITE_URL ?>/node.php"><?php echo _('Node') ?></a> <a href="<?php echo WEBSITE_URL ?>/node.php"><?php echo _('Node') ?></a>
| |
<a href="<?php echo WEBSITE_URL ?>/index.php?rss"><?php echo _('RSS') ?></a> <a href="<?php echo WEBSITE_URL ?>/index.php?rss"><?php echo _('RSS') ?></a>

16
src/public/node.php

@ -182,11 +182,12 @@ else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROV
<td class="padding-y-8 padding-b-8 border-bottom-default text-right" colspan="2"> <td class="padding-y-8 padding-b-8 border-bottom-default text-right" colspan="2">
<?php echo _('Trackers') ?> <?php echo _('Trackers') ?>
</td> </td>
<?php foreach (TRACKER_LINKS as $name => $settings) { ?> <?php foreach (json_decode(file_get_contents(__DIR__ . '/../config/trackers.json')) as $i => $tracker) { ?>
<tr> <tr>
<td class="padding-t-16"><?php echo $name ?></td> <td class="padding-t-16"><?php echo sprintf('#%s', $i + 1) ?></td>
</tr> </tr>
<?php foreach ($settings as $key => $value) { ?> <?php foreach ($tracker as $key => $value) { ?>
<?php if ($value) { ?>
<tr> <tr>
<td> <td>
<span class="margin-l-16"><?php echo $key ?></span> <span class="margin-l-16"><?php echo $key ?></span>
@ -195,6 +196,7 @@ else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROV
</tr> </tr>
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>
<?php } ?>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -210,12 +212,14 @@ else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROV
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="column width-100 text-center margin-y-8"> <div class="column width-100 text-center margin-y-8">
<?php foreach (TRACKER_LINKS as $name => $value) { ?> <?php foreach (json_decode(file_get_contents(__DIR__ . '/../config/trackers.json')) as $i => $tracker) { ?>
<a href="<?php echo $value->announce ?>"><?php echo $name ?></a> <?php if (!empty($tracker->announce) && !empty($tracker->stats)) { ?>
<a href="<?php echo $tracker->announce ?>"><?php echo sprintf('Tracker %s', $i + 1) ?></a>
/ /
<a href="<?php echo $value->stats ?>"><?php echo _('Stats') ?></a> <a href="<?php echo $tracker->stats ?>"><?php echo _('Stats') ?></a>
| |
<?php } ?> <?php } ?>
<?php } ?>
<a href="<?php echo WEBSITE_URL ?>/node.php"><?php echo _('Node') ?></a> <a href="<?php echo WEBSITE_URL ?>/node.php"><?php echo _('Node') ?></a>
| |
<a href="<?php echo WEBSITE_URL ?>/index.php?rss"><?php echo _('RSS') ?></a> <a href="<?php echo WEBSITE_URL ?>/index.php?rss"><?php echo _('RSS') ?></a>

Loading…
Cancel
Save