|
|
|
@ -16,31 +16,35 @@ namespace DepotDownloader
|
|
|
|
|
const string DEFAULT_DIR = "depots";
|
|
|
|
|
const int MAX_STORAGE_RETRIES = 500;
|
|
|
|
|
|
|
|
|
|
static Steam3Session steam3;
|
|
|
|
|
public static DownloadConfig Config = new DownloadConfig();
|
|
|
|
|
|
|
|
|
|
static bool CreateDirectories( int depotId, int depotVersion, ref string installDir )
|
|
|
|
|
private static Steam3Session steam3;
|
|
|
|
|
private static Steam3Session.Credentials steam3Credentials;
|
|
|
|
|
|
|
|
|
|
static bool CreateDirectories( int depotId, int depotVersion, out string installDir )
|
|
|
|
|
{
|
|
|
|
|
installDir = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if ( installDir == null || installDir == "" )
|
|
|
|
|
if (ContentDownloader.Config.InstallDirectory == null || ContentDownloader.Config.InstallDirectory == "")
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory( DEFAULT_DIR );
|
|
|
|
|
|
|
|
|
|
string depotPath = Path.Combine( DEFAULT_DIR, depotId.ToString() );
|
|
|
|
|
Directory.CreateDirectory( depotPath );
|
|
|
|
|
|
|
|
|
|
installDir = Path.Combine( depotPath, depotVersion.ToString() );
|
|
|
|
|
Directory.CreateDirectory( installDir );
|
|
|
|
|
installDir = Path.Combine(depotPath, depotVersion.ToString());
|
|
|
|
|
Directory.CreateDirectory(installDir);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory( installDir );
|
|
|
|
|
Directory.CreateDirectory(ContentDownloader.Config.InstallDirectory);
|
|
|
|
|
|
|
|
|
|
string serverFolder = CDRManager.GetDedicatedServerFolder( depotId );
|
|
|
|
|
if ( serverFolder != null && serverFolder != "" )
|
|
|
|
|
{
|
|
|
|
|
installDir = Path.Combine( installDir, serverFolder );
|
|
|
|
|
Directory.CreateDirectory( installDir );
|
|
|
|
|
installDir = Path.Combine(ContentDownloader.Config.InstallDirectory, serverFolder);
|
|
|
|
|
Directory.CreateDirectory(installDir);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -109,6 +113,28 @@ namespace DepotDownloader
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool TestIsFileIncluded(string filename)
|
|
|
|
|
{
|
|
|
|
|
if (!Config.UsingFileList)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
foreach (string fileListEntry in Config.FilesToDownload)
|
|
|
|
|
{
|
|
|
|
|
if (fileListEntry.Equals(filename, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (Regex rgx in Config.FilesToDownloadRegex)
|
|
|
|
|
{
|
|
|
|
|
Match m = rgx.Match(filename);
|
|
|
|
|
|
|
|
|
|
if (m.Success)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool AccountHasAccess( int depotId )
|
|
|
|
|
{
|
|
|
|
|
if ( steam3 == null || steam3.Licenses == null )
|
|
|
|
@ -116,6 +142,7 @@ namespace DepotDownloader
|
|
|
|
|
|
|
|
|
|
foreach ( var license in steam3.Licenses )
|
|
|
|
|
{
|
|
|
|
|
// TODO: support PackageInfoRequest/Response, this is a steam2 dependency
|
|
|
|
|
if ( CDRManager.SubHasDepot( ( int )license.PackageID, depotId ) )
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -123,84 +150,223 @@ namespace DepotDownloader
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool DepotHasSteam3Manifest( int depotId, int appId, out ulong manifest_id )
|
|
|
|
|
static bool AppIsSteam3(int appId)
|
|
|
|
|
{
|
|
|
|
|
if (steam3 == null || steam3.AppInfo == null)
|
|
|
|
|
if (steam3 == null || steam3.AppInfoOverridesCDR == null)
|
|
|
|
|
{
|
|
|
|
|
manifest_id = 0;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
string appkey = appId.ToString();
|
|
|
|
|
string depotkey = depotId.ToString();
|
|
|
|
|
|
|
|
|
|
foreach (var app in steam3.AppInfo)
|
|
|
|
|
steam3.RequestAppInfo((uint)appId);
|
|
|
|
|
|
|
|
|
|
bool app_override;
|
|
|
|
|
if(!steam3.AppInfoOverridesCDR.TryGetValue((uint)appId, out app_override))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return app_override;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static KeyValue GetSteam3AppSection(int appId, EAppInfoSection section)
|
|
|
|
|
{
|
|
|
|
|
if (steam3 == null || steam3.AppInfo == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SteamApps.AppInfoCallback.AppInfo app;
|
|
|
|
|
if (!steam3.AppInfo.TryGetValue((uint)appId, out app))
|
|
|
|
|
{
|
|
|
|
|
KeyValue depots;
|
|
|
|
|
if (app.AppID == appId && app.Sections.TryGetValue((int)EAppInfoSection.AppInfoSectionDepots, out depots))
|
|
|
|
|
{
|
|
|
|
|
// check depots for app
|
|
|
|
|
foreach (var depotkv in depots[appkey].Children)
|
|
|
|
|
{
|
|
|
|
|
if(depotkv.Name != depotkey)
|
|
|
|
|
continue;
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KeyValue section_kv;
|
|
|
|
|
if (!app.Sections.TryGetValue((int)section, out section_kv))
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var node = depotkv.Children
|
|
|
|
|
.Where(c => c.Name == "manifests").First().Children
|
|
|
|
|
.Where(d => d.Name == "Public").First();
|
|
|
|
|
return section_kv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ulong GetSteam3DepotManifest(int depotId, int appId)
|
|
|
|
|
{
|
|
|
|
|
if (appId == -1 || !AppIsSteam3(appId))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
KeyValue depots = GetSteam3AppSection(appId, EAppInfoSection.AppInfoSectionDepots);
|
|
|
|
|
KeyValue depotChild = depots[appId.ToString()][depotId.ToString()];
|
|
|
|
|
|
|
|
|
|
if (depotChild == null)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
var node = depotChild["manifests"]["Public"];
|
|
|
|
|
|
|
|
|
|
return UInt64.Parse(node.Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static string GetAppOrDepotName(int depotId, int appId)
|
|
|
|
|
{
|
|
|
|
|
if (appId == -1 || !AppIsSteam3(appId))
|
|
|
|
|
{
|
|
|
|
|
return CDRManager.GetDepotName(depotId);
|
|
|
|
|
}
|
|
|
|
|
else if (depotId == -1)
|
|
|
|
|
{
|
|
|
|
|
KeyValue info = GetSteam3AppSection(appId, EAppInfoSection.AppInfoSectionCommon);
|
|
|
|
|
|
|
|
|
|
if (info == null)
|
|
|
|
|
return String.Empty;
|
|
|
|
|
|
|
|
|
|
return info[appId.ToString()]["name"].AsString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
KeyValue depots = GetSteam3AppSection(appId, EAppInfoSection.AppInfoSectionDepots);
|
|
|
|
|
|
|
|
|
|
if (depots == null)
|
|
|
|
|
return String.Empty;
|
|
|
|
|
|
|
|
|
|
KeyValue depotChild = depots[appId.ToString()][depotId.ToString()];
|
|
|
|
|
|
|
|
|
|
if (depotChild == null)
|
|
|
|
|
return String.Empty;
|
|
|
|
|
|
|
|
|
|
return depotChild["name"].AsString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void InitializeSteam3(string username, string password)
|
|
|
|
|
{
|
|
|
|
|
steam3 = new Steam3Session(
|
|
|
|
|
new SteamUser.LogOnDetails()
|
|
|
|
|
{
|
|
|
|
|
Username = username,
|
|
|
|
|
Password = password,
|
|
|
|
|
|
|
|
|
|
manifest_id = UInt64.Parse(node.Value);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
steam3Credentials = steam3.WaitForCredentials();
|
|
|
|
|
|
|
|
|
|
if (!steam3Credentials.HasSessionToken)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Unable to get steam3 credentials.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
manifest_id = 0;
|
|
|
|
|
return false;
|
|
|
|
|
private static ContentServerClient.Credentials GetSteam2Credentials(uint appId)
|
|
|
|
|
{
|
|
|
|
|
if (steam3 == null || !steam3Credentials.HasSessionToken)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new ContentServerClient.Credentials()
|
|
|
|
|
{
|
|
|
|
|
Steam2Ticket = new Steam2Ticket(steam3Credentials.Steam2Ticket),
|
|
|
|
|
AppTicket = steam3.AppTickets[appId],
|
|
|
|
|
SessionToken = steam3Credentials.SessionToken,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Download( int depotId, int appId, int depotVersion, int cellId, string username, string password, bool onlyManifest, bool gameServer, bool exclude, string installDir, string[] fileList )
|
|
|
|
|
public static void DownloadApp(int appId)
|
|
|
|
|
{
|
|
|
|
|
if ( !CreateDirectories( depotId, depotVersion, ref installDir ) )
|
|
|
|
|
if(steam3 != null)
|
|
|
|
|
steam3.RequestAppInfo((uint)appId);
|
|
|
|
|
|
|
|
|
|
if (!AccountHasAccess(appId))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine( "Error: Unable to create install directories!" );
|
|
|
|
|
string contentName = GetAppOrDepotName(-1, appId);
|
|
|
|
|
Console.WriteLine("App {0} ({1}) is not available from this account.", appId, contentName);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ContentServerClient.Credentials credentials = null;
|
|
|
|
|
List<int> depotIDs = null;
|
|
|
|
|
|
|
|
|
|
if (username != null)
|
|
|
|
|
if (AppIsSteam3(appId))
|
|
|
|
|
{
|
|
|
|
|
// ServerCache.BuildAuthServers( username );
|
|
|
|
|
credentials = GetCredentials((uint)depotId, (uint)appId, username, password);
|
|
|
|
|
depotIDs = new List<int>();
|
|
|
|
|
KeyValue depots = GetSteam3AppSection(appId, EAppInfoSection.AppInfoSectionDepots);
|
|
|
|
|
|
|
|
|
|
if (depots != null)
|
|
|
|
|
{
|
|
|
|
|
depots = depots[appId.ToString()];
|
|
|
|
|
foreach (var child in depots.Children)
|
|
|
|
|
{
|
|
|
|
|
if (child.Children.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
depotIDs.Add(int.Parse(child.Name));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// steam2 path
|
|
|
|
|
depotIDs = CDRManager.GetDepotIDsForApp(appId, Config.DownloadAllPlatforms);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!AccountHasAccess(depotId))
|
|
|
|
|
if (depotIDs == null || depotIDs.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Couldn't find any depots to download for app {0}", appId);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var depot in depotIDs)
|
|
|
|
|
{
|
|
|
|
|
string contentName = CDRManager.GetDepotName(depotId);
|
|
|
|
|
// Steam2 dependency
|
|
|
|
|
int depotVersion = CDRManager.GetLatestDepotVersion(depot, Config.PreferBetaVersions);
|
|
|
|
|
if (depotVersion == -1)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Error: Unable to find DepotID {0} in the CDR!", depot);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DownloadDepot(depot, appId, depotVersion);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void DownloadDepot(int depotId, int appId, int depotVersion)
|
|
|
|
|
{
|
|
|
|
|
if(steam3 != null && appId > 0)
|
|
|
|
|
steam3.RequestAppInfo((uint)appId);
|
|
|
|
|
|
|
|
|
|
string contentName = GetAppOrDepotName(depotId, appId);
|
|
|
|
|
|
|
|
|
|
if (!AccountHasAccess(depotId))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Depot {0} ({1}) is not available from this account.", depotId, contentName);
|
|
|
|
|
|
|
|
|
|
if (steam3 != null)
|
|
|
|
|
steam3.Disconnect();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string installDir;
|
|
|
|
|
if (!CreateDirectories(depotId, depotVersion, out installDir))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Error: Unable to create install directories!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ulong steam3_manifest;
|
|
|
|
|
if ( DepotHasSteam3Manifest( depotId, appId, out steam3_manifest ) )
|
|
|
|
|
Console.WriteLine("Downloading \"{0}\" version {1} ...", contentName, depotVersion);
|
|
|
|
|
|
|
|
|
|
ulong manifestID = GetSteam3DepotManifest(depotId, appId);
|
|
|
|
|
if (manifestID > 0)
|
|
|
|
|
{
|
|
|
|
|
DownloadSteam3( credentials, depotId, depotVersion, cellId, steam3_manifest, installDir );
|
|
|
|
|
DownloadSteam3(depotId, depotVersion, manifestID, installDir);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DownloadSteam2( credentials, depotId, depotVersion, cellId, username, password, onlyManifest, gameServer, exclude, installDir, fileList );
|
|
|
|
|
// steam2 path
|
|
|
|
|
DownloadSteam2(depotId, depotVersion, installDir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( steam3 != null )
|
|
|
|
|
steam3.Disconnect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void DownloadSteam3( ContentServerClient.Credentials credentials, int depotId, int depotVersion, int cellId, ulong depot_manifest, string installDir )
|
|
|
|
|
private static void DownloadSteam3( int depotId, int depotVersion, ulong depot_manifest, string installDir )
|
|
|
|
|
{
|
|
|
|
|
steam3.RequestAppTicket((uint)depotId);
|
|
|
|
|
steam3.RequestDepotKey((uint)depotId);
|
|
|
|
|
|
|
|
|
|
Console.Write("Finding content servers...");
|
|
|
|
|
|
|
|
|
|
List<IPEndPoint> serverList = steam3.steamClient.GetServersOfType(EServerType.ServerTypeCS);
|
|
|
|
@ -209,7 +375,7 @@ namespace DepotDownloader
|
|
|
|
|
|
|
|
|
|
foreach(var endpoint in serverList)
|
|
|
|
|
{
|
|
|
|
|
cdnServers = CDNClient.FetchServerList(new CDNClient.ClientEndPoint(endpoint.Address.ToString(), endpoint.Port), cellId);
|
|
|
|
|
cdnServers = CDNClient.FetchServerList(new CDNClient.ClientEndPoint(endpoint.Address.ToString(), endpoint.Port), Config.CellID);
|
|
|
|
|
|
|
|
|
|
if (cdnServers != null && cdnServers.Count > 0)
|
|
|
|
|
break;
|
|
|
|
@ -217,14 +383,14 @@ namespace DepotDownloader
|
|
|
|
|
|
|
|
|
|
if (cdnServers == null || cdnServers.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Unable to find any steam3 content servers");
|
|
|
|
|
Console.WriteLine("Unable to find any Steam3 content servers");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Console.WriteLine(" Done!");
|
|
|
|
|
Console.Write("Downloading depot manifest...");
|
|
|
|
|
|
|
|
|
|
CDNClient cdnClient = new CDNClient(cdnServers[0], credentials.AppTicket);
|
|
|
|
|
CDNClient cdnClient = new CDNClient(cdnServers[0], steam3.AppTickets[(uint)depotId]);
|
|
|
|
|
|
|
|
|
|
if (!cdnClient.Connect())
|
|
|
|
|
{
|
|
|
|
@ -241,13 +407,11 @@ namespace DepotDownloader
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string manifestFile = Path.Combine(installDir, "manifest.bin");
|
|
|
|
|
string keyFile = Path.Combine(installDir, "depotkey.bin");
|
|
|
|
|
File.WriteAllBytes(manifestFile, manifest);
|
|
|
|
|
File.WriteAllBytes(keyFile, steam3.DepotKey);
|
|
|
|
|
|
|
|
|
|
DepotManifest depotManifest = new DepotManifest(manifest);
|
|
|
|
|
|
|
|
|
|
if (!depotManifest.DecryptFilenames(steam3.DepotKey))
|
|
|
|
|
if (!depotManifest.DecryptFilenames(steam3.DepotKeys[(uint)depotId]))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("\nUnable to decrypt manifest for depot {0}", depotId);
|
|
|
|
|
return;
|
|
|
|
@ -258,6 +422,8 @@ namespace DepotDownloader
|
|
|
|
|
ulong complete_download_size = 0;
|
|
|
|
|
ulong size_downloaded = 0;
|
|
|
|
|
|
|
|
|
|
depotManifest.Files.Sort((x, y) => { return x.FileName.CompareTo(y.FileName); });
|
|
|
|
|
|
|
|
|
|
foreach (var file in depotManifest.Files)
|
|
|
|
|
{
|
|
|
|
|
complete_download_size += file.TotalSize;
|
|
|
|
@ -276,10 +442,7 @@ namespace DepotDownloader
|
|
|
|
|
|
|
|
|
|
string dir_path = Path.GetDirectoryName(download_path);
|
|
|
|
|
|
|
|
|
|
int top = Console.CursorTop;
|
|
|
|
|
Console.WriteLine("00.00% Downloading {0}", download_path);
|
|
|
|
|
int top_post = Console.CursorTop;
|
|
|
|
|
Console.CursorTop = top;
|
|
|
|
|
Console.Write("{0:00.00}% Downloading {1}", ((float)size_downloaded / (float)complete_download_size) * 100.0f, download_path);
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(dir_path))
|
|
|
|
|
Directory.CreateDirectory(dir_path);
|
|
|
|
@ -292,7 +455,7 @@ namespace DepotDownloader
|
|
|
|
|
string chunkID = Utils.BinToHex(chunk.ChunkID);
|
|
|
|
|
|
|
|
|
|
byte[] encrypted_chunk = cdnClient.DownloadDepotChunk(depotId, chunkID);
|
|
|
|
|
byte[] chunk_data = cdnClient.ProcessChunk(encrypted_chunk, steam3.DepotKey);
|
|
|
|
|
byte[] chunk_data = cdnClient.ProcessChunk(encrypted_chunk, steam3.DepotKeys[(uint)depotId]);
|
|
|
|
|
|
|
|
|
|
fs.Seek((long)chunk.Offset, SeekOrigin.Begin);
|
|
|
|
|
fs.Write(chunk_data, 0, chunk_data.Length);
|
|
|
|
@ -303,19 +466,18 @@ namespace DepotDownloader
|
|
|
|
|
Console.Write("{0:00.00}", ((float)size_downloaded / (float)complete_download_size) * 100.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Console.CursorTop = top_post;
|
|
|
|
|
Console.CursorLeft = 0;
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 )
|
|
|
|
|
private static void DownloadSteam2( int depotId, int depotVersion, string installDir )
|
|
|
|
|
{
|
|
|
|
|
Console.Write("Finding content servers...");
|
|
|
|
|
IPEndPoint[] contentServers = GetStorageServer(depotId, depotVersion, cellId);
|
|
|
|
|
IPEndPoint[] contentServers = GetStorageServer(depotId, depotVersion, Config.CellID);
|
|
|
|
|
|
|
|
|
|
if (contentServers.Length == 0)
|
|
|
|
|
if (contentServers == null || contentServers.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("\nError: Unable to find any content servers for depot {0}, version {1}", depotId, depotVersion);
|
|
|
|
|
Console.WriteLine("\nError: Unable to find any Steam2 content servers for depot {0}, version {1}", depotId, depotVersion);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -335,7 +497,7 @@ namespace DepotDownloader
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
csClient.Connect( contentServers[server] );
|
|
|
|
|
session = csClient.OpenStorage( ( uint )depotId, ( uint )depotVersion, ( uint )cellId, credentials );
|
|
|
|
|
session = csClient.OpenStorage( ( uint )depotId, ( uint )depotVersion, ( uint )Config.CellID, GetSteam2Credentials((uint)depotId) );
|
|
|
|
|
}
|
|
|
|
|
catch ( Steam2Exception ex )
|
|
|
|
|
{
|
|
|
|
@ -367,29 +529,12 @@ namespace DepotDownloader
|
|
|
|
|
|
|
|
|
|
Console.WriteLine( " Done!" );
|
|
|
|
|
|
|
|
|
|
if ( onlyManifest )
|
|
|
|
|
File.Delete( txtManifest );
|
|
|
|
|
|
|
|
|
|
StringBuilder manifestBuilder = new StringBuilder();
|
|
|
|
|
List<Regex> rgxList = new List<Regex>();
|
|
|
|
|
|
|
|
|
|
if ( fileList != null )
|
|
|
|
|
{
|
|
|
|
|
foreach ( string fileListentry in fileList )
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Regex rgx = new Regex( fileListentry, RegexOptions.Compiled | RegexOptions.IgnoreCase );
|
|
|
|
|
rgxList.Add( rgx );
|
|
|
|
|
}
|
|
|
|
|
catch { continue; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
byte[] cryptKey = CDRManager.GetDepotEncryptionKey( depotId, depotVersion );
|
|
|
|
|
string[] excludeList = null;
|
|
|
|
|
|
|
|
|
|
if ( gameServer && exclude )
|
|
|
|
|
if ( Config.UsingExclusionList )
|
|
|
|
|
excludeList = GetExcludeList( session, manifest );
|
|
|
|
|
|
|
|
|
|
for ( int x = 0 ; x < manifest.Nodes.Count ; ++x )
|
|
|
|
@ -398,7 +543,7 @@ namespace DepotDownloader
|
|
|
|
|
|
|
|
|
|
string downloadPath = Path.Combine( installDir, dirEntry.FullName.ToLower() );
|
|
|
|
|
|
|
|
|
|
if ( onlyManifest )
|
|
|
|
|
if ( Config.DownloadManifestOnly )
|
|
|
|
|
{
|
|
|
|
|
if ( dirEntry.FileID == -1 )
|
|
|
|
|
continue;
|
|
|
|
@ -407,44 +552,16 @@ namespace DepotDownloader
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( gameServer && exclude && IsFileExcluded( dirEntry.FullName, excludeList ) )
|
|
|
|
|
if (Config.UsingExclusionList && IsFileExcluded(dirEntry.FullName, excludeList))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if ( fileList != null )
|
|
|
|
|
{
|
|
|
|
|
bool bMatched = false;
|
|
|
|
|
|
|
|
|
|
foreach ( string fileListEntry in fileList )
|
|
|
|
|
{
|
|
|
|
|
if ( fileListEntry.Equals( dirEntry.FullName, StringComparison.OrdinalIgnoreCase ) )
|
|
|
|
|
{
|
|
|
|
|
bMatched = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !bMatched )
|
|
|
|
|
{
|
|
|
|
|
foreach ( Regex rgx in rgxList )
|
|
|
|
|
{
|
|
|
|
|
Match m = rgx.Match( dirEntry.FullName );
|
|
|
|
|
|
|
|
|
|
if ( m.Success )
|
|
|
|
|
{
|
|
|
|
|
bMatched = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !bMatched )
|
|
|
|
|
continue;
|
|
|
|
|
if (!TestIsFileIncluded(dirEntry.FullName))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
string path = Path.GetDirectoryName( downloadPath );
|
|
|
|
|
string path = Path.GetDirectoryName(downloadPath);
|
|
|
|
|
|
|
|
|
|
if ( !Directory.Exists( path ) )
|
|
|
|
|
Directory.CreateDirectory( path );
|
|
|
|
|
}
|
|
|
|
|
if (!Directory.Exists(path))
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
|
|
|
|
|
|
if ( dirEntry.FileID == -1 )
|
|
|
|
|
{
|
|
|
|
@ -470,7 +587,7 @@ namespace DepotDownloader
|
|
|
|
|
File.WriteAllBytes( downloadPath, file );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( onlyManifest )
|
|
|
|
|
if ( Config.DownloadManifestOnly )
|
|
|
|
|
File.WriteAllText( txtManifest, manifestBuilder.ToString() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -478,40 +595,6 @@ namespace DepotDownloader
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ContentServerClient.Credentials GetCredentials( uint depotId, uint appId, string username, string password )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
steam3 = new Steam3Session(
|
|
|
|
|
new SteamUser.LogOnDetails()
|
|
|
|
|
{
|
|
|
|
|
Username = username,
|
|
|
|
|
Password = password,
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
depotId,
|
|
|
|
|
appId
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
var steam3Credentials = steam3.WaitForCredentials();
|
|
|
|
|
|
|
|
|
|
if ( !steam3Credentials.HasSessionToken || steam3Credentials.AppTicket == null || steam3Credentials.Steam2Ticket == null )
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine( "Unable to get steam3 credentials." );
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Steam2Ticket s2Ticket = new Steam2Ticket( steam3Credentials.Steam2Ticket );
|
|
|
|
|
|
|
|
|
|
ContentServerClient.Credentials credentials = new ContentServerClient.Credentials()
|
|
|
|
|
{
|
|
|
|
|
Steam2Ticket = s2Ticket,
|
|
|
|
|
AppTicket = steam3Credentials.AppTicket,
|
|
|
|
|
SessionToken = steam3Credentials.SessionToken,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return credentials;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static IPEndPoint[] GetStorageServer( int depotId, int depotVersion, int cellId )
|
|
|
|
|
{
|
|
|
|
|
foreach ( IPEndPoint csdServer in ServerCache.CSDSServers )
|
|
|
|
@ -536,30 +619,6 @@ 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 )
|
|
|
|
|