mirror of
https://github.com/SteamAutoCracks/DepotDownloaderMod.git
synced 2026-02-10 20:00:55 +01:00
Initial support for Steam3 HTTP CDN. Incomplete.
This commit is contained in:
@@ -123,6 +123,35 @@ namespace DepotDownloader
|
||||
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 )
|
||||
{
|
||||
if ( !CreateDirectories( depotId, depotVersion, ref installDir ) )
|
||||
@@ -131,37 +160,81 @@ namespace DepotDownloader
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Console.WriteLine( " Done!" );
|
||||
|
||||
ContentServerClient.Credentials credentials = null;
|
||||
|
||||
if ( username != null )
|
||||
if (username != null)
|
||||
{
|
||||
credentials = GetCredentials( ( uint )depotId, username, password );
|
||||
// ServerCache.BuildAuthServers( username );
|
||||
credentials = GetCredentials((uint)depotId, username, password);
|
||||
}
|
||||
|
||||
if ( !AccountHasAccess( depotId ) )
|
||||
if (!AccountHasAccess(depotId))
|
||||
{
|
||||
string contentName = CDRManager.GetDepotName( depotId );
|
||||
Console.WriteLine( "Depot {0} ({1}) is not available from this account.", depotId, contentName );
|
||||
string contentName = CDRManager.GetDepotName(depotId);
|
||||
Console.WriteLine("Depot {0} ({1}) is not available from this account.", depotId, contentName);
|
||||
|
||||
if ( steam3 != null )
|
||||
if (steam3 != null)
|
||||
steam3.Disconnect();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
string manifestFile = Path.Combine( installDir, "manifest.bin" );
|
||||
string txtManifest = Path.Combine( installDir, "manifest.txt" );
|
||||
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();
|
||||
}
|
||||
|
||||
private static void DownloadSteam3( ContentServerClient.Credentials credentials, int depotId, int depotVersion, int cellId )
|
||||
{
|
||||
Console.Write("Finding content servers...");
|
||||
/* IPEndPoint contentServer = GetAnyStorageServer();
|
||||
|
||||
if (contentServer == null)
|
||||
{
|
||||
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!");
|
||||
|
||||
CDNClient cdnClient = new CDNClient(cdnServers[0], credentials.AppTicket);
|
||||
|
||||
if (!cdnClient.Connect())
|
||||
{
|
||||
Console.WriteLine("\nCould not initialize connection with CDN.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
Console.WriteLine(" Done!");
|
||||
|
||||
string manifestFile = Path.Combine(installDir, "manifest.bin");
|
||||
string txtManifest = Path.Combine(installDir, "manifest.txt");
|
||||
|
||||
ContentServerClient csClient = new ContentServerClient();
|
||||
|
||||
@@ -313,9 +386,6 @@ namespace DepotDownloader
|
||||
|
||||
csClient.Disconnect();
|
||||
|
||||
if ( steam3 != null )
|
||||
steam3.Disconnect();
|
||||
|
||||
}
|
||||
|
||||
static ContentServerClient.Credentials GetCredentials( uint depotId, string username, string password )
|
||||
@@ -374,6 +444,31 @@ namespace DepotDownloader
|
||||
|
||||
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()
|
||||
{
|
||||
if ( ServerCache.AuthServers.Count > 0 )
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@@ -50,6 +51,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace DepotDownloader
|
||||
private set;
|
||||
}
|
||||
|
||||
public ReadOnlyCollection<SteamApps.AppInfoCallback.AppInfo> AppInfo { get; private set; }
|
||||
|
||||
SteamClient steamClient;
|
||||
|
||||
SteamUser steamUser;
|
||||
@@ -99,7 +101,7 @@ namespace DepotDownloader
|
||||
if ( diff > STEAM3_TIMEOUT && !bConnected )
|
||||
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;
|
||||
|
||||
if ( callback == null )
|
||||
@@ -141,6 +143,7 @@ namespace DepotDownloader
|
||||
Console.WriteLine( "Got Steam2 Ticket!" );
|
||||
credentials.Steam2Ticket = msg.Steam2Ticket;
|
||||
|
||||
steamApps.GetAppInfo( depotId );
|
||||
steamApps.GetAppOwnershipTicket( depotId );
|
||||
}
|
||||
|
||||
@@ -186,6 +189,21 @@ namespace DepotDownloader
|
||||
Console.WriteLine( "Got {0} licenses for account!", msg.LicenseList.Count );
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user