From e9a5abecb74b2bf88fbcd96a2189516c676c70fe Mon Sep 17 00:00:00 2001 From: Tim Pilius Date: Fri, 8 Nov 2024 16:13:48 -0500 Subject: [PATCH 1/2] Adding support for Lancache with a new optional flag. --- DepotDownloader/DepotDownloader.csproj | 2 +- DepotDownloader/Program.cs | 14 ++++++++++++++ README.md | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/DepotDownloader/DepotDownloader.csproj b/DepotDownloader/DepotDownloader.csproj index 4a7508b3..6f5e398a 100644 --- a/DepotDownloader/DepotDownloader.csproj +++ b/DepotDownloader/DepotDownloader.csproj @@ -27,6 +27,6 @@ - + diff --git a/DepotDownloader/Program.cs b/DepotDownloader/Program.cs index ea65385b..da9a8387 100644 --- a/DepotDownloader/Program.cs +++ b/DepotDownloader/Program.cs @@ -11,6 +11,7 @@ using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Threading.Tasks; using SteamKit2; +using SteamKit2.CDN; namespace DepotDownloader { @@ -118,6 +119,18 @@ namespace DepotDownloader ContentDownloader.Config.VerifyAll = HasParameter(args, "-verify-all") || HasParameter(args, "-verify_all") || HasParameter(args, "-validate"); ContentDownloader.Config.MaxServers = GetParameter(args, "-max-servers", 20); + + if (HasParameter(args, "-use-lancache")) + { + await Client.DetectLancacheServerAsync(); + // Increasing the number of concurrent downloads when the cache is detected since the downloads will likely + // be served much faster than over the internet. Steam internally has this behavior as well. + if (!HasParameter(args, "-max-downloads")) + { + ContentDownloader.Config.MaxDownloads = 25; + } + } + ContentDownloader.Config.MaxDownloads = GetParameter(args, "-max-downloads", 8); ContentDownloader.Config.MaxServers = Math.Max(ContentDownloader.Config.MaxServers, ContentDownloader.Config.MaxDownloads); ContentDownloader.Config.LoginID = HasParameter(args, "-loginid") ? GetParameter(args, "-loginid") : null; @@ -435,6 +448,7 @@ namespace DepotDownloader Console.WriteLine(" -max-servers <#> - maximum number of content servers to use. (default: 20)."); Console.WriteLine(" -max-downloads <#> - maximum number of chunks to download concurrently. (default: 8)."); Console.WriteLine(" -loginid <#> - a unique 32-bit integer Steam LogonID in decimal, required if running multiple instances of DepotDownloader concurrently."); + Console.WriteLine(" -use-lancache - forces downloads over the local network via a Lancache instance."); } static void PrintVersion(bool printExtra = false) diff --git a/README.md b/README.md index 12f45512..c3378b72 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ Parameter | Description `-max-servers <#>` | maximum number of content servers to use. (default: 20). `-max-downloads <#>` | maximum number of chunks to download concurrently. (default: 8). `-loginid <#>` | a unique 32-bit integer Steam LogonID in decimal, required if running multiple instances of DepotDownloader concurrently. +`-use-lancache` | forces downloads over the local network via a Lancache instance `-V` or `--version` | print version and runtime ## Frequently Asked Questions From f567a63d84408bf0f6f51100f2bcd7523b56eb29 Mon Sep 17 00:00:00 2001 From: Tim Pilius Date: Fri, 3 Jan 2025 13:28:42 -0500 Subject: [PATCH 2/2] Adding log message for when the lancache has been detected. --- DepotDownloader/Program.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/DepotDownloader/Program.cs b/DepotDownloader/Program.cs index da9a8387..98fb50d6 100644 --- a/DepotDownloader/Program.cs +++ b/DepotDownloader/Program.cs @@ -123,11 +123,16 @@ namespace DepotDownloader if (HasParameter(args, "-use-lancache")) { await Client.DetectLancacheServerAsync(); - // Increasing the number of concurrent downloads when the cache is detected since the downloads will likely - // be served much faster than over the internet. Steam internally has this behavior as well. - if (!HasParameter(args, "-max-downloads")) + if (Client.UseLancacheServer) { - ContentDownloader.Config.MaxDownloads = 25; + Console.WriteLine("Detected Lancache server! Downloads will be directed through the Lancache."); + + // Increasing the number of concurrent downloads when the cache is detected since the downloads will likely + // be served much faster than over the internet. Steam internally has this behavior as well. + if (!HasParameter(args, "-max-downloads")) + { + ContentDownloader.Config.MaxDownloads = 25; + } } }