From a479aa930199af77bda7e382f6aaa78ac7aed39c Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Thu, 18 Nov 2021 12:25:23 +0200 Subject: [PATCH 1/6] Update SteamKit --- DepotDownloader/DepotDownloader.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DepotDownloader/DepotDownloader.csproj b/DepotDownloader/DepotDownloader.csproj index a0713f34..8cbe4965 100644 --- a/DepotDownloader/DepotDownloader.csproj +++ b/DepotDownloader/DepotDownloader.csproj @@ -12,6 +12,6 @@ - + From bef429908a943853bb55921b56ec3e7bfff487e4 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Wed, 17 Nov 2021 14:52:35 +0200 Subject: [PATCH 2/6] Updates for SteamKit updates --- DepotDownloader/CDNClientPool.cs | 31 ++++++++++++++-------------- DepotDownloader/ContentDownloader.cs | 14 ++++++------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/DepotDownloader/CDNClientPool.cs b/DepotDownloader/CDNClientPool.cs index 485bbcd2..b0b8731b 100644 --- a/DepotDownloader/CDNClientPool.cs +++ b/DepotDownloader/CDNClientPool.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; @@ -6,6 +6,7 @@ using System.Net; using System.Threading; using System.Threading.Tasks; using SteamKit2; +using SteamKit2.CDN; namespace DepotDownloader { @@ -18,11 +19,11 @@ namespace DepotDownloader private readonly Steam3Session steamSession; private readonly uint appId; - public CDNClient CDNClient { get; } - public CDNClient.Server ProxyServer { get; private set; } + public Client CDNClient { get; } + public Server ProxyServer { get; private set; } - private readonly ConcurrentStack activeConnectionPool; - private readonly BlockingCollection availableServerEndpoints; + private readonly ConcurrentStack activeConnectionPool; + private readonly BlockingCollection availableServerEndpoints; private readonly AutoResetEvent populatePoolEvent; private readonly Task monitorTask; @@ -33,10 +34,10 @@ namespace DepotDownloader { this.steamSession = steamSession; this.appId = appId; - CDNClient = new CDNClient(steamSession.steamClient); + CDNClient = new Client(steamSession.steamClient); - activeConnectionPool = new ConcurrentStack(); - availableServerEndpoints = new BlockingCollection(); + activeConnectionPool = new ConcurrentStack(); + availableServerEndpoints = new BlockingCollection(); populatePoolEvent = new AutoResetEvent(true); shutdownToken = new CancellationTokenSource(); @@ -50,7 +51,7 @@ namespace DepotDownloader monitorTask.Wait(); } - private async Task> FetchBootstrapServerListAsync() + private async Task> FetchBootstrapServerListAsync() { var backoffDelay = 0; @@ -104,7 +105,7 @@ namespace DepotDownloader var weightedCdnServers = servers .Where(server => { - var isEligibleForApp = server.AllowedAppIds == null || server.AllowedAppIds.Contains(appId); + var isEligibleForApp = server.AllowedAppIds.Length == 0 || server.AllowedAppIds.Contains(appId); return isEligibleForApp && (server.Type == "SteamCache" || server.Type == "CDN"); }) .Select(server => @@ -133,7 +134,7 @@ namespace DepotDownloader } } - private CDNClient.Server BuildConnection(CancellationToken token) + private Server BuildConnection(CancellationToken token) { if (availableServerEndpoints.Count < ServerEndpointMinimumSize) { @@ -143,7 +144,7 @@ namespace DepotDownloader return availableServerEndpoints.Take(token); } - public CDNClient.Server GetConnection(CancellationToken token) + public Server GetConnection(CancellationToken token) { if (!activeConnectionPool.TryPop(out var connection)) { @@ -153,7 +154,7 @@ namespace DepotDownloader return connection; } - public async Task AuthenticateConnection(uint appId, uint depotId, CDNClient.Server server) + public async Task AuthenticateConnection(uint appId, uint depotId, Server server) { var host = steamSession.ResolveCDNTopLevelHost(server.Host); var cdnKey = $"{depotId:D}:{host}"; @@ -169,14 +170,14 @@ namespace DepotDownloader throw new Exception($"Failed to retrieve CDN token for server {server.Host} depot {depotId}"); } - public void ReturnConnection(CDNClient.Server server) + public void ReturnConnection(Server server) { if (server == null) return; activeConnectionPool.Push(server); } - public void ReturnBrokenConnection(CDNClient.Server server) + public void ReturnBrokenConnection(Server server) { if (server == null) return; diff --git a/DepotDownloader/ContentDownloader.cs b/DepotDownloader/ContentDownloader.cs index c9b2d358..4eff4301 100644 --- a/DepotDownloader/ContentDownloader.cs +++ b/DepotDownloader/ContentDownloader.cs @@ -4,10 +4,10 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; -using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using SteamKit2; +using SteamKit2.CDN; namespace DepotDownloader { @@ -831,15 +831,15 @@ namespace DepotDownloader { cts.Token.ThrowIfCancellationRequested(); - CDNClient.Server connection = null; + Server connection = null; try { connection = cdnPool.GetConnection(cts.Token); DebugLog.WriteLine("ContentDownloader", "Downloading manifest {0} from {1} with {2}", depot.manifestId, connection, cdnPool.ProxyServer != null ? cdnPool.ProxyServer : "no proxy"); - depotManifest = await cdnPool.CDNClient.DownloadManifestAsync(depot.id, depot.manifestId, - connection, null, depot.depotKey, proxyServer: cdnPool.ProxyServer).ConfigureAwait(false); + depotManifest = await cdnPool.CDNClient.DownloadManifestAsync(depot.id, depot.manifestId, manifestRequestCode: 0, + connection, depot.depotKey, cdnPool.ProxyServer).ConfigureAwait(false); cdnPool.ReturnConnection(connection); } @@ -1223,13 +1223,13 @@ namespace DepotDownloader data.CompressedLength = chunk.CompressedLength; data.UncompressedLength = chunk.UncompressedLength; - CDNClient.DepotChunk chunkData = null; + DepotChunk chunkData = null; do { cts.Token.ThrowIfCancellationRequested(); - CDNClient.Server connection = null; + Server connection = null; try { @@ -1237,7 +1237,7 @@ namespace DepotDownloader DebugLog.WriteLine("ContentDownloader", "Downloading chunk {0} from {1} with {2}", chunkID, connection, cdnPool.ProxyServer != null ? cdnPool.ProxyServer : "no proxy"); chunkData = await cdnPool.CDNClient.DownloadDepotChunkAsync(depot.id, data, - connection, null, depot.depotKey, proxyServer: cdnPool.ProxyServer).ConfigureAwait(false); + connection, depot.depotKey, cdnPool.ProxyServer).ConfigureAwait(false); cdnPool.ReturnConnection(connection); } From e915870db70dd43cc422a773a1868dc816846e20 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Wed, 17 Nov 2021 15:20:39 +0200 Subject: [PATCH 3/6] Use SteamContent.GetServersForSteamPipe --- DepotDownloader/CDNClientPool.cs | 30 ++++++++---------------------- DepotDownloader/Steam3Session.cs | 4 +++- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/DepotDownloader/CDNClientPool.cs b/DepotDownloader/CDNClientPool.cs index b0b8731b..aab33c9e 100644 --- a/DepotDownloader/CDNClientPool.cs +++ b/DepotDownloader/CDNClientPool.cs @@ -2,10 +2,8 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; -using System.Net; using System.Threading; using System.Threading.Tasks; -using SteamKit2; using SteamKit2.CDN; namespace DepotDownloader @@ -53,30 +51,18 @@ namespace DepotDownloader private async Task> FetchBootstrapServerListAsync() { - var backoffDelay = 0; - - while (!shutdownToken.IsCancellationRequested) + try { - try + var cdnServers = await this.steamSession.steamContent.GetServersForSteamPipe(); + if (cdnServers != null) { - var cdnServers = await ContentServerDirectoryService.LoadAsync(this.steamSession.steamClient.Configuration, ContentDownloader.Config.CellID, shutdownToken.Token); - if (cdnServers != null) - { - return cdnServers; - } - } - catch (Exception ex) - { - Console.WriteLine("Failed to retrieve content server list: {0}", ex.Message); - - if (ex is SteamKitWebRequestException e && e.StatusCode == (HttpStatusCode)429) - { - // If we're being throttled, add a delay to the next request - backoffDelay = Math.Min(5, ++backoffDelay); - await Task.Delay(TimeSpan.FromSeconds(backoffDelay)); - } + return cdnServers; } } + catch (Exception ex) + { + Console.WriteLine("Failed to retrieve content server list: {0}", ex.Message); + } return null; } diff --git a/DepotDownloader/Steam3Session.cs b/DepotDownloader/Steam3Session.cs index d669dc76..c2c24dcf 100644 --- a/DepotDownloader/Steam3Session.cs +++ b/DepotDownloader/Steam3Session.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -40,6 +40,7 @@ namespace DepotDownloader public SteamClient steamClient; public SteamUser steamUser; + public SteamContent steamContent; readonly SteamApps steamApps; readonly SteamCloud steamCloud; readonly SteamUnifiedMessages.UnifiedService steamPublishedFile; @@ -101,6 +102,7 @@ namespace DepotDownloader this.steamCloud = this.steamClient.GetHandler(); var steamUnifiedMessages = this.steamClient.GetHandler(); this.steamPublishedFile = steamUnifiedMessages.CreateService(); + this.steamContent = this.steamClient.GetHandler(); this.callbacks = new CallbackManager(this.steamClient); From 4e81487aee798cb833042b3ffd4613199c97a404 Mon Sep 17 00:00:00 2001 From: Yaakov Date: Sat, 4 Dec 2021 23:55:19 +1100 Subject: [PATCH 4/6] Update to SK2.4.0 / net6.0 --- DepotDownloader/DepotDownloader.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DepotDownloader/DepotDownloader.csproj b/DepotDownloader/DepotDownloader.csproj index a0713f34..8469c43a 100644 --- a/DepotDownloader/DepotDownloader.csproj +++ b/DepotDownloader/DepotDownloader.csproj @@ -1,7 +1,7 @@  Exe - net5.0 + net6.0 true 2.4.5 @@ -12,6 +12,6 @@ - + From 60ff69d6e9e3a4e3ad7a566d8742a27949816470 Mon Sep 17 00:00:00 2001 From: Yaakov Date: Sun, 5 Dec 2021 00:00:59 +1100 Subject: [PATCH 5/6] Update README for net6.0 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b1a7a7a2..7a56fba0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ DepotDownloader =============== -Steam depot downloader utilizing the SteamKit2 library. Supports .NET 5.0 +Steam depot downloader utilizing the SteamKit2 library. Supports .NET 6.0 ### Downloading one or all depots for an app ``` From 7dc4ec999e1cb94b1fe0ee314c815275bd9a44dc Mon Sep 17 00:00:00 2001 From: Yaakov Date: Sun, 5 Dec 2021 00:02:57 +1100 Subject: [PATCH 6/6] we actually need to specify an sdk version otherwise this does nothing --- .github/workflows/build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 01afa0b5..5dbc0a5d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,10 +24,15 @@ jobs: configuration: [Release, Debug] steps: - uses: actions/checkout@v2 + - name: Setup .NET Core uses: actions/setup-dotnet@v1 + with: + dotnet-version: '6.0.x' + - name: Build run: dotnet publish -c ${{ matrix.configuration }} -o artifacts + - name: Upload artifact uses: actions/upload-artifact@v2 if: matrix.configuration == 'Release'