mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
Announcer support for responding to stopped events (#918)
* Announcer support for answering stopped events
This commit is contained in:
parent
9a372605f3
commit
6a007023da
2 changed files with 6 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue