Merge branch 'net8'

pull/473/head
Yaakov 2 years ago
commit 828ba1ecaf

@ -33,7 +33,7 @@ jobs:
dotnet-version: 8.0.x
- name: Build
run: dotnet publish -c ${{ matrix.configuration }} -o artifacts
run: dotnet publish DepotDownloader/DepotDownloader.csproj -c ${{ matrix.configuration }} -o artifacts
- name: Upload artifact
uses: actions/upload-artifact@v3
@ -45,31 +45,31 @@ jobs:
- name: Publish Windows-x64
if: matrix.configuration == 'Release' && matrix.runs-on == 'windows-latest'
run: dotnet publish --configuration Release -p:PublishSingleFile=true -p:DebugType=embedded --self-contained --runtime win-x64 --output selfcontained-win-x64
run: dotnet publish DepotDownloader/DepotDownloader.csproj --configuration Release -p:PublishSingleFile=true -p:DebugType=embedded --self-contained --runtime win-x64 --output selfcontained-win-x64
- name: Publish Windows-arm64
if: matrix.configuration == 'Release' && matrix.runs-on == 'windows-latest'
run: dotnet publish --configuration Release -p:PublishSingleFile=true -p:DebugType=embedded --self-contained --runtime win-arm64 --output selfcontained-win-arm64
run: dotnet publish DepotDownloader/DepotDownloader.csproj --configuration Release -p:PublishSingleFile=true -p:DebugType=embedded --self-contained --runtime win-arm64 --output selfcontained-win-arm64
- name: Publish Linux-x64
if: matrix.configuration == 'Release' && matrix.runs-on == 'ubuntu-latest'
run: dotnet publish --configuration Release -p:PublishSingleFile=true -p:DebugType=embedded --self-contained --runtime linux-x64 --output selfcontained-linux-x64
run: dotnet publish DepotDownloader/DepotDownloader.csproj --configuration Release -p:PublishSingleFile=true -p:DebugType=embedded --self-contained --runtime linux-x64 --output selfcontained-linux-x64
- name: Publish Linux-arm
if: matrix.configuration == 'Release' && matrix.runs-on == 'ubuntu-latest'
run: dotnet publish --configuration Release -p:PublishSingleFile=true -p:DebugType=embedded --self-contained --runtime linux-arm --output selfcontained-linux-arm
run: dotnet publish DepotDownloader/DepotDownloader.csproj --configuration Release -p:PublishSingleFile=true -p:DebugType=embedded --self-contained --runtime linux-arm --output selfcontained-linux-arm
- name: Publish Linux-arm64
if: matrix.configuration == 'Release' && matrix.runs-on == 'ubuntu-latest'
run: dotnet publish --configuration Release -p:PublishSingleFile=true -p:DebugType=embedded --self-contained --runtime linux-arm64 --output selfcontained-linux-arm64
run: dotnet publish DepotDownloader/DepotDownloader.csproj --configuration Release -p:PublishSingleFile=true -p:DebugType=embedded --self-contained --runtime linux-arm64 --output selfcontained-linux-arm64
- name: Publish macOS-x64
if: matrix.configuration == 'Release' && matrix.runs-on == 'macos-latest'
run: dotnet publish --configuration Release -p:PublishSingleFile=true -p:DebugType=embedded --self-contained --runtime osx-x64 --output selfcontained-osx-x64
run: dotnet publish DepotDownloader/DepotDownloader.csproj --configuration Release -p:PublishSingleFile=true -p:DebugType=embedded --self-contained --runtime osx-x64 --output selfcontained-osx-x64
- name: Publish macOS-arm64
if: matrix.configuration == 'Release' && matrix.runs-on == 'macos-14'
run: dotnet publish --configuration Release -p:PublishSingleFile=true -p:DebugType=embedded --self-contained --runtime osx-arm64 --output selfcontained-osx-arm64
if: matrix.configuration == 'Release' && matrix.runs-on == 'macos-latest'
run: dotnet publish DepotDownloader/DepotDownloader.csproj --configuration Release -p:PublishSingleFile=true -p:DebugType=embedded --self-contained --runtime osx-arm64 --output selfcontained-osx-arm64
- name: Upload Windows-x64
uses: actions/upload-artifact@v3

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
@ -11,8 +11,7 @@ namespace DepotDownloader
[ProtoContract]
class AccountSettingsStore
{
[ProtoMember(1, IsRequired = false)]
public Dictionary<string, byte[]> SentryData { get; private set; }
// Member 1 was a Dictionary<string, byte[]> for SentryData.
[ProtoMember(2, IsRequired = false)]
public ConcurrentDictionary<string, int> ContentServerPenalty { get; private set; }
@ -22,13 +21,16 @@ namespace DepotDownloader
[ProtoMember(4, IsRequired = false)]
public Dictionary<string, string> LoginTokens { get; private set; }
[ProtoMember(5, IsRequired = false)]
public Dictionary<string, string> GuardData { get; private set; }
string FileName;
AccountSettingsStore()
{
SentryData = new Dictionary<string, byte[]>();
ContentServerPenalty = new ConcurrentDictionary<string, int>();
LoginTokens = new Dictionary<string, string>();
GuardData = new Dictionary<string, string>();
}
static bool Loaded

@ -1163,7 +1163,7 @@ namespace DepotDownloader
neededChunks = Util.ValidateSteam3FileChecksums(fs, file.Chunks.OrderBy(x => x.Offset).ToArray());
}
if (neededChunks.Count() == 0)
if (neededChunks.Count == 0)
{
lock (depotDownloadCounter)
{

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<RollForward>LatestMajor</RollForward>
<Version>2.5.0</Version>
@ -12,7 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="protobuf-net" Version="3.2.16" />
<PackageReference Include="protobuf-net" Version="3.2.26" />
<PackageReference Include="QRCoder" Version="1.4.3" />
<PackageReference Include="SteamKit2" Version="2.5.0-Beta.1" />
</ItemGroup>

@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics.Tracing;
using System.Text;
@ -35,7 +35,7 @@ namespace DepotDownloader
}
}
sb.Append(")");
sb.Append(')');
Console.WriteLine(sb.ToString());
}
}

