Initial support for Steam3 HTTP CDN. Incomplete.

pull/8/head
azuisleet 14 years ago
parent d18e9c465e
commit 32b2e6b754

@ -123,6 +123,35 @@ namespace DepotDownloader
return false; return false;
} }
static bool DepotHasSteam3Manifest( int depotId, out string manifest_id )
{
if (steam3 == null || steam3.AppInfo == null)
{
manifest_id = null;
return false;
}
foreach (var app in steam3.AppInfo)
{
KeyValue depots;
if (app.AppID == depotId && app.Sections.TryGetValue((int)EAppInfoSection.AppInfoSectionDepots, out depots))
{
string key = depotId.ToString();
var node = depots.Children.Where(a => a.Name == key).First().Children
.Where(b => b.Name == key).First().Children
.Where(c => c.Name == "manifests").First().Children
.Where(d => d.Name == "Public").First();
manifest_id = node.AsString(null);
return true;
}
}
manifest_id = null;
return false;
}
public static void Download( int depotId, int depotVersion, int cellId, string username, string password, bool onlyManifest, bool gameServer, bool exclude, string installDir, string[] fileList ) public static void Download( int depotId, int depotVersion, int cellId, string username, string password, bool onlyManifest, bool gameServer, bool exclude, string installDir, string[] fileList )
{ {
if ( !CreateDirectories( depotId, depotVersion, ref installDir ) ) if ( !CreateDirectories( depotId, depotVersion, ref installDir ) )
@ -131,37 +160,81 @@ namespace DepotDownloader
return; return;
} }
Console.Write( "Finding content servers..." ); ContentServerClient.Credentials credentials = null;
IPEndPoint contentServer = GetStorageServer( depotId, depotVersion, cellId );
if (username != null)
{
// ServerCache.BuildAuthServers( username );
credentials = GetCredentials((uint)depotId, username, password);
}
if ( contentServer == null ) if (!AccountHasAccess(depotId))
{ {
Console.WriteLine( "\nError: Unable to find any content servers for depot {0}, version {1}", depotId, depotVersion ); string contentName = CDRManager.GetDepotName(depotId);
Console.WriteLine("Depot {0} ({1}) is not available from this account.", depotId, contentName);
if (steam3 != null)
steam3.Disconnect();
return; return;
} }
Console.WriteLine( " Done!" ); string steam3_manifest = null;
if ( DepotHasSteam3Manifest( depotId, out steam3_manifest ) )
{
DownloadSteam3( credentials, depotId, depotVersion, cellId );
}
else
{
DownloadSteam2( credentials, depotId, depotVersion, cellId, username, password, onlyManifest, gameServer, exclude, installDir, fileList );
}
if ( steam3 != null )
steam3.Disconnect();
}
ContentServerClient.Credentials credentials = null; private static void DownloadSteam3( ContentServerClient.Credentials credentials, int depotId, int depotVersion, int cellId )
{
Console.Write("Finding content servers...");
/* IPEndPoint contentServer = GetAnyStorageServer();
if ( username != null ) if (contentServer == null)
{ {
credentials = GetCredentials( ( uint )depotId, username, password ); Console.WriteLine("\nError: Unable to find any content servers");
return;
} }
*/
// find a proper bootstrap...
IPEndPoint contentServer1 = new IPEndPoint(IPAddress.Parse("4.28.20.42"), 80);
List<IPEndPoint> cdnServers = CDNClient.FetchServerList(contentServer1, cellId);
Console.WriteLine(" Done!");
if ( !AccountHasAccess( depotId ) ) CDNClient cdnClient = new CDNClient(cdnServers[0], credentials.AppTicket);
if (!cdnClient.Connect())
{ {
string contentName = CDRManager.GetDepotName( depotId ); Console.WriteLine("\nCould not initialize connection with CDN.");
Console.WriteLine( "Depot {0} ({1}) is not available from this account.", depotId, contentName ); return;
}
}
if ( steam3 != null ) private static void DownloadSteam2( ContentServerClient.Credentials credentials, int depotId, int depotVersion, int cellId, string username, string password, bool onlyManifest, bool gameServer, bool exclude, string installDir, string[] fileList )
steam3.Disconnect(); {
Console.Write("Finding content servers...");
IPEndPoint contentServer = GetStorageServer(depotId, depotVersion, cellId);
if (contentServer == null)
{
Console.WriteLine("\nError: Unable to find any content servers for depot {0}, version {1}", depotId, depotVersion);
return; return;
} }
string manifestFile = Path.Combine( installDir, "manifest.bin" ); Console.WriteLine(" Done!");
string txtManifest = Path.Combine( installDir, "manifest.txt" );
string manifestFile = Path.Combine(installDir, "manifest.bin");
string txtManifest = Path.Combine(installDir, "manifest.txt");
ContentServerClient csClient = new ContentServerClient(); ContentServerClient csClient = new ContentServerClient();
@ -313,9 +386,6 @@ namespace DepotDownloader
csClient.Disconnect(); csClient.Disconnect();
if ( steam3 != null )
steam3.Disconnect();
} }
static ContentServerClient.Credentials GetCredentials( uint depotId, string username, string password ) static ContentServerClient.Credentials GetCredentials( uint depotId, string username, string password )
@ -374,6 +444,31 @@ namespace DepotDownloader
return null; return null;
} }
static IPEndPoint GetAnyStorageServer()
{
foreach (IPEndPoint csdServer in ServerCache.CSDSServers)
{
ContentServerDSClient csdsClient = new ContentServerDSClient();
csdsClient.Connect(csdServer);
IPEndPoint[] servers = csdsClient.GetContentServerList();
if (servers == null)
{
Console.WriteLine("Warning: CSDS {0} returned empty server list.", csdServer);
continue;
}
if (servers.Length == 0)
continue;
return servers[PsuedoRandom.GetRandomInt(0, servers.Length - 1)];
}
return null;
}
static IPEndPoint GetAuthServer() static IPEndPoint GetAuthServer()
{ {
if ( ServerCache.AuthServers.Count > 0 ) if ( ServerCache.AuthServers.Count > 0 )

@ -41,6 +41,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@ -50,6 +51,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />

@ -27,6 +27,8 @@ namespace DepotDownloader
private set; private set;
} }
public ReadOnlyCollection<SteamApps.AppInfoCallback.AppInfo> AppInfo { get; private set; }
SteamClient steamClient; SteamClient steamClient;
SteamUser steamUser; SteamUser steamUser;
@ -99,7 +101,7 @@ namespace DepotDownloader
if ( diff > STEAM3_TIMEOUT && !bConnected ) if ( diff > STEAM3_TIMEOUT && !bConnected )
break; break;
if ( credentials.HasSessionToken && credentials.AppTicket != null && Licenses != null && credentials.Steam2Ticket != null ) if ( credentials.HasSessionToken && credentials.AppTicket != null && Licenses != null && credentials.Steam2Ticket != null && AppInfo != null )
break; break;
if ( callback == null ) if ( callback == null )
@ -141,6 +143,7 @@ namespace DepotDownloader
Console.WriteLine( "Got Steam2 Ticket!" ); Console.WriteLine( "Got Steam2 Ticket!" );
credentials.Steam2Ticket = msg.Steam2Ticket; credentials.Steam2Ticket = msg.Steam2Ticket;
steamApps.GetAppInfo( depotId );
steamApps.GetAppOwnershipTicket( depotId ); steamApps.GetAppOwnershipTicket( depotId );
} }
@ -186,6 +189,21 @@ namespace DepotDownloader
Console.WriteLine( "Got {0} licenses for account!", msg.LicenseList.Count ); Console.WriteLine( "Got {0} licenses for account!", msg.LicenseList.Count );
Licenses = msg.LicenseList; Licenses = msg.LicenseList;
} }
if ( callback.IsType<SteamApps.AppInfoCallback>() )
{
var msg = callback as SteamApps.AppInfoCallback;
if (msg.AppsPending > 0 || msg.Apps.Count == 0 || msg.Apps[0].Status == SteamApps.AppInfoCallback.AppInfo.AppInfoStatus.Unknown)
{
Console.WriteLine("AppInfo did not contain the requested app id {0}", depotId);
steamUser.LogOff();
break;
}
Console.WriteLine("Got AppInfo for {0}", msg.Apps[0].AppID);
AppInfo = msg.Apps;
}
} }
credentialHandle.Set(); credentialHandle.Set();

Loading…
Cancel
Save