announce use warn() + one IP one client

This commit is contained in:
xiaomlove
2023-06-10 02:07:56 +08:00
parent 3bf2b3591a
commit 7d1af5b351
4 changed files with 69 additions and 43 deletions

View File

@@ -1,6 +1,6 @@
<?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.4');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-06-08');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-06-10');
defined('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");

View File

@@ -61,8 +61,37 @@ function benc_resp_raw($x) {
else
echo $x;
}
/**
* client will retry, keep the event param
* @param $msg
* @return void
*/
function err($msg)
{
benc_resp(['failure reason' => $msg]);
exit();
}
/**
* client will not retry, think about success with warning message
* @param $msg
* @param int $interval
* @return void|null
*/
function warn($msg, int $interval = 7200)
{
$d = get_resp_dict_from_global();
$d['warning message'] = $msg;
if ($interval > 0) {
$d['interval'] = intval($interval);
$d['min interval'] = intval($interval);
}
benc_resp($d);
exit();
}
function get_resp_dict_from_global() {
if (isset($GLOBALS['rep_dict'])) {
$d = $GLOBALS['rep_dict'];
} else {
@@ -79,15 +108,7 @@ function err($msg)
$d['peers6'] = ''; // If peer use IPv6 address , we should add packed string in `peers6`
}
}
if (!empty($_REQUEST['event'])) {
//keep fail response, next request keep event param
$d['failure reason'] = $msg;
} else {
//avoid retry frequent
$d['warning message'] = $msg;
}
benc_resp($d);
exit();
return $d;
}
function check_cheater($userid, $torrentid, $uploaded, $downloaded, $anctime, $seeders=0, $leechers=0){