Merge pull request #1079 from wabbajack-tools/ips-reworks

Ips reworks
This commit is contained in:
Timothy Baldridge 2020-09-09 16:40:32 -06:00 committed by GitHub
commit ba2d1878b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 86 additions and 17 deletions

View File

@ -1,5 +1,10 @@
### Changelog
#### Version - 2.3.0.0 - ???
* Rewrote the file extraction routines. New code uses less memory, less disk space, and performs less thrashing on HDDs
* Reworked IPS4 integration to reduce download failures
#### Version - 2.2.2.0 - 8/31/2020
* Route CDN requests through a reverse proxy to improve reliability

View File

@ -86,7 +86,7 @@ namespace Compression.BSA
if (BSA.HeaderType == VersionType.SSE)
{
if (Compressed)
if (Compressed && size.Size != size.OnDisk)
{
using var r = LZ4Stream.Decode(rdr.BaseStream);
await r.CopyToLimitAsync(output, size.Original).ConfigureAwait(false);

View File

@ -131,6 +131,8 @@ namespace Wabbajack.Common
public static AbsolutePath SettingsFile => LocalAppDataPath.Combine("settings.json");
public static RelativePath SettingsIni = (RelativePath)"settings.ini";
public static byte SettingsVersion => 2;
public static bool IsServer = false;
public static string CompressedBodyHeader = "x-compressed-body";
public static AbsolutePath CefCacheLocation = @"CEF".RelativeTo(LocalAppDataPath);

View File

@ -329,6 +329,7 @@ namespace Wabbajack.Common
{
await using var fs = await Create();
await data.CopyToAsync(fs);
await data.FlushAsync();
if (disposeDataAfter) await data.DisposeAsync();
}

View File

@ -13,8 +13,9 @@ using System.Threading.Tasks;
using Wabbajack.Common.Exceptions;
using Wabbajack.Common.Serialization.Json;
using Wabbajack.Lib.Downloaders;
namespace Wabbajack.Lib
using Wabbajack.Lib.LibCefHelpers;
namespace Wabbajack.Lib
{
public static class BuildServerStatus
{
@ -254,5 +255,12 @@ namespace Wabbajack.Lib
return null;
}
}
public static async Task<Helpers.Cookie[]> GetAuthInfo<T>(string key)
{
var client = await GetClient();
return await client.GetJsonAsync<Helpers.Cookie[]>(
$"{Consts.WabbajackBuildServerUri}site-integration/auth-info/{key}");
}
}
}

View File

@ -86,18 +86,24 @@ namespace Wabbajack.Lib.Downloaders
return cookies;
}
public async Task<Wabbajack.Lib.Http.Client> GetAuthedClient()
public async Task<Http.Client> GetAuthedClient()
{
Helpers.Cookie[] cookies;
try
if (Consts.IsServer)
{
cookies = await Utils.FromEncryptedJson<Helpers.Cookie[]>(_encryptedKeyName);
if (cookies != null)
return Helpers.GetClient(cookies, SiteURL.ToString());
}
catch (FileNotFoundException) { }
try
{
cookies = await Utils.FromEncryptedJson<Helpers.Cookie[]>(_encryptedKeyName);
if (cookies != null)
return Helpers.GetClient(cookies, SiteURL.ToString());
}
catch (FileNotFoundException) { }
cookies = await Utils.Log(new RequestSiteLogin(this)).Task;
cookies = await Utils.Log(new RequestSiteLogin(this)).Task;
return Helpers.GetClient(cookies, SiteURL.ToString());
}
cookies = await ClientAPI.GetAuthInfo<Helpers.Cookie[]>(_encryptedKeyName);
return Helpers.GetClient(cookies, SiteURL.ToString());
}

View File

@ -56,8 +56,13 @@ namespace Wabbajack.Lib.Downloaders
if (state != null)
return state;
}
return null;
var meta = string.Join("\n", new string[]
{
"[General]",
$"directURL={uri}"
});
return (AbstractDownloadState)(await ResolveArchive(meta.LoadIniString()));
}
public static T GetInstance<T>() where T : IDownloader

View File

@ -17,7 +17,9 @@
<Version>3.1.0</Version>
</PackageReference>
<PackageReference Include="Fody">
<Version>6.2.4</Version>
<Version>6.2.5</Version>
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Genbox.AlphaFS">
<Version>2.2.2.1</Version>

View File

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Wabbajack.Common;
using Wabbajack.Lib.Downloaders;
namespace Wabbajack.BuildServer.Controllers
{
[ApiController]
[Authorize(Roles = "User")]
[Route("/site-integration")]
public class SiteIntegration : ControllerBase
{
private ILogger<SiteIntegration> _logger;
public SiteIntegration(ILogger<SiteIntegration> logger)
{
_logger = logger;
}
private HashSet<string> Allowed = new HashSet<string>
{ "loverslabcookies", "deadlystream", "tesall", "tesalliance", "vectorplexus"};
[Route("auth-info/{site}")]
public async Task<IActionResult> GetAuthInfo(string site)
{
if (!Allowed.Contains(site))
{
return BadRequest("No key found");
}
return Ok(Encoding.UTF8.GetString(await Utils.FromEncryptedData(site)));
}
}
}

View File

@ -4,6 +4,7 @@ using System.Net;
using System.Security.Cryptography.X509Certificates;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Wabbajack.Common;
namespace Wabbajack.Server
{
@ -11,6 +12,7 @@ namespace Wabbajack.Server
{
public static void Main(string[] args)
{
Consts.IsServer = true;
bool testMode = args.Contains("TESTMODE");
CreateHostBuilder(args, testMode).Build().Run();
}

View File

@ -18,7 +18,7 @@
<PackageReference Include="Dapper" Version="2.0.35" />
<PackageReference Include="FluentFTP" Version="32.4.4" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Core" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.7" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Nettle" Version="1.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.1" />

View File

@ -56,9 +56,9 @@
<ItemGroup>
<PackageReference Include="CefSharp.Wpf" Version="84.4.10" />
<PackageReference Include="DynamicData" Version="6.16.8" />
<PackageReference Include="DynamicData" Version="6.16.9" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.0.1" />
<PackageReference Include="Fody" Version="6.2.4">
<PackageReference Include="Fody" Version="6.2.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>