From 06d25ef1ed4a5202125515e2d74c55453e73d6be Mon Sep 17 00:00:00 2001 From: Ryan Kistner Date: Wed, 9 Jun 2021 17:44:39 -0600 Subject: [PATCH] 2.4.2: Added HTTP diagnostics to -debug --- DepotDownloader/ContentDownloader.cs | 6 +++ .../HttpDiagnosticEventListener.cs | 42 +++++++++++++++++++ DepotDownloader/Program.cs | 3 +- DepotDownloader/Properties/AssemblyInfo.cs | 2 +- 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 DepotDownloader/HttpDiagnosticEventListener.cs diff --git a/DepotDownloader/ContentDownloader.cs b/DepotDownloader/ContentDownloader.cs index 1d1a8436..74c76460 100644 --- a/DepotDownloader/ContentDownloader.cs +++ b/DepotDownloader/ContentDownloader.cs @@ -840,8 +840,11 @@ namespace DepotDownloader try { connection = cdnPool.GetConnection(cts.Token); + + DebugLog.WriteLine("ContentDownloader", "Authenticating connection to {0}", connection); var cdnToken = await cdnPool.AuthenticateConnection(appId, depot.id, connection); + 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, cdnToken, depot.depotKey, proxyServer: cdnPool.ProxyServer).ConfigureAwait(false); @@ -1215,8 +1218,11 @@ namespace DepotDownloader try { connection = cdnPool.GetConnection(cts.Token); + + DebugLog.WriteLine("ContentDownloader", "Authenticating connection to {0}", connection); var cdnToken = await cdnPool.AuthenticateConnection(appId, depot.id, connection); + 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, cdnToken, depot.depotKey, proxyServer: cdnPool.ProxyServer).ConfigureAwait(false); diff --git a/DepotDownloader/HttpDiagnosticEventListener.cs b/DepotDownloader/HttpDiagnosticEventListener.cs new file mode 100644 index 00000000..eb883b05 --- /dev/null +++ b/DepotDownloader/HttpDiagnosticEventListener.cs @@ -0,0 +1,42 @@ +using System; +using System.Diagnostics.Tracing; +using System.Text; + +namespace DepotDownloader +{ + internal sealed class HttpDiagnosticEventListener : EventListener + { + public const EventKeywords TasksFlowActivityIds = (EventKeywords)0x80; + + protected override void OnEventSourceCreated(EventSource eventSource) + { + if (eventSource.Name == "System.Net.Http" || + eventSource.Name == "System.Net.Sockets" || + eventSource.Name == "System.Net.Security" || + eventSource.Name == "System.Net.NameResolution") + { + EnableEvents(eventSource, EventLevel.LogAlways); + } + else if (eventSource.Name == "System.Threading.Tasks.TplEventSource") + { + EnableEvents(eventSource, EventLevel.LogAlways, TasksFlowActivityIds); + } + } + + protected override void OnEventWritten(EventWrittenEventArgs eventData) + { + var sb = new StringBuilder().Append($"{eventData.TimeStamp:HH:mm:ss.fffffff} {eventData.EventSource.Name}.{eventData.EventName}("); + for (int i = 0; i < eventData.Payload?.Count; i++) + { + sb.Append(eventData.PayloadNames?[i]).Append(": ").Append(eventData.Payload[i]); + if (i < eventData.Payload?.Count - 1) + { + sb.Append(", "); + } + } + + sb.Append(")"); + Console.WriteLine(sb.ToString()); + } + } +} diff --git a/DepotDownloader/Program.cs b/DepotDownloader/Program.cs index cf7b0f33..aa3944e3 100644 --- a/DepotDownloader/Program.cs +++ b/DepotDownloader/Program.cs @@ -5,7 +5,6 @@ using System.Text.RegularExpressions; using SteamKit2; using System.ComponentModel; using System.Threading.Tasks; -using System.Runtime.InteropServices; using System.Linq; namespace DepotDownloader @@ -36,6 +35,8 @@ namespace DepotDownloader { Console.WriteLine( "[{0}] {1}", category, message ); }); + + var httpEventListener = new HttpDiagnosticEventListener(); } string username = GetParameter( args, "-username" ) ?? GetParameter( args, "-user" ); diff --git a/DepotDownloader/Properties/AssemblyInfo.cs b/DepotDownloader/Properties/AssemblyInfo.cs index 398d4151..987e75ec 100644 --- a/DepotDownloader/Properties/AssemblyInfo.cs +++ b/DepotDownloader/Properties/AssemblyInfo.cs @@ -31,4 +31,4 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.4.1.0")] +[assembly: AssemblyVersion("2.4.2.0")]