private async Task handleGetInfo(HttpProcessor p) { var info = await MyInfo.Fetch(api.getConsole()); p.writeSuccess(); await p.outputStream.WriteLineAsync(info.Json.ToString()); }
public override Tasks NextTaskToUpgrade() { var info = MyInfo.Fetch(console).Result; RebuildPercentages(info, cfg); return(chooseTask(info)); }
public void Init(IConfig cfg, IConfigParser parser) { config = cfg; configParser = parser; try { var builder = new vhAPIBuilder().useConfig(cfg); api = builder.getAPI(); timerInfo = new Timer((o) => { var info = MyInfo.Fetch(api.getConsole()).Result; lock (this) { jsonInfo = info.Json; } }, null, TimeSpan.Zero, TimeSpan.FromSeconds(10)); } catch (Exception exc) { config.logger.Log($"Error creating vhAPI: {exc.Message}"); } }
public override void Set(IConfig cfg, vhAPI api) { logger = cfg.logger; _api = api; Pause = () => { hackTimer.Change(0, Timeout.Infinite); cfg.logger.Log("*** STOPPING UPGRADE MANAGER"); }; Resume = () => { Set(cfg, api); cfg.logger.Log("*** RESUMING UPGRADE MANAGER"); }; if (hackTimer != null) { hackTimer.Dispose(); hackTimer = null; } var console = api.getConsole(); var upd = new Update(cfg); hackTimer = new Timer( async(o) => { if (!Monitor.TryEnter(localSemaphore)) { return; } try { var info = await MyInfo.Fetch(console); var tasks = await upd.getTasks(); // upgrade botnet PCs anyway await doUpgradePc(info, upd); var curStatus = CurrentStatus(info, tasks); if (curStatus == Status.Idle) { return; } if (curStatus == Status.Upgrade) { await doUpgrade(info, upd, cfg, tasks); } if (curStatus == Status.EndTasks) { await doBoost(info, upd, cfg, tasks); } } catch (Exception e) { cfg.logger.Log(e.ToString()); } finally { Monitor.Exit(localSemaphore); } } , null, TimeSpan.Zero, TimeSpan.FromSeconds(1)); }
public virtual Tasks NextTaskToUpgrade() { var info = MyInfo.Fetch(console).Result; return(chooseTask(info)); }