Use new ContentServerDirectoryService to fetch content servers for CDNClientPool

pull/64/head
Ryan Kistner 7 years ago
parent 87a238b0ec
commit c6975323d2

@ -46,15 +46,13 @@ namespace DepotDownloader
shutdownToken.Cancel(); shutdownToken.Cancel();
} }
private async Task<IList<CDNClient.Server>> FetchBootstrapServerListAsync() private async Task<IReadOnlyCollection<CDNClient.Server>> FetchBootstrapServerListAsync()
{ {
CDNClient bootstrap = new CDNClient(steamSession.steamClient);
while (!shutdownToken.IsCancellationRequested) while (!shutdownToken.IsCancellationRequested)
{ {
try try
{ {
var cdnServers = await bootstrap.FetchServerListAsync(cellId: (uint)ContentDownloader.Config.CellID).ConfigureAwait(false); var cdnServers = await ContentServerDirectoryService.LoadAsync(this.steamSession.steamClient.Configuration, ContentDownloader.Config.CellID, shutdownToken.Token);
if (cdnServers != null) if (cdnServers != null)
{ {
return cdnServers; return cdnServers;
@ -73,14 +71,13 @@ namespace DepotDownloader
{ {
bool didPopulate = false; bool didPopulate = false;
while(!shutdownToken.IsCancellationRequested) while (!shutdownToken.IsCancellationRequested)
{ {
populatePoolEvent.WaitOne(TimeSpan.FromSeconds(1)); populatePoolEvent.WaitOne(TimeSpan.FromSeconds(1));
// peek ahead into steam session to see if we have servers // We want the Steam session so we can take the CellID from the session and pass it through to the ContentServer Directory Service
if (availableServerEndpoints.Count < ServerEndpointMinimumSize && if (availableServerEndpoints.Count < ServerEndpointMinimumSize &&
steamSession.steamClient.IsConnected && steamSession.steamClient.IsConnected)
steamSession.steamClient.GetServersOfType(EServerType.CS).Count > 0)
{ {
var servers = await FetchBootstrapServerListAsync().ConfigureAwait(false); var servers = await FetchBootstrapServerListAsync().ConfigureAwait(false);
@ -150,7 +147,7 @@ namespace DepotDownloader
try try
{ {
if (server.Type == "CDN") if (server.Type == "CDN" || server.Type == "SteamCache")
{ {
steamSession.RequestCDNAuthToken(appId, depotId, server.Host); steamSession.RequestCDNAuthToken(appId, depotId, server.Host);
@ -190,13 +187,13 @@ namespace DepotDownloader
private async Task<bool> ReauthConnectionAsync(CDNClient client, CDNClient.Server server, uint appId, uint depotId, byte[] depotKey) private async Task<bool> ReauthConnectionAsync(CDNClient client, CDNClient.Server server, uint appId, uint depotId, byte[] depotKey)
{ {
DebugLog.Assert(server.Type == "CDN" || steamSession.AppTickets[depotId] == null, "CDNClientPool", "Re-authing a CDN or anonymous connection"); DebugLog.Assert(server.Type == "CDN" || server.Type == "SteamCache" || steamSession.AppTickets[depotId] == null, "CDNClientPool", "Re-authing a CDN or anonymous connection");
String cdnAuthToken = null; String cdnAuthToken = null;
try try
{ {
if (server.Type == "CDN") if (server.Type == "CDN" || server.Type == "SteamCache")
{ {
steamSession.RequestCDNAuthToken(appId, depotId, server.Host); steamSession.RequestCDNAuthToken(appId, depotId, server.Host);
@ -242,7 +239,7 @@ namespace DepotDownloader
// if we couldn't find the authorization data or it's not authed to this depotid, re-initialize // if we couldn't find the authorization data or it's not authed to this depotid, re-initialize
if (!activeClientAuthed.TryGetValue(client, out authData) || authData.Item1 != depotId) if (!activeClientAuthed.TryGetValue(client, out authData) || authData.Item1 != depotId)
{ {
if (authData.Item2.Type == "CDN" && await ReauthConnectionAsync(client, authData.Item2, appId, depotId, depotKey).ConfigureAwait(false)) if ((authData.Item2.Type == "CDN" || authData.Item2.Type == "SteamCache") && await ReauthConnectionAsync(client, authData.Item2, appId, depotId, depotKey).ConfigureAwait(false))
{ {
Console.WriteLine("Re-authed CDN connection to content server {0} from {1} to {2}", authData.Item2, authData.Item1, depotId); Console.WriteLine("Re-authed CDN connection to content server {0} from {1} to {2}", authData.Item2, authData.Item1, depotId);
} }

Loading…
Cancel
Save