Compare commits

...

7 Commits

Author SHA1 Message Date
JustArchi
765f9d29bb Fix version comparison bug (and bump to 2.0.1.0 to fix legacy versions) 2016-03-14 22:40:19 +01:00
JustArchi
99af5c86a5 Bump 2016-03-14 22:20:06 +01:00
JustArchi
0bb2b3ed5f Add UnobservedTaskExceptionHandler, thank you @Netshroud 2016-03-14 20:51:29 +01:00
JustArchi
4181f3ba21 Add workaround for broken GenerateMachineID(), #154 2016-03-14 20:38:17 +01:00
JustArchi
c189b398c0 Improve readability 2016-03-14 18:24:03 +01:00
JustArchi
de4fbf8b04 Accept only trade confirmations when dealing with trades 2016-03-14 18:13:33 +01:00
JustArchi
f91a558314 Bump 2016-03-13 22:58:52 +01:00
8 changed files with 80 additions and 15 deletions

View File

@@ -265,6 +265,36 @@ namespace ArchiSteamFarm {
}
}
// TODO: Please remove me immediately after https://github.com/SteamRE/SteamKit/issues/254 gets fixed
internal void HackedLogOn(SteamUser.LogOnDetails details) {
if (!Client.IsConnected) {
return;
}
SteamID steamID = new SteamID(details.AccountID, details.AccountInstance, Client.ConnectedUniverse, EAccountType.Individual);
var logon = new ClientMsgProtobuf<CMsgClientLogon>(EMsg.ClientLogon);
logon.Body.obfustucated_private_ip = details.LoginID.Value;
logon.ProtoHeader.client_sessionid = 0;
logon.ProtoHeader.steamid = steamID.ConvertToUInt64();
logon.Body.account_name = details.Username;
logon.Body.password = details.Password;
logon.Body.should_remember_password = details.ShouldRememberPassword;
logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;
logon.Body.client_os_type = (uint) details.ClientOSType;
logon.Body.client_language = details.ClientLanguage;
logon.Body.cell_id = details.CellID;
logon.Body.steam2_ticket_request = details.RequestSteam2Ticket;
logon.Body.client_package_version = 1771;
logon.Body.auth_code = details.AuthCode;
logon.Body.two_factor_code = details.TwoFactorCode;
logon.Body.login_key = details.LoginKey;
logon.Body.sha_sentryfile = details.SentryFileHash;
logon.Body.eresult_sentryfile = (int) (details.SentryFileHash != null ? EResult.OK : EResult.FileNotFound);
Client.Send(logon);
}
/*
_ _ _ _
| | | | __ _ _ __ __| || | ___ _ __ ___

View File

@@ -223,7 +223,7 @@ namespace ArchiSteamFarm {
if (BotConfig.AcceptConfirmationsPeriod > 0 && AcceptConfirmationsTimer == null) {
AcceptConfirmationsTimer = new Timer(
async e => await AcceptAllConfirmations().ConfigureAwait(false),
async e => await AcceptConfirmations().ConfigureAwait(false),
null,
TimeSpan.FromMinutes(BotConfig.AcceptConfirmationsPeriod), // Delay
TimeSpan.FromMinutes(BotConfig.AcceptConfirmationsPeriod) // Period
@@ -247,7 +247,7 @@ namespace ArchiSteamFarm {
Start().Wait();
}
internal async Task AcceptAllConfirmations() {
internal async Task AcceptConfirmations(Confirmation.ConfirmationType allowedConfirmationType = Confirmation.ConfirmationType.Unknown) {
if (BotDatabase.SteamGuardAccount == null) {
return;
}
@@ -263,11 +263,11 @@ namespace ArchiSteamFarm {
}
foreach (Confirmation confirmation in confirmations) {
if (BotDatabase.SteamGuardAccount.AcceptConfirmation(confirmation)) {
Logging.LogGenericInfo("Accepting confirmation: Success!", BotName);
} else {
Logging.LogGenericWarning("Accepting confirmation: Failed!", BotName);
if (allowedConfirmationType != Confirmation.ConfirmationType.Unknown && confirmation.ConfType != allowedConfirmationType) {
continue;
}
BotDatabase.SteamGuardAccount.AcceptConfirmation(confirmation);
}
} catch (SteamGuardAccount.WGTokenInvalidException) {
Logging.LogGenericWarning("Accepting confirmation: Failed!", BotName);
@@ -537,7 +537,7 @@ namespace ArchiSteamFarm {
}
if (await ArchiWebHandler.SendTradeOffer(inventory, BotConfig.SteamMasterID, BotConfig.SteamTradeToken).ConfigureAwait(false)) {
await AcceptAllConfirmations().ConfigureAwait(false);
await AcceptConfirmations(Confirmation.ConfirmationType.Trade).ConfigureAwait(false);
return "Trade offer sent successfully!";
} else {
return "Trade offer failed due to error!";
@@ -609,7 +609,7 @@ namespace ArchiSteamFarm {
return "That bot doesn't have ASF 2FA enabled!";
}
await AcceptAllConfirmations().ConfigureAwait(false);
await AcceptConfirmations().ConfigureAwait(false);
return "Done!";
}
@@ -1082,6 +1082,24 @@ namespace ArchiSteamFarm {
InitializeLoginAndPassword();
Logging.LogGenericInfo("Logging in...", BotName);
// TODO: Please remove me immediately after https://github.com/SteamRE/SteamKit/issues/254 gets fixed
if (Program.GlobalConfig.HackIgnoreMachineID) {
Logging.LogGenericWarning("Using workaround for broken GenerateMachineID()!", BotName);
ArchiHandler.HackedLogOn(new SteamUser.LogOnDetails {
Username = BotConfig.SteamLogin,
Password = BotConfig.SteamPassword,
AuthCode = AuthCode,
LoginID = LoginID,
LoginKey = BotDatabase.LoginKey,
TwoFactorCode = TwoFactorAuth,
SentryFileHash = sentryHash,
ShouldRememberPassword = true
});
return;
}
SteamUser.LogOn(new SteamUser.LogOnDetails {
Username = BotConfig.SteamLogin,
Password = BotConfig.SteamPassword,

View File

@@ -80,6 +80,10 @@ namespace ArchiSteamFarm {
[JsonProperty(Required = Required.DisallowNull)]
internal bool Statistics { get; private set; } = true;
// TODO: Please remove me immediately after https://github.com/SteamRE/SteamKit/issues/254 gets fixed
[JsonProperty(Required = Required.DisallowNull)]
internal bool HackIgnoreMachineID { get; private set; } = false;
[JsonProperty(Required = Required.DisallowNull)]
internal HashSet<uint> Blacklist { get; private set; } = new HashSet<uint>(GlobalBlacklist);

View File

@@ -69,7 +69,7 @@ namespace ArchiSteamFarm {
}
Log("[!] EXCEPTION: " + previousMethodName + "() <" + botName + "> " + exception.Message);
Log("[!] StackTrace: " + exception.StackTrace);
Log("[!] StackTrace:" + Environment.NewLine + exception.StackTrace);
if (exception.InnerException != null) {
LogGenericException(exception.InnerException, botName, previousMethodName);

View File

@@ -72,7 +72,7 @@ namespace ArchiSteamFarm {
private static readonly string ExecutableDirectory = Path.GetDirectoryName(ExecutableFile);
private static readonly WCF WCF = new WCF();
internal static readonly string Version = Assembly.GetName().Version.ToString();
internal static readonly Version Version = Assembly.GetName().Version;
internal static GlobalConfig GlobalConfig { get; private set; }
internal static GlobalDatabase GlobalDatabase { get; private set; }
@@ -144,9 +144,11 @@ namespace ArchiSteamFarm {
return;
}
Logging.LogGenericInfo("Local version: " + Version + " | Remote version: " + releaseResponse.Tag);
Version newVersion = new Version(releaseResponse.Tag);
if (string.Compare(Version, releaseResponse.Tag, StringComparison.Ordinal) >= 0) { // If local version is the same or newer than remote version
Logging.LogGenericInfo("Local version: " + Version + " | Remote version: " + newVersion);
if (Version.CompareTo(newVersion) >= 0) { // If local version is the same or newer than remote version
if (GlobalConfig.AutoUpdates && AutoUpdatesTimer == null) {
Logging.LogGenericInfo("ASF will automatically check for new versions every 24 hours");
AutoUpdatesTimer = new Timer(
@@ -414,8 +416,17 @@ namespace ArchiSteamFarm {
Logging.LogGenericException((Exception) args.ExceptionObject);
}
private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs args) {
if (sender == null || args == null) {
return;
}
Logging.LogGenericException(args.Exception);
}
private static void Main(string[] args) {
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
TaskScheduler.UnobservedTaskException += UnobservedTaskExceptionHandler;
Logging.LogGenericInfo("Archi's Steam Farm, version " + Version);
Directory.SetCurrentDirectory(ExecutableDirectory);

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0.9")]
[assembly: AssemblyFileVersion("2.0.0.9")]
[assembly: AssemblyVersion("2.0.1.0")]
[assembly: AssemblyFileVersion("2.0.1.0")]

View File

@@ -22,6 +22,7 @@
*/
using SteamAuth;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
@@ -81,7 +82,7 @@ namespace ArchiSteamFarm {
}
await Task.WhenAll(tasks).ConfigureAwait(false);
await Bot.AcceptAllConfirmations().ConfigureAwait(false);
await Bot.AcceptConfirmations(Confirmation.ConfirmationType.Trade).ConfigureAwait(false);
}
private async Task ParseTrade(Steam.TradeOffer tradeOffer) {

View File

@@ -13,6 +13,7 @@
"WCFHostname": "localhost",
"WCFPort": 1242,
"Statistics": true,
"HackIgnoreMachineID": false,
"Blacklist": [
267420,
303700,