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. 17
      src/public/action.php
  5. 12
      src/public/edit.php
  6. 12
      src/public/index.php
  7. 12
      src/public/magnet.php
  8. 32
      src/public/node.php

9
README.md

@ -10,8 +10,11 @@ YGGtracker uses [Yggdrasil](https://github.com/yggdrasil-network/yggdrasil-go) I @@ -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 @@ -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

21
src/config/app.php.example

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

16
src/config/trackers.json

@ -0,0 +1,16 @@ @@ -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"
}
]

17
src/public/action.php

@ -472,9 +472,10 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false) @@ -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) @@ -759,11 +760,13 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
<div class="container">
<div class="row">
<div class="column width-100 text-center margin-y-8">
<?php foreach (TRACKER_LINKS as $name => $value) { ?>
<a href="<?php echo $value->announce ?>"><?php echo $name ?></a>
/
<a href="<?php echo $value->stats ?>"><?php echo _('Stats') ?></a>
|
<?php foreach (json_decode(file_get_contents(__DIR__ . '/../config/trackers.json')) as $i => $tracker) { ?>
<?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 $tracker->stats ?>"><?php echo _('Stats') ?></a>
|
<?php } ?>
<?php } ?>
<a href="<?php echo WEBSITE_URL ?>/node.php"><?php echo _('Node') ?></a>
|

12
src/public/edit.php

@ -634,11 +634,13 @@ else { @@ -634,11 +634,13 @@ else {
<div class="container">
<div class="row">
<div class="column width-100 text-center margin-y-8">
<?php foreach (TRACKER_LINKS as $name => $value) { ?>
<a href="<?php echo $value->announce ?>"><?php echo $name ?></a>
/
<a href="<?php echo $value->stats ?>"><?php echo _('Stats') ?></a>
|
<?php foreach (json_decode(file_get_contents(__DIR__ . '/../config/trackers.json')) as $i => $tracker) { ?>
<?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 $tracker->stats ?>"><?php echo _('Stats') ?></a>
|
<?php } ?>
<?php } ?>
<a href="<?php echo WEBSITE_URL ?>/node.php"><?php echo _('Node') ?></a>
|

12
src/public/index.php

@ -395,11 +395,13 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?> @@ -395,11 +395,13 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
<div class="container">
<div class="row">
<div class="column width-100 text-center margin-y-8">
<?php foreach (TRACKER_LINKS as $name => $value) { ?>
<a href="<?php echo $value->announce ?>"><?php echo $name ?></a>
/
<a href="<?php echo $value->stats ?>"><?php echo _('Stats') ?></a>
|
<?php foreach (json_decode(file_get_contents(__DIR__ . '/../config/trackers.json')) as $i => $tracker) { ?>
<?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 $tracker->stats ?>"><?php echo _('Stats') ?></a>
|
<?php } ?>
<?php } ?>
<a href="<?php echo WEBSITE_URL ?>/node.php"><?php echo _('Node') ?></a>
|

12
src/public/magnet.php

@ -466,11 +466,13 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?> @@ -466,11 +466,13 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
<div class="container">
<div class="row">
<div class="column width-100 text-center margin-y-8">
<?php foreach (TRACKER_LINKS as $name => $value) { ?>
<a href="<?php echo $value->announce ?>"><?php echo $name ?></a>
/
<a href="<?php echo $value->stats ?>"><?php echo _('Stats') ?></a>
|
<?php foreach (json_decode(file_get_contents(__DIR__ . '/../config/trackers.json')) as $i => $tracker) { ?>
<?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 $tracker->stats ?>"><?php echo _('Stats') ?></a>
|
<?php } ?>
<?php } ?>
<a href="<?php echo WEBSITE_URL ?>/node.php"><?php echo _('Node') ?></a>
|

32
src/public/node.php

@ -182,17 +182,19 @@ else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROV @@ -182,17 +182,19 @@ 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">
<?php echo _('Trackers') ?>
</td>
<?php foreach (TRACKER_LINKS as $name => $settings) { ?>
<?php foreach (json_decode(file_get_contents(__DIR__ . '/../config/trackers.json')) as $i => $tracker) { ?>
<tr>
<td class="padding-t-16"><?php echo $name ?></td>
<td class="padding-t-16"><?php echo sprintf('#%s', $i + 1) ?></td>
</tr>
<?php foreach ($settings as $key => $value) { ?>
<tr>
<td>
<span class="margin-l-16"><?php echo $key ?></span>
</td>
<td><?php echo $value ?></td>
</tr>
<?php foreach ($tracker as $key => $value) { ?>
<?php if ($value) { ?>
<tr>
<td>
<span class="margin-l-16"><?php echo $key ?></span>
</td>
<td><?php echo $value ?></td>
</tr>
<?php } ?>
<?php } ?>
<?php } ?>
</tr>
@ -210,11 +212,13 @@ else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROV @@ -210,11 +212,13 @@ else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROV
<div class="container">
<div class="row">
<div class="column width-100 text-center margin-y-8">
<?php foreach (TRACKER_LINKS as $name => $value) { ?>
<a href="<?php echo $value->announce ?>"><?php echo $name ?></a>
/
<a href="<?php echo $value->stats ?>"><?php echo _('Stats') ?></a>
|
<?php foreach (json_decode(file_get_contents(__DIR__ . '/../config/trackers.json')) as $i => $tracker) { ?>
<?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 $tracker->stats ?>"><?php echo _('Stats') ?></a>
|
<?php } ?>
<?php } ?>
<a href="<?php echo WEBSITE_URL ?>/node.php"><?php echo _('Node') ?></a>
|

Loading…
Cancel
Save