@ -1,7 +1,8 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Security.Cryptography;
using ProtoBuf;
using SteamKit2;
@ -135,7 +136,7 @@ namespace DepotDownloader
using (var ds = new DeflateStream(fs, CompressionMode.Decompress))
ds.CopyTo(ms);
checksum = Util.SHAHash(ms.ToArray());
checksum = SHA1.HashData(ms.ToArray());
ms.Seek(0, SeekOrigin.Begin);
return Serializer.Deserialize<ProtoManifest>(ms);
@ -148,7 +149,7 @@ namespace DepotDownloader
{
Serializer.Serialize(ms, this);
checksum = Util.SHAHash(ms.ToArray());
checksum = SHA1.HashData(ms.ToArray());
ms.Seek(0, SeekOrigin.Begin);

@ -2,7 +2,6 @@ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -112,26 +111,9 @@ namespace DepotDownloader
this.callbacks.Subscribe<SteamUser.LoggedOnCallback>(LogOnCallback);
this.callbacks.Subscribe<SteamUser.SessionTokenCallback>(SessionTokenCallback);
this.callbacks.Subscribe<SteamApps.LicenseListCallback>(LicenseListCallback);
this.callbacks.Subscribe<SteamUser.UpdateMachineAuthCallback>(UpdateMachineAuthCallback);
Console.Write("Connecting to Steam3...");
if (details.Username != null)
{
var fi = new FileInfo(String.Format("{0}.sentryFile", logonDetails.Username));
if (AccountSettingsStore.Instance.SentryData != null && AccountSettingsStore.Instance.SentryData.ContainsKey(logonDetails.Username))
{
logonDetails.SentryFileHash = Util.SHAHash(AccountSettingsStore.Instance.SentryData[logonDetails.Username]);
}
else if (fi.Exists && fi.Length > 0)
{
var sentryData = File.ReadAllBytes(fi.FullName);
logonDetails.SentryFileHash = Util.SHAHash(sentryData);
AccountSettingsStore.Instance.SentryData[logonDetails.Username] = sentryData;
AccountSettingsStore.Save();
}
}
Connect();
}
@ -216,9 +198,9 @@ namespace DepotDownloader
};
var request = new SteamApps.PICSRequest(appId);
if (AppTokens.ContainsKey(appId))
if (AppTokens.TryGetValue(appId, out var token))
{
request.AccessToken = AppTokens[appId];
request.AccessToken = token;
}
WaitUntilCallback(() =>
@ -508,11 +490,13 @@ namespace DepotDownloader
{
try
{
_ = AccountSettingsStore.Instance.GuardData.TryGetValue(logonDetails.Username, out var guarddata);
authSession = await steamClient.Authentication.BeginAuthSessionViaCredentialsAsync(new SteamKit2.Authentication.AuthSessionDetails
{
Username = logonDetails.Username,
Password = logonDetails.Password,
IsPersistentSession = ContentDownloader.Config.RememberPassword,
GuardData = guarddata,
Authenticator = new UserConsoleAuthenticator(),
});
}
@ -576,6 +560,14 @@ namespace DepotDownloader
logonDetails.Password = null;
logonDetails.AccessToken = result.RefreshToken;
if (result.NewGuardData != null)
{
AccountSettingsStore.Instance.GuardData[result.AccountName] = result.NewGuardData;
}
else
{
AccountSettingsStore.Instance.GuardData.Remove(result.AccountName);
}
AccountSettingsStore.Instance.LoginTokens[result.AccountName] = result.RefreshToken;
AccountSettingsStore.Save();
}
@ -657,7 +649,7 @@ namespace DepotDownloader
{
Console.Write("Please enter your 2 factor auth code from your authenticator app: ");
logonDetails.TwoFactorCode = Console.ReadLine();
} while (String.Empty == logonDetails.TwoFactorCode);
} while (string.Empty == logonDetails.TwoFactorCode);
}
else if (isAccessToken)
{
@ -749,35 +741,6 @@ namespace DepotDownloader
}
}
private void UpdateMachineAuthCallback(SteamUser.UpdateMachineAuthCallback machineAuth)
{
var hash = Util.SHAHash(machineAuth.Data);
Console.WriteLine("Got Machine Auth: {0} {1} {2} {3}", machineAuth.FileName, machineAuth.Offset, machineAuth.BytesToWrite, machineAuth.Data.Length);
AccountSettingsStore.Instance.SentryData[logonDetails.Username] = machineAuth.Data;
AccountSettingsStore.Save();
var authResponse = new SteamUser.MachineAuthDetails
{
BytesWritten = machineAuth.BytesToWrite,
FileName = machineAuth.FileName,
FileSize = machineAuth.BytesToWrite,
Offset = machineAuth.Offset,
SentryFileHash = hash, // should be the sha1 hash of the sentry file we just wrote
OneTimePassword = machineAuth.OneTimePassword, // not sure on this one yet, since we've had no examples of steam using OTPs
LastError = 0, // result from win32 GetLastError
Result = EResult.OK, // if everything went okay, otherwise ~who knows~
JobID = machineAuth.JobID, // so we respond to the correct server job
};
// send off our response
steamUser.SendMachineAuthResponse(authResponse);
}
private static void DisplayQrCode(string challengeUrl)
{
// Encode the link as a QR code

@ -1,9 +1,8 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
@ -113,16 +112,6 @@ namespace DepotDownloader
return BitConverter.GetBytes(a | (b << 16));
}
public static byte[] SHAHash(byte[] input)
{
using (var sha = SHA1.Create())
{
var output = sha.ComputeHash(input);
return output;
}
}
public static byte[] DecodeHexString(string hex)
{
if (hex == null)
@ -146,8 +135,8 @@ namespace DepotDownloader
public static async Task InvokeAsync(IEnumerable<Func<Task>> taskFactories, int maxDegreeOfParallelism)
{
if (taskFactories == null) throw new ArgumentNullException(nameof(taskFactories));
if (maxDegreeOfParallelism <= 0) throw new ArgumentException(nameof(maxDegreeOfParallelism));
ArgumentNullException.ThrowIfNull(taskFactories);
ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(maxDegreeOfParallelism, 0);
var queue = taskFactories.ToArray();

Loading…
Cancel
Save