From a80ad3924247ad3990b50a3747d83c06f8c5d8b6 Mon Sep 17 00:00:00 2001 From: RobinSchapendonk <46354497+Robin-Sch@users.noreply.github.com> Date: Tue, 18 Jan 2022 21:48:05 +0100 Subject: [PATCH] pool status checker --- index.js | 41 ++++++++++++++++++++++++++++++++++++++--- js/main.js | 6 +++++- package.json | 2 +- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index b735eae..1ff586d 100755 --- a/index.js +++ b/index.js @@ -8,7 +8,6 @@ const { cpus } = require('os'); const fetch = require('node-fetch'); const { app, BrowserWindow, Menu, ipcMain } = electron; -const { info } = require('electron-log'); autoUpdater.logger = log; autoUpdater.logger.transports.file.level = 'info'; @@ -22,6 +21,20 @@ const gotTheLock = app.requestSingleInstanceLock(); const cpuCount = cpus().length; const MenuTemplate = [ + { + label: 'Updates', + submenu: [ + { + label: `Version: ${app.getVersion()}` + }, + { + label: 'Check for updates', + click: function(item, focusedWindow) { + autoUpdater.checkForUpdates(); + } + } + ] + }, { label: 'Debugging', submenu: [ @@ -83,9 +96,9 @@ if (!gotTheLock && app.isPackaged) { if(app.isPackaged) { log.info('starting update check'); - return autoUpdater.checkForUpdates(); + autoUpdater.checkForUpdates(); } else { - return currentWindow.webContents.openDevTools(); + currentWindow.webContents.openDevTools(); } }); @@ -133,6 +146,10 @@ if (!gotTheLock && app.isPackaged) { if (!reload) return currentWindow.webContents.send('miner-status', { type, status: false }); } + const res = await checkPool(); + console.log(res, 'res'); + if(!res) return; + if (!['cpu','gpu'].includes(type)) return log.info(`No CPU or GPU as mining type! ${type}`); const resourcesPath = join(app.getAppPath(), app.isPackaged ? '..' : ''); @@ -227,4 +244,22 @@ if (!gotTheLock && app.isPackaged) { autoUpdater.quitAndInstall(); }, 3000); }); +} + +const checkPool = async () => { + try { + process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; + const res = await fetch('https://gulf.moneroocean.stream'); + process.env.NODE_TLS_REJECT_UNAUTHORIZED = undefined; + const text = await res.text(); + if (text !== 'Mining Pool Online') { + currentWindow.webContents.send('pool-status', { online: false }); + return false; + } else { + return true; + } + } catch (e) { + currentWindow.webContents.send('pool-status', { online: false }); + return false; + } } \ No newline at end of file diff --git a/js/main.js b/js/main.js index 91ada89..72f17fe 100755 --- a/js/main.js +++ b/js/main.js @@ -62,7 +62,11 @@ ipcRenderer.on('resetXmrigStatus', (event, { type, message }) => { modal.hide(); return log.innerHTML += `