DepotDownloader: Added anonymous download support

pull/8/head
Ryan Kistner 13 years ago
parent eb64860ae8
commit 6a5a329ddf

@ -302,7 +302,7 @@ namespace DepotDownloader
return DownloadSource.Steam2; return DownloadSource.Steam2;
KeyValue config = GetSteam3AppSection(appId, EAppInfoSection.Config); KeyValue config = GetSteam3AppSection(appId, EAppInfoSection.Config);
int contenttype = config[appId.ToString()]["contenttype"].AsInteger(0); int contenttype = config["contenttype"].AsInteger(0);
// EContentDownloadSourceType? // EContentDownloadSourceType?
if (contenttype != 3) if (contenttype != 3)
@ -362,7 +362,7 @@ namespace DepotDownloader
if (info == null) if (info == null)
return String.Empty; return String.Empty;
return info[appId.ToString()]["name"].AsString(); return info["name"].AsString();
} }
else else
{ {
@ -668,10 +668,15 @@ namespace DepotDownloader
List<CDNClient.ClientEndPoint> cdnEndpoints = cdnServers.Where((ep) => { return ep.Type == "CDN"; }).ToList(); List<CDNClient.ClientEndPoint> cdnEndpoints = cdnServers.Where((ep) => { return ep.Type == "CDN"; }).ToList();
List<CDNClient.ClientEndPoint> csEndpoints = cdnServers.Where((ep) => { return ep.Type == "CS"; }).ToList(); List<CDNClient.ClientEndPoint> csEndpoints = cdnServers.Where((ep) => { return ep.Type == "CS"; }).ToList();
List<CDNClient> cdnClients = new List<CDNClient>(); List<CDNClient> cdnClients = new List<CDNClient>();
byte[] appTicket = steam3.AppTickets[(uint)depotId];
foreach (var server in csEndpoints) foreach (var server in csEndpoints)
{ {
CDNClient client = new CDNClient(server, steam3.AppTickets[(uint)depotId]); CDNClient client;
if (appTicket == null)
client = new CDNClient(server, (uint)depotId, steam3.steamUser.SteamID);
else
client = new CDNClient(server, appTicket);
if (client.Connect()) if (client.Connect())
{ {

@ -36,12 +36,12 @@ namespace DepotDownloader
public Dictionary<uint, bool> AppInfoOverridesCDR { get; private set; } public Dictionary<uint, bool> AppInfoOverridesCDR { get; private set; }
public SteamClient steamClient; public SteamClient steamClient;
public SteamUser steamUser;
SteamUser steamUser;
SteamApps steamApps; SteamApps steamApps;
CallbackManager callbacks; CallbackManager callbacks;
bool authenticatedUser;
bool bConnected; bool bConnected;
bool bAborted; bool bAborted;
DateTime connectTime; DateTime connectTime;
@ -59,6 +59,7 @@ namespace DepotDownloader
{ {
this.logonDetails = details; this.logonDetails = details;
this.authenticatedUser = details.Username != null;
this.credentials = new Credentials(); this.credentials = new Credentials();
this.bConnected = false; this.bConnected = false;
this.bAborted = false; this.bAborted = false;
@ -84,11 +85,14 @@ namespace DepotDownloader
Console.Write( "Connecting to Steam3..." ); Console.Write( "Connecting to Steam3..." );
if ( authenticatedUser )
{
FileInfo fi = new FileInfo(String.Format("{0}.sentryFile", logonDetails.Username)); FileInfo fi = new FileInfo(String.Format("{0}.sentryFile", logonDetails.Username));
if(fi.Exists && fi.Length > 0) if (fi.Exists && fi.Length > 0)
{ {
logonDetails.SentryFileHash = Util.SHAHash(File.ReadAllBytes(fi.FullName)); logonDetails.SentryFileHash = Util.SHAHash(File.ReadAllBytes(fi.FullName));
} }
}
Connect(); Connect();
} }
@ -188,6 +192,13 @@ namespace DepotDownloader
if (AppTickets.ContainsKey(appId) || bAborted) if (AppTickets.ContainsKey(appId) || bAborted)
return; return;
if ( !authenticatedUser )
{
AppTickets[appId] = null;
return;
}
Action<SteamApps.AppOwnershipTicketCallback, JobID> cbMethod = (appTicket, jobId) => Action<SteamApps.AppOwnershipTicketCallback, JobID> cbMethod = (appTicket, jobId) =>
{ {
if (appTicket.Result != EResult.OK) if (appTicket.Result != EResult.OK)
@ -282,7 +293,7 @@ namespace DepotDownloader
{ {
Console.WriteLine(" Done!"); Console.WriteLine(" Done!");
bConnected = true; bConnected = true;
if ( logonDetails.Username == null ) if ( !authenticatedUser )
{ {
Console.Write( "Logging anonymously into Steam3..." ); Console.Write( "Logging anonymously into Steam3..." );
steamUser.LogOnAnonymous(); steamUser.LogOnAnonymous();

Loading…
Cancel
Save