Fix several issues with client authorization with the server

This commit is contained in:
Timothy Baldridge 2021-04-11 16:04:12 -06:00
parent 131c11809f
commit 8bca15cb36
5 changed files with 34 additions and 2 deletions

View File

@ -27,6 +27,7 @@ namespace Wabbajack.Lib.Http
};
Utils.Log($"Configuring with SSL {_socketsHandler.SslOptions.EnabledSslProtocols}");
Client = new SysHttp.HttpClient(_socketsHandler);
Client.DefaultRequestHeaders.Add("User-Agent", Consts.UserAgent);
}
}
}

View File

@ -164,8 +164,12 @@ namespace Wabbajack.Lib.ModListRegistry
public string Link => $"/lists/status/{MachineURL}.json";
[JsonProperty("report")]
public string Report => $"/lists/status/{MachineURL}.html";
[JsonProperty("modlist_missing")]
public bool ModListIsMissing { get; set; }
[JsonProperty("has_failures")]
public bool HasFailures => Failed > 0;
public bool HasFailures => Failed > 0 || ModListIsMissing;
}
}

View File

@ -16,5 +16,6 @@ namespace Wabbajack.Server.DTOs
public ConcurrentHashSet<(Game Game, long ModId)> SlowQueriedFor { get; set; } = new ConcurrentHashSet<(Game Game, long ModId)>();
public Dictionary<Hash, bool> Mirrors { get; set; }
public Lazy<Task<Dictionary<Hash, string>>> AllowedMirrors { get; set; }
public IEnumerable<AuthoredFilesSummary> AllAuthoredFiles { get; set; }
}
}

View File

@ -18,6 +18,7 @@ namespace Wabbajack.Server.DataLayer
var archiveStatus = AllModListArchivesStatus();
var modLists = AllModLists();
var mirrors = GetAllMirroredHashes();
var authoredFiles = AllAuthoredFiles();
return new ValidationData
{
NexusFiles = new ConcurrentHashSet<(long Game, long ModId, long FileId)>((await nexusFiles).Select(f => (f.NexusGameId, f.ModId, f.FileId))),
@ -25,6 +26,7 @@ namespace Wabbajack.Server.DataLayer
ModLists = await modLists,
Mirrors = await mirrors,
AllowedMirrors = new Lazy<Task<Dictionary<Hash, string>>>(async () => await GetAllowedMirrors()),
AllAuthoredFiles = await authoredFiles,
};
}

View File

@ -53,10 +53,33 @@ namespace Wabbajack.Server.Services
timer.Start();
var oldSummary =
oldSummaries.FirstOrDefault(s => s.Summary.MachineURL == metadata.Links.MachineURL);
var mainFile = await DownloadDispatcher.Infer(new Uri(metadata.Links.Download));
var mainArchive = new Archive(mainFile!)
{
Size = metadata.DownloadMetadata!.Size,
Hash = metadata.DownloadMetadata!.Hash
};
bool mainFailed = false;
try
{
if (!await mainArchive.State.Verify(mainArchive))
{
mainFailed = true;
}
}
catch (Exception ex)
{
mainFailed = true;
}
var listArchives = await _sql.ModListArchives(metadata.Links.MachineURL);
var archives = await listArchives.PMap(queue, async archive =>
{
if (mainFailed)
return (archive, ArchiveStatus.InValid);
try
{
ReportStarting(archive.State.PrimaryKeyString);
@ -107,6 +130,7 @@ namespace Wabbajack.Server.Services
Mirrored = mirroredCount,
MachineURL = metadata.Links.MachineURL,
Name = metadata.Title,
ModListIsMissing = mainFailed
};
var detailed = new DetailedStatus