diff --git a/CHANGELOG.md b/CHANGELOG.md index 53e6c1a48..361f12807 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ **Merged pull requests:** +- Fixed announcer-list issue [\#1129](https://github.com/torrentpier/torrentpier/pull/1129) ([belomaxorka](https://github.com/belomaxorka)) - Removed client column from bb_bt_tracker table [\#1128](https://github.com/torrentpier/torrentpier/pull/1128) ([belomaxorka](https://github.com/belomaxorka)) - Removed one-time used variables [\#1120](https://github.com/torrentpier/torrentpier/pull/1120) ([belomaxorka](https://github.com/belomaxorka)) - Don't create empty announce-list dict, if ann_urls are empty [\#1119](https://github.com/torrentpier/torrentpier/pull/1119) ([kovalensky](https://github.com/kovalensky)) diff --git a/src/Legacy/Torrent.php b/src/Legacy/Torrent.php index a52048c66..57b067234 100644 --- a/src/Legacy/Torrent.php +++ b/src/Legacy/Torrent.php @@ -547,9 +547,12 @@ class Torrent bb_die($lang['TORFILE_INVALID']); } + // Get tracker announcer + $announce_url = $bb_cfg['ocelot']['enabled'] ? $bb_cfg['ocelot']['url'] . "$passkey_val/announce" : $bb_cfg['bt_announce_url'] . "?$passkey_key=$passkey_val"; + // Replace original announce url with tracker default - if ($bb_cfg['bt_replace_ann_url'] || !isset($tor['announce'])) { - $tor['announce'] = $bb_cfg['ocelot']['enabled'] ? $bb_cfg['ocelot']['url'] . "$passkey_val/announce" : $bb_cfg['bt_announce_url'] . "?$passkey_key=$passkey_val"; + if ($bb_cfg['bt_replace_ann_url']) { + $tor['announce'] = $announce_url; } // Get additional announce urls @@ -564,14 +567,31 @@ class Torrent // Delete all additional urls if ($bb_cfg['bt_del_addit_ann_urls'] || $bb_cfg['bt_disable_dht']) { unset($tor['announce-list']); - } elseif (!empty($announce_urls_add)) { - $tor['announce-list'] = array_merge($tor['announce-list'] ?? [], $announce_urls_add); + } else { + // Creating announce-list if not exist + if (!isset($tor['announce-list']) || !is_array($tor['announce-list'])) { + $tor['announce-list'] = []; + } + + // Adding tracker announcer to announce-list + if ($bb_cfg['bt_replace_ann_url']) { + // Adding tracker announcer as main announcer (At start) + array_unshift($tor['announce-list'], [$announce_url]); + } else { + // Adding tracker announcer (At end) + $tor['announce-list'] = array_merge($tor['announce-list'], [[$announce_url]]); + } + + // Adding additional announce urls (If present) + if (!empty($announce_urls_add)) { + $tor['announce-list'] = array_merge($tor['announce-list'], $announce_urls_add); + } } // Add retracker if (!empty($bb_cfg['tracker']['retracker_host']) && $bb_cfg['tracker']['retracker']) { if (bf($userdata['user_opt'], 'user_opt', 'user_retracker') || IS_GUEST) { - $tor['announce-list'] = array_merge($tor['announce-list'] ?? [], [[$bb_cfg['tracker']['retracker_host']]]); + $tor['announce-list'] = array_merge($tor['announce-list'], [[$bb_cfg['tracker']['retracker_host']]]); } }