feat(remote): implement idle seeding limits (#2947)
This commit is contained in:
parent
96de1706af
commit
88d280be8f
|
@ -212,7 +212,7 @@ enum
|
||||||
|
|
||||||
// --- Command-Line Arguments
|
// --- Command-Line Arguments
|
||||||
|
|
||||||
auto constexpr Options = std::array<tr_option, 98>{
|
static auto constexpr Options = std::array<tr_option, 108>{
|
||||||
{ { 'a', "add", "Add torrent files by filename or URL", "a", false, nullptr },
|
{ { 'a', "add", "Add torrent files by filename or URL", "a", false, nullptr },
|
||||||
{ 970, "alt-speed", "Use the alternate Limits", "as", false, nullptr },
|
{ 970, "alt-speed", "Use the alternate Limits", "as", false, nullptr },
|
||||||
{ 971, "no-alt-speed", "Don't use the alternate Limits", "AS", false, nullptr },
|
{ 971, "no-alt-speed", "Don't use the alternate Limits", "AS", false, nullptr },
|
||||||
|
@ -307,6 +307,31 @@ auto constexpr Options = std::array<tr_option, 98>{
|
||||||
"GSR",
|
"GSR",
|
||||||
false,
|
false,
|
||||||
nullptr },
|
nullptr },
|
||||||
|
{ 955,
|
||||||
|
"idle-seeding-limit",
|
||||||
|
"Let the current torrent(s) seed until a specific amount idle time",
|
||||||
|
"isl",
|
||||||
|
true,
|
||||||
|
"<minutes>" },
|
||||||
|
{ 956,
|
||||||
|
"default-idle-seeding-limit",
|
||||||
|
"Let the current torrent(s) use the default idle seeding settings",
|
||||||
|
"isld",
|
||||||
|
false,
|
||||||
|
nullptr },
|
||||||
|
{ 957, "no-idle-seeding-limit", "Let the current torrent(s) seed regardless of idle time", "ISL", false, nullptr },
|
||||||
|
{ 958,
|
||||||
|
"global-idle-seeding-limit",
|
||||||
|
"All torrents, unless overridden by a per-torrent setting, should seed until a specific amount of idle time",
|
||||||
|
"gisl",
|
||||||
|
true,
|
||||||
|
"<minutes>" },
|
||||||
|
{ 959,
|
||||||
|
"no-global-idle-seeding-limit",
|
||||||
|
"All torrents, unless overridden by a per-torrent setting, should seed regardless of idle time",
|
||||||
|
"GISL",
|
||||||
|
false,
|
||||||
|
nullptr },
|
||||||
{ 710, "tracker-add", "Add a tracker to a torrent", "td", true, "<tracker>" },
|
{ 710, "tracker-add", "Add a tracker to a torrent", "td", true, "<tracker>" },
|
||||||
{ 712, "tracker-remove", "Remove a tracker from a torrent", "tr", true, "<trackerId>" },
|
{ 712, "tracker-remove", "Remove a tracker from a torrent", "tr", true, "<trackerId>" },
|
||||||
{ 's', "start", "Start the current torrent(s)", "s", false, nullptr },
|
{ 's', "start", "Start the current torrent(s)", "s", false, nullptr },
|
||||||
|
@ -436,6 +461,8 @@ enum
|
||||||
case 912: /* encryption-tolerated */
|
case 912: /* encryption-tolerated */
|
||||||
case 953: /* global-seedratio */
|
case 953: /* global-seedratio */
|
||||||
case 954: /* no-global-seedratio */
|
case 954: /* no-global-seedratio */
|
||||||
|
case 958: /* global-idle-seeding-limit */
|
||||||
|
case 959: /* no-global-idle-seeding-limit */
|
||||||
case 990: /* start-paused */
|
case 990: /* start-paused */
|
||||||
case 991: /* no-start-paused */
|
case 991: /* no-start-paused */
|
||||||
case 992: /* trash-torrent */
|
case 992: /* trash-torrent */
|
||||||
|
@ -446,6 +473,9 @@ enum
|
||||||
case 950: /* seedratio */
|
case 950: /* seedratio */
|
||||||
case 951: /* seedratio-default */
|
case 951: /* seedratio-default */
|
||||||
case 952: /* no-seedratio */
|
case 952: /* no-seedratio */
|
||||||
|
case 955: /* idle-seeding-limit */
|
||||||
|
case 956: /* default-idle-seeding-limit */
|
||||||
|
case 957: /* no-idle-seeding-limit*/
|
||||||
case 984: /* honor-session */
|
case 984: /* honor-session */
|
||||||
case 985: /* no-honor-session */
|
case 985: /* no-honor-session */
|
||||||
return MODE_TORRENT_SET;
|
return MODE_TORRENT_SET;
|
||||||
|
@ -704,7 +734,7 @@ auto constexpr FilesKeys = std::array<tr_quark, 4>{
|
||||||
TR_KEY_wanted,
|
TR_KEY_wanted,
|
||||||
};
|
};
|
||||||
|
|
||||||
auto constexpr DetailsKeys = std::array<tr_quark, 53>{
|
static auto constexpr DetailsKeys = std::array<tr_quark, 56>{
|
||||||
TR_KEY_activityDate,
|
TR_KEY_activityDate,
|
||||||
TR_KEY_addedDate,
|
TR_KEY_addedDate,
|
||||||
TR_KEY_bandwidthPriority,
|
TR_KEY_bandwidthPriority,
|
||||||
|
@ -747,6 +777,8 @@ auto constexpr DetailsKeys = std::array<tr_quark, 53>{
|
||||||
TR_KEY_seedRatioMode,
|
TR_KEY_seedRatioMode,
|
||||||
TR_KEY_seedRatioLimit,
|
TR_KEY_seedRatioLimit,
|
||||||
TR_KEY_sequentialDownload,
|
TR_KEY_sequentialDownload,
|
||||||
|
TR_KEY_seedIdleMode,
|
||||||
|
TR_KEY_seedIdleLimit,
|
||||||
TR_KEY_sizeWhenDone,
|
TR_KEY_sizeWhenDone,
|
||||||
TR_KEY_source,
|
TR_KEY_source,
|
||||||
TR_KEY_startDate,
|
TR_KEY_startDate,
|
||||||
|
@ -1212,6 +1244,31 @@ void printDetails(tr_variant* top)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tr_variantDictFindInt(t, TR_KEY_seedIdleMode, &i))
|
||||||
|
{
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case TR_IDLELIMIT_GLOBAL:
|
||||||
|
fmt::print(" Idle Limit: Default\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TR_IDLELIMIT_SINGLE:
|
||||||
|
if (tr_variantDictFindInt(t, TR_KEY_seedIdleLimit, &j))
|
||||||
|
{
|
||||||
|
fmt::print(" Idle Limit: {} minutes\n", j);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TR_IDLELIMIT_UNLIMITED:
|
||||||
|
fmt::print(" Idle Limit: Unlimited\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tr_variantDictFindBool(t, TR_KEY_honorsSessionLimits, &boolVal))
|
if (tr_variantDictFindBool(t, TR_KEY_honorsSessionLimits, &boolVal))
|
||||||
{
|
{
|
||||||
fmt::print(" Honors Session Limits: {:s}\n", boolVal ? "Yes" : "No");
|
fmt::print(" Honors Session Limits: {:s}\n", boolVal ? "Yes" : "No");
|
||||||
|
@ -1792,6 +1849,7 @@ void printSession(tr_variant* top)
|
||||||
bool upEnabled;
|
bool upEnabled;
|
||||||
bool downEnabled;
|
bool downEnabled;
|
||||||
bool seedRatioLimited;
|
bool seedRatioLimited;
|
||||||
|
bool seedIdleLimited;
|
||||||
int64_t altDown;
|
int64_t altDown;
|
||||||
int64_t altUp;
|
int64_t altUp;
|
||||||
int64_t altBegin;
|
int64_t altBegin;
|
||||||
|
@ -1800,6 +1858,7 @@ void printSession(tr_variant* top)
|
||||||
int64_t upLimit;
|
int64_t upLimit;
|
||||||
int64_t downLimit;
|
int64_t downLimit;
|
||||||
int64_t peerLimit;
|
int64_t peerLimit;
|
||||||
|
int64_t seedIdleLimit;
|
||||||
double seedRatioLimit;
|
double seedRatioLimit;
|
||||||
|
|
||||||
if (tr_variantDictFindInt(args, TR_KEY_alt_speed_down, &altDown) &&
|
if (tr_variantDictFindInt(args, TR_KEY_alt_speed_down, &altDown) &&
|
||||||
|
@ -1815,13 +1874,19 @@ void printSession(tr_variant* top)
|
||||||
tr_variantDictFindInt(args, TR_KEY_speed_limit_up, &upLimit) &&
|
tr_variantDictFindInt(args, TR_KEY_speed_limit_up, &upLimit) &&
|
||||||
tr_variantDictFindBool(args, TR_KEY_speed_limit_up_enabled, &upEnabled) &&
|
tr_variantDictFindBool(args, TR_KEY_speed_limit_up_enabled, &upEnabled) &&
|
||||||
tr_variantDictFindReal(args, TR_KEY_seedRatioLimit, &seedRatioLimit) &&
|
tr_variantDictFindReal(args, TR_KEY_seedRatioLimit, &seedRatioLimit) &&
|
||||||
tr_variantDictFindBool(args, TR_KEY_seedRatioLimited, &seedRatioLimited))
|
tr_variantDictFindBool(args, TR_KEY_seedRatioLimited, &seedRatioLimited) &&
|
||||||
|
tr_variantDictFindInt(args, TR_KEY_idle_seeding_limit, &seedIdleLimit) &&
|
||||||
|
tr_variantDictFindBool(args, TR_KEY_idle_seeding_limit_enabled, &seedIdleLimited))
|
||||||
{
|
{
|
||||||
fmt::print("LIMITS\n");
|
fmt::print("LIMITS\n");
|
||||||
fmt::print(" Peer limit: {:d}\n", peerLimit);
|
fmt::print(" Peer limit: {:d}\n", peerLimit);
|
||||||
|
|
||||||
fmt::print(" Default seed ratio limit: {:s}\n", seedRatioLimited ? strlratio2(seedRatioLimit) : "Unlimited");
|
fmt::print(" Default seed ratio limit: {:s}\n", seedRatioLimited ? strlratio2(seedRatioLimit) : "Unlimited");
|
||||||
|
|
||||||
|
fmt::print(
|
||||||
|
" Default idle seeding time limit: {:s}\n",
|
||||||
|
seedIdleLimited ? (std::to_string(seedIdleLimit) + " minutes").c_str() : "Unlimited");
|
||||||
|
|
||||||
std::string effective_up_limit;
|
std::string effective_up_limit;
|
||||||
|
|
||||||
if (altEnabled)
|
if (altEnabled)
|
||||||
|
@ -2767,6 +2832,15 @@ int processArgs(char const* rpcurl, int argc, char const* const* argv, RemoteCon
|
||||||
tr_variantDictAddBool(args, TR_KEY_seedRatioLimited, false);
|
tr_variantDictAddBool(args, TR_KEY_seedRatioLimited, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 958:
|
||||||
|
tr_variantDictAddInt(args, TR_KEY_idle_seeding_limit, atoi(optarg));
|
||||||
|
tr_variantDictAddBool(args, TR_KEY_idle_seeding_limit_enabled, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 959:
|
||||||
|
tr_variantDictAddBool(args, TR_KEY_idle_seeding_limit_enabled, false);
|
||||||
|
break;
|
||||||
|
|
||||||
case 990:
|
case 990:
|
||||||
tr_variantDictAddBool(args, TR_KEY_start_added_torrents, false);
|
tr_variantDictAddBool(args, TR_KEY_start_added_torrents, false);
|
||||||
break;
|
break;
|
||||||
|
@ -2903,6 +2977,19 @@ int processArgs(char const* rpcurl, int argc, char const* const* argv, RemoteCon
|
||||||
tr_variantDictAddInt(args, TR_KEY_seedRatioMode, TR_RATIOLIMIT_UNLIMITED);
|
tr_variantDictAddInt(args, TR_KEY_seedRatioMode, TR_RATIOLIMIT_UNLIMITED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 955:
|
||||||
|
tr_variantDictAddInt(args, TR_KEY_seedIdleLimit, atoi(optarg));
|
||||||
|
tr_variantDictAddInt(args, TR_KEY_seedIdleMode, TR_IDLELIMIT_SINGLE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 956:
|
||||||
|
tr_variantDictAddInt(args, TR_KEY_seedIdleMode, TR_IDLELIMIT_GLOBAL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 957:
|
||||||
|
tr_variantDictAddInt(args, TR_KEY_seedIdleMode, TR_IDLELIMIT_UNLIMITED);
|
||||||
|
break;
|
||||||
|
|
||||||
case 984:
|
case 984:
|
||||||
tr_variantDictAddBool(args, TR_KEY_honorsSessionLimits, true);
|
tr_variantDictAddBool(args, TR_KEY_honorsSessionLimits, true);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -28,6 +28,8 @@ and
|
||||||
.Op Fl F Ar filter
|
.Op Fl F Ar filter
|
||||||
.Op Fl g Ar files
|
.Op Fl g Ar files
|
||||||
.Op Fl G Ar files
|
.Op Fl G Ar files
|
||||||
|
.Op Fl gisl Ar number
|
||||||
|
.Op Fl GISL Ar number
|
||||||
.Op Fl gsr Ar ratio
|
.Op Fl gsr Ar ratio
|
||||||
.Op Fl GSR
|
.Op Fl GSR
|
||||||
.Op Fl h
|
.Op Fl h
|
||||||
|
@ -36,6 +38,9 @@ and
|
||||||
.Op Fl ids
|
.Op Fl ids
|
||||||
.Op Fl if
|
.Op Fl if
|
||||||
.Op Fl ip
|
.Op Fl ip
|
||||||
|
.Op Fl isl Ar number
|
||||||
|
.Op Fl ISL Ar number
|
||||||
|
.Op Fl isld
|
||||||
.Op Fl it
|
.Op Fl it
|
||||||
.Op Fl j
|
.Op Fl j
|
||||||
.Op Fl l
|
.Op Fl l
|
||||||
|
@ -176,6 +181,17 @@ All torrents, unless overridden by a per-torrent setting, should seed until a sp
|
||||||
.Ar ratio
|
.Ar ratio
|
||||||
.It Fl GSR Fl -no-global-seedratio
|
.It Fl GSR Fl -no-global-seedratio
|
||||||
All torrents, unless overridden by a per-torrent setting, should seed regardless of ratio
|
All torrents, unless overridden by a per-torrent setting, should seed regardless of ratio
|
||||||
|
.It Fl isl Fl -idle-seeding-limit Ar minutes
|
||||||
|
Let the selected torrent(s) seed until a specific amount of idle time
|
||||||
|
.It Fl isld Fl -default-idle-seeding-limit
|
||||||
|
Use the default idle-seeding-limit for the selected torrent
|
||||||
|
.It Fl ISL Fl -no-idle-seeding-limit
|
||||||
|
Let the selected torrent(s) seed regardless of idle time
|
||||||
|
.It Fl gisl Fl -global-idle-seeding-limit Ar minutes
|
||||||
|
All torrents, unless overridden by a per-torrent, should stop seeding after spending the specified time idling
|
||||||
|
.It Fl GISL Fl -no-global-idle-seeding-limit
|
||||||
|
All torrents, unless overridden by a per-torrent, should seed regardless of the time spent idle
|
||||||
|
Let the selected torrent(s) seed regardless of idle time
|
||||||
.It Fl h Fl -help
|
.It Fl h Fl -help
|
||||||
Print command-line option descriptions.
|
Print command-line option descriptions.
|
||||||
.It Fl i Fl -info
|
.It Fl i Fl -info
|
||||||
|
|
Loading…
Reference in New Issue