diff --git a/DepotDownloader/CDNClientPool.cs b/DepotDownloader/CDNClientPool.cs index 654d3f54..941e8c1c 100644 --- a/DepotDownloader/CDNClientPool.cs +++ b/DepotDownloader/CDNClientPool.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Net; using System.Threading; using System.Threading.Tasks; +using System.Text.RegularExpressions; namespace DepotDownloader { @@ -28,6 +29,8 @@ namespace DepotDownloader private readonly CancellationTokenSource shutdownToken; public CancellationTokenSource ExhaustedToken { get; set; } + public static Regex blacklistCDN = new Regex("$^"); // default: a regex that matches nothing. + public CDNClientPool(Steam3Session steamSession) { this.steamSession = steamSession; @@ -97,7 +100,7 @@ namespace DepotDownloader return; } - var weightedCdnServers = servers.Where(x => x.Type == "SteamCache" || x.Type == "CDN").Select(x => + var weightedCdnServers = servers.Where(x => blacklistCDN.Matches(x.Host).Count == 0).Where(x => x.Type == "SteamCache" || x.Type == "CDN").Select(x => { AccountSettingsStore.Instance.ContentServerPenalty.TryGetValue(x.Host, out var penalty); diff --git a/DepotDownloader/Program.cs b/DepotDownloader/Program.cs index b3b9b737..5994197f 100644 --- a/DepotDownloader/Program.cs +++ b/DepotDownloader/Program.cs @@ -36,6 +36,17 @@ namespace DepotDownloader }); } + try + { + string regex = GetParameter( args, "-blacklist-cdn", "$^" ); + CDNClientPool.blacklistCDN = new Regex(regex, RegexOptions.Compiled | RegexOptions.IgnoreCase); + } + catch + { + Console.WriteLine( "Error: Invalid regex supplied for -blacklist-cdn" ); + return 1; + } + string username = GetParameter( args, "-username" ) ?? GetParameter( args, "-user" ); string password = GetParameter( args, "-password" ) ?? GetParameter( args, "-pass" ); ContentDownloader.Config.RememberPassword = HasParameter( args, "-remember-password" );