Touched formatting and line endings. Tweaked login key handling.

pull/25/head
Ryan Kistner 9 years ago
parent dceed3a9a1
commit 58b5b6185e

@ -3,10 +3,7 @@ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DepotDownloader
{

@ -1,15 +1,12 @@
using System;
using SteamKit2;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using SteamKit2;
using System.Collections.Concurrent;
using System.Threading.Tasks;
namespace DepotDownloader
{
@ -334,13 +331,20 @@ namespace DepotDownloader
public static bool InitializeSteam3( string username, string password )
{
string loginKey = null;
if ( username != null && ContentDownloader.Config.RememberPassword && ConfigStore.TheConfig.LoginKeys.ContainsKey( username ) )
{
loginKey = ConfigStore.TheConfig.LoginKeys[ username ];
}
steam3 = new Steam3Session(
new SteamUser.LogOnDetails()
{
Username = username,
Password = password,
Password = loginKey == null ? password : null,
ShouldRememberPassword = Config.RememberPassword,
LoginKey = username != null && ConfigStore.TheConfig.LoginKeys.ContainsKey(username) ? ConfigStore.TheConfig.LoginKeys[username] : null,
LoginKey = loginKey,
}
);
@ -361,6 +365,7 @@ namespace DepotDownloader
if ( steam3 == null )
return;
steam3.TryWaitForLoginKey();
steam3.Disconnect();
}
@ -584,7 +589,8 @@ namespace DepotDownloader
while ( depotManifest == null )
{
CDNClient client = null;
try {
try
{
client = cdnPool.GetConnectionForDepot( appId, depot.id, depot.depotKey, CancellationToken.None );
depotManifest = client.DownloadManifest( depot.id, depot.manifestId );

@ -25,6 +25,7 @@ namespace DepotDownloader
public int MaxServers { get; set; }
public int MaxDownloads { get; set; }
public string SuppliedPassword { get; set; }
public bool RememberPassword { get; set; }
}
}

@ -109,6 +109,9 @@ namespace DepotDownloader
Console.WriteLine( "No username given. Using anonymous account with dedicated server subscription." );
}
// capture the supplied password in case we need to re-use it after checking the login key
ContentDownloader.Config.SuppliedPassword = password;
if ( ContentDownloader.InitializeSteam3( username, password ) )
{
ContentDownloader.DownloadApp( appId, depotId, branch, forceDepot );

@ -165,7 +165,8 @@ namespace DepotDownloader
}
};
WaitUntilCallback(() => {
WaitUntilCallback( () =>
{
callbacks.Subscribe( steamApps.PICSGetAccessTokens( new List<uint>() { appId }, new List<uint>() { } ), cbMethodTokens );
}, () => { return completed; } );
@ -195,7 +196,8 @@ namespace DepotDownloader
request.Public = false;
}
WaitUntilCallback(() => {
WaitUntilCallback( () =>
{
callbacks.Subscribe( steamApps.PICSGetProductInfo( new List<SteamApps.PICSRequest>() { request }, new List<SteamApps.PICSRequest>() { } ), cbMethod );
}, () => { return completed; } );
}
@ -225,7 +227,8 @@ namespace DepotDownloader
}
};
WaitUntilCallback(() => {
WaitUntilCallback( () =>
{
callbacks.Subscribe( steamApps.PICSGetProductInfo( new List<uint>(), packages ), cbMethod );
}, () => { return completed; } );
}
@ -240,7 +243,8 @@ namespace DepotDownloader
success = resultInfo.GrantedApps.Contains( appId );
};
WaitUntilCallback(() => {
WaitUntilCallback( () =>
{
callbacks.Subscribe( steamApps.RequestFreeLicense( appId ), cbMethod );
}, () => { return completed; } );
@ -276,7 +280,8 @@ namespace DepotDownloader
}
};
WaitUntilCallback(() => {
WaitUntilCallback( () =>
{
callbacks.Subscribe( steamApps.GetAppOwnershipTicket( appId ), cbMethod );
}, () => { return completed; } );
}
@ -392,6 +397,22 @@ namespace DepotDownloader
}
}
public void TryWaitForLoginKey()
{
if ( logonDetails.Username == null || !ContentDownloader.Config.RememberPassword ) return;
DateTime waitUntil = new DateTime().AddSeconds( 10 );
while ( true )
{
DateTime now = new DateTime();
if ( now >= waitUntil ) break;
if ( ConfigStore.TheConfig.LoginKeys.ContainsKey( logonDetails.Username ) ) break;
callbacks.RunWaitAllCallbacks( TimeSpan.FromMilliseconds( 100 ) );
}
}
private void WaitForCallbacks()
{
@ -443,7 +464,8 @@ namespace DepotDownloader
if ( bConnecting )
{
Console.WriteLine( "Connection to Steam failed. Trying again" );
} else
}
else
{
Console.WriteLine( "Lost connection to Steam. Reconnecting" );
}
@ -457,19 +479,41 @@ namespace DepotDownloader
{
bool isSteamGuard = loggedOn.Result == EResult.AccountLogonDenied;
bool is2FA = loggedOn.Result == EResult.AccountLoginDeniedNeedTwoFactor;
bool isLoginKey = ContentDownloader.Config.RememberPassword && logonDetails.LoginKey != null && loggedOn.Result == EResult.InvalidPassword;
if (isSteamGuard || is2FA)
if ( isSteamGuard || is2FA || isLoginKey )
{
bExpectingDisconnectRemote = true;
Abort( false );
if ( !isLoginKey )
{
Console.WriteLine( "This account is protected by Steam Guard." );
}
if ( is2FA )
{
Console.Write( "Please enter your 2 factor auth code from your authenticator app: " );
logonDetails.TwoFactorCode = Console.ReadLine();
}
else if ( isLoginKey )
{
ConfigStore.TheConfig.LoginKeys.Remove( logonDetails.Username );
ConfigStore.Save();
logonDetails.LoginKey = null;
if ( ContentDownloader.Config.SuppliedPassword != null )
{
Console.WriteLine( "Login key was expired. Connecting with supplied password." );
logonDetails.Password = ContentDownloader.Config.SuppliedPassword;
}
else
{
Console.WriteLine( "Login key was expired. Please enter your password: " );
logonDetails.Password = Util.ReadPassword();
}
}
else
{
Console.Write( "Please enter the authentication code sent to your email address: " );
@ -566,6 +610,8 @@ namespace DepotDownloader
private void LoginKeyCallback( SteamUser.LoginKeyCallback loginKey )
{
Console.WriteLine( "Accepted new login key for account {0}", logonDetails.Username );
ConfigStore.TheConfig.LoginKeys[ logonDetails.Username ] = loginKey.LoginKey;
ConfigStore.Save();

Loading…
Cancel
Save