Announcer support for responding to stopped events (#918)

* Announcer support for answering stopped events
This commit is contained in:
Constantine Kovalensky 2023-09-30 13:20:55 +04:00 committed by GitHub
commit 6a007023da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View file

@ -46,14 +46,14 @@ $input_vars_num = ['port', 'uploaded', 'downloaded', 'left', 'numwant', 'compact
// Init received data
// String
foreach ($input_vars_str as $var_name) {
${$var_name} = isset($_GET[$var_name]) ? (string)$_GET[$var_name] : null;
$$var_name = isset($_GET[$var_name]) ? (string)$_GET[$var_name] : null;
}
// Numeric
foreach ($input_vars_num as $var_name) {
${$var_name} = isset($_GET[$var_name]) ? (float)$_GET[$var_name] : null;
$$var_name = isset($_GET[$var_name]) ? (float)$_GET[$var_name] : null;
}
// Passkey
$passkey = ${$passkey_key} ?? null;
$passkey = $$passkey_key ?? null;
// Verify request
// Required params (info_hash, peer_id, port, uploaded, downloaded, left, passkey)
@ -339,7 +339,7 @@ if (($is_hybrid && $hybrid_tor_update) || !$is_hybrid) { // Update statistics on
// Exit if stopped
if ($stopped) {
silent_exit();
silent_exit('Cache will be reset within 30 seconds');
}
// Store peer info in cache

View file

@ -21,17 +21,15 @@ if ($bb_cfg['tracker']['bt_off']) {
//
// Functions
//
function silent_exit()
function silent_exit($msg = '')
{
ob_end_clean();
echo \SandFox\Bencode\Bencode::encode(['warning message' => str_compact($msg)]);
exit;
}
function error_exit($msg = '')
{
silent_exit();
echo \SandFox\Bencode\Bencode::encode(['failure reason' => str_compact($msg)]);
exit;