mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-13 18:04:16 +01:00
make speedtest rate limit to remote config and default to 0.5h
This commit is contained in:
parent
0d72e3b40e
commit
532c123927
2 changed files with 3 additions and 2 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue