Skip to content

Commit

Permalink
2.4.2: Added HTTP diagnostics to -debug
Browse files Browse the repository at this point in the history
  • Loading branch information
azuisleet committed Jun 9, 2021
1 parent 4b0cbb0 commit 06d25ef
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
6 changes: 6 additions & 0 deletions DepotDownloader/ContentDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,11 @@ private static async Task<DepotFilesData> ProcessDepotManifestAndFiles(Cancellat
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);

Expand Down Expand Up @@ -1215,8 +1218,11 @@ private static async Task DownloadSteam3AsyncDepotFileChunk(
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);

Expand Down
42 changes: 42 additions & 0 deletions DepotDownloader/HttpDiagnosticEventListener.cs
Original file line number Diff line number Diff line change
@@ -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());
}
}
}
3 changes: 2 additions & 1 deletion DepotDownloader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using SteamKit2;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Linq;

namespace DepotDownloader
Expand Down Expand Up @@ -36,6 +35,8 @@ static async Task<int> MainAsync( string[] args )
{
Console.WriteLine( "[{0}] {1}", category, message );
});

var httpEventListener = new HttpDiagnosticEventListener();
}

string username = GetParameter<string>( args, "-username" ) ?? GetParameter<string>( args, "-user" );
Expand Down
2 changes: 1 addition & 1 deletion DepotDownloader/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
// 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")]

0 comments on commit 06d25ef

Please sign in to comment.