mirror of
https://github.com/SteamRE/DepotDownloader.git
synced 2026-10-20 01:46:17 +00:00
Cut some code and determined the issue behind authenticated downloads not working. It's fixed now.
--HG-- extra : convert_revision : svn%3A946a0da7-ebce-4904-9acb-2f1e67aed693%40218
This commit is contained in:
1 parent
14f2b6e39d
commit
de9ea3a6c8
2 files changed
+42
-6
No files matched your search
@@ -14,6 +14,8 @@ namespace DepotDownloader
|
||||
{
|
||||
const string DOWNLOAD_DIR = "depots";
|
||||
|
||||
static Steam3Session steam3;
|
||||
|
||||
public static void Download( int depotId, int depotVersion, int cellId, string username, string password )
|
||||
{
|
||||
Directory.CreateDirectory( DOWNLOAD_DIR );
|
||||
@@ -55,6 +57,10 @@ namespace DepotDownloader
|
||||
if ( storageId == uint.MaxValue )
|
||||
{
|
||||
Console.WriteLine( "This depot requires valid user credentials and a license for this app" );
|
||||
|
||||
if ( steam3 != null )
|
||||
steam3.Disconnect();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -126,6 +132,9 @@ namespace DepotDownloader
|
||||
|
||||
csClient.Disconnect();
|
||||
|
||||
if ( steam3 != null )
|
||||
steam3.Disconnect();
|
||||
|
||||
}
|
||||
|
||||
static ContentServerClient.Credentials GetCredentials( uint depotId, string username, string password )
|
||||
@@ -144,7 +153,7 @@ namespace DepotDownloader
|
||||
byte[] serverTgt;
|
||||
Blob accountRecord;
|
||||
|
||||
Console.Write( "Logging in '{0}'... ", username );
|
||||
Console.Write( "Logging '{0}' into Steam2... ", username );
|
||||
AuthServerClient.LoginResult result = asClient.Login( username, password, out clientTgt, out serverTgt, out accountRecord );
|
||||
|
||||
if ( result != AuthServerClient.LoginResult.LoggedIn )
|
||||
@@ -153,7 +162,9 @@ namespace DepotDownloader
|
||||
return null;
|
||||
}
|
||||
|
||||
Steam3Session steam3 = new Steam3Session(
|
||||
Console.WriteLine( " Done!" );
|
||||
|
||||
steam3 = new Steam3Session(
|
||||
new SteamUser.LogOnDetails()
|
||||
{
|
||||
Username = username,
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace DepotDownloader
|
||||
SteamApps steamApps;
|
||||
|
||||
Thread callbackThread;
|
||||
ManualResetEvent credentialHandle;
|
||||
bool bConnected;
|
||||
|
||||
DateTime connectTime;
|
||||
|
||||
@@ -43,7 +45,8 @@ namespace DepotDownloader
|
||||
this.logonDetails = details;
|
||||
|
||||
this.credentials = new Credentials();
|
||||
|
||||
this.credentialHandle = new ManualResetEvent( false );
|
||||
this.bConnected = false;
|
||||
|
||||
this.steamClient = new SteamClient();
|
||||
|
||||
@@ -53,16 +56,22 @@ namespace DepotDownloader
|
||||
this.callbackThread = new Thread( HandleCallbacks );
|
||||
this.callbackThread.Start();
|
||||
|
||||
Console.Write( "Connecting to Steam3..." );
|
||||
|
||||
this.connectTime = DateTime.Now;
|
||||
this.steamClient.Connect();
|
||||
}
|
||||
|
||||
public Credentials WaitForCredentials()
|
||||
{
|
||||
this.callbackThread.Join(); // no timespan as the thread will terminate itself
|
||||
this.credentialHandle.WaitOne();
|
||||
|
||||
return credentials;
|
||||
}
|
||||
public void Disconnect()
|
||||
{
|
||||
steamClient.Disconnect();
|
||||
}
|
||||
|
||||
void HandleCallbacks()
|
||||
{
|
||||
@@ -72,7 +81,10 @@ namespace DepotDownloader
|
||||
|
||||
TimeSpan diff = DateTime.Now - connectTime;
|
||||
|
||||
if ( diff > STEAM3_TIMEOUT || ( credentials.HasSessionToken && credentials.AppTicket != null ) )
|
||||
if ( diff > STEAM3_TIMEOUT && !bConnected )
|
||||
break;
|
||||
|
||||
if ( credentials.HasSessionToken && credentials.AppTicket != null )
|
||||
break;
|
||||
|
||||
if ( callback == null )
|
||||
@@ -80,7 +92,14 @@ namespace DepotDownloader
|
||||
|
||||
if ( callback.IsType<SteamClient.ConnectCallback>() )
|
||||
{
|
||||
Console.WriteLine( " Done!" );
|
||||
bConnected = true;
|
||||
steamUser.LogOn( logonDetails );
|
||||
|
||||
SteamID steamId = new SteamID();
|
||||
steamId.SetFromSteam2( logonDetails.ClientTGT.UserID, steamClient.ConnectedUniverse );
|
||||
|
||||
Console.Write( "Logging '{0}' into Steam3...", steamId.Render() );
|
||||
}
|
||||
|
||||
if ( callback.IsType<SteamUser.LogOnCallback>() )
|
||||
@@ -94,6 +113,8 @@ namespace DepotDownloader
|
||||
break;
|
||||
}
|
||||
|
||||
Console.WriteLine( " Done!" );
|
||||
|
||||
steamApps.GetAppOwnershipTicket( depotId );
|
||||
}
|
||||
|
||||
@@ -111,6 +132,7 @@ namespace DepotDownloader
|
||||
break;
|
||||
}
|
||||
|
||||
Console.WriteLine( "Got appticket for {0}!", depotId );
|
||||
credentials.AppTicket = msg.Ticket;
|
||||
|
||||
}
|
||||
@@ -119,12 +141,15 @@ namespace DepotDownloader
|
||||
{
|
||||
var msg = callback as SteamUser.SessionTokenCallback;
|
||||
|
||||
Console.WriteLine( "Got session token!" );
|
||||
credentials.SessionToken = msg.SessionToken;
|
||||
credentials.HasSessionToken = true;
|
||||
}
|
||||
}
|
||||
|
||||
steamClient.Disconnect();
|
||||
credentialHandle.Set();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user