make speedtest rate limit to remote config and default to 0.5h
This commit is contained in:
@@ -20,9 +20,10 @@ public class StaticFilesServerConfiguration : MareConfigurationBase
|
|||||||
public bool UseColdStorage { get; set; } = false;
|
public bool UseColdStorage { get; set; } = false;
|
||||||
public string ColdStorageDirectory { get; set; } = null;
|
public string ColdStorageDirectory { get; set; } = null;
|
||||||
public double ColdStorageSizeHardLimitInGiB { get; set; } = -1;
|
public double ColdStorageSizeHardLimitInGiB { get; set; } = -1;
|
||||||
public int SpeedTestHoursRateLimit { get; set; } = 6;
|
|
||||||
public int ColdStorageUnusedFileRetentionPeriodInDays { get; set; } = 30;
|
public int ColdStorageUnusedFileRetentionPeriodInDays { get; set; } = 30;
|
||||||
[RemoteConfiguration]
|
[RemoteConfiguration]
|
||||||
|
public double SpeedTestHoursRateLimit { get; set; } = 0.5;
|
||||||
|
[RemoteConfiguration]
|
||||||
public Uri CdnFullUrl { get; set; } = null;
|
public Uri CdnFullUrl { get; set; } = null;
|
||||||
[RemoteConfiguration]
|
[RemoteConfiguration]
|
||||||
public List<CdnShardConfiguration> CdnShardConfiguration { get; set; } = new();
|
public List<CdnShardConfiguration> CdnShardConfiguration { get; set; } = new();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class SpeedTestController : ControllerBase
|
|||||||
public async Task<IActionResult> DownloadTest(CancellationToken cancellationToken)
|
public async Task<IActionResult> DownloadTest(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var user = HttpContext.User.Claims.First(f => string.Equals(f.Type, MareClaimTypes.Uid, StringComparison.Ordinal)).Value;
|
var user = HttpContext.User.Claims.First(f => string.Equals(f.Type, MareClaimTypes.Uid, StringComparison.Ordinal)).Value;
|
||||||
var speedtestLimit = _configurationService.GetValueOrDefault(nameof(StaticFilesServerConfiguration.SpeedTestHoursRateLimit), 6);
|
var speedtestLimit = _configurationService.GetValueOrDefault(nameof(StaticFilesServerConfiguration.SpeedTestHoursRateLimit), 0.5);
|
||||||
if (_memoryCache.TryGetValue<DateTime>(user, out var value))
|
if (_memoryCache.TryGetValue<DateTime>(user, out var value))
|
||||||
{
|
{
|
||||||
var hoursRemaining = value.Subtract(DateTime.UtcNow).TotalHours;
|
var hoursRemaining = value.Subtract(DateTime.UtcNow).TotalHours;
|
||||||
|
|||||||
Reference in New Issue
Block a user