mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 22:03:49 -07:00
Update announce.php
This commit is contained in:
parent
1abd1176bf
commit
ed8fe6fbf1
1 changed files with 27 additions and 25 deletions
|
@ -113,10 +113,12 @@ if (!$bb_cfg['ignore_reported_ip'] && isset($_GET['ip']) && $ip !== $_GET['ip'])
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check that IP format is valid
|
||||
if (!\TorrentPier\Helpers\IPHelper::isValid($ip)) {
|
||||
msg_die("Invalid IP: $ip");
|
||||
}
|
||||
|
||||
// Convert IP to HEX format
|
||||
$ip_sql = \TorrentPier\Helpers\IPHelper::ip2long($ip);
|
||||
|
||||
|
@ -133,31 +135,6 @@ if ($lp_info && (!isset($event) || $event !== 'stopped')) {
|
|||
drop_fast_announce($lp_info);
|
||||
}
|
||||
|
||||
// Functions
|
||||
function drop_fast_announce($lp_info)
|
||||
{
|
||||
global $announce_interval;
|
||||
|
||||
if ($lp_info['update_time'] < (TIMENOW - $announce_interval + 60)) {
|
||||
return; // if announce interval correct
|
||||
}
|
||||
|
||||
$new_ann_intrv = $lp_info['update_time'] + $announce_interval - TIMENOW;
|
||||
|
||||
dummy_exit($new_ann_intrv);
|
||||
}
|
||||
|
||||
function msg_die($msg)
|
||||
{
|
||||
$output = \SandFox\Bencode\Bencode::encode([
|
||||
'min interval' => (int)1800,
|
||||
'failure reason' => (string)$msg,
|
||||
'warning message' => (string)$msg,
|
||||
]);
|
||||
|
||||
die($output);
|
||||
}
|
||||
|
||||
// Start announcer
|
||||
require __DIR__ . '/includes/init_tr.php';
|
||||
|
||||
|
@ -423,6 +400,31 @@ if (!$output) {
|
|||
$peers_list_cached = CACHE('tr_cache')->set(PEERS_LIST_PREFIX . $topic_id, $output, PEERS_LIST_EXPIRE);
|
||||
}
|
||||
|
||||
// Functions
|
||||
function drop_fast_announce($lp_info)
|
||||
{
|
||||
global $announce_interval;
|
||||
|
||||
if ($lp_info['update_time'] < (TIMENOW - $announce_interval + 60)) {
|
||||
return; // if announce interval correct
|
||||
}
|
||||
|
||||
$new_ann_intrv = $lp_info['update_time'] + $announce_interval - TIMENOW;
|
||||
|
||||
dummy_exit($new_ann_intrv);
|
||||
}
|
||||
|
||||
function msg_die($msg)
|
||||
{
|
||||
$output = \SandFox\Bencode\Bencode::encode([
|
||||
'min interval' => (int)1800,
|
||||
'failure reason' => (string)$msg,
|
||||
'warning message' => (string)$msg,
|
||||
]);
|
||||
|
||||
die($output);
|
||||
}
|
||||
|
||||
// Return data to client
|
||||
echo \SandFox\Bencode\Bencode::encode($output);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue