Merge remote-tracking branch 'refs/remotes/origin/master'

Conflicts:
	src/cc/XMRigd.cpp
This commit is contained in:
BenDroid 2018-01-14 19:16:10 +01:00
commit 34f7fcc957
7 changed files with 62 additions and 32 deletions

View file

@ -11,6 +11,7 @@
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet"> <link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
<style> <style>
.right{text-align:right;}
.left{text-align:left;} .left{text-align:left;}
.center{text-align:center; padding-bottom: 50pt} .center{text-align:center; padding-bottom: 50pt}
.center-tab{text-align: center; vertical-align: middle;} .center-tab{text-align: center; vertical-align: middle;}
@ -49,20 +50,26 @@
<script src="https://use.fontawesome.com/6b3cdfc597.js"></script> <script src="https://use.fontawesome.com/6b3cdfc597.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var TRESHOLD_IN_MS = 90 * 1000; var TRESHOLD_IN_MS = 60 * 1000;
var RELOAD_INTERVAL_IN_MS = 10 * 1000; var RELOAD_INTERVAL_IN_MS = 10 * 1000;
var latestRelease = "";
var currentServerTime = 0;
var clockDrift = 0;
$.fn.dataTable.ext.search.push( $.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) { function( settings, data, dataIndex ) {
var hideOffline = $('#hideOffline').prop('checked'); var hideOffline = $('#hideOffline').prop('checked');
var showNotification = $('#showOfflineNotification').prop('checked'); var showNotification = $('#showOfflineNotification').prop('checked');
var clientId = settings.aoData[dataIndex]._aData.client_status.client_id; var clientId = settings.aoData[dataIndex]._aData.client_status.client_id;
var lastStatus = settings.aoData[dataIndex]._aData.client_status.last_status_update * 1000; var lastStatus = settings.aoData[dataIndex]._aData.client_status.last_status_update * 1000;
var online = isOnline(lastStatus); var online = isOnline(lastStatus);
if (!online) { if (!online) {
var threshold = new Date().getTime() - (TRESHOLD_IN_MS + RELOAD_INTERVAL_IN_MS); var threshold = currentServerTime - (TRESHOLD_IN_MS + RELOAD_INTERVAL_IN_MS);
if (lastStatus > threshold && showNotification) { if (lastStatus > threshold && showNotification) {
$("#notificationBar").after('<div class="alert alert-danger alert-dismissable fade in">' + $("#notificationBar").after('<div class="alert alert-danger alert-dismissable fade in">' +
'<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>' + '<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>' +
@ -76,10 +83,9 @@
); );
$(document).ready(function() { $(document).ready(function() {
var latestRelease = "";
var table = $('#clientStatusList').DataTable({ var table = $('#clientStatusList').DataTable({
dom: "<'row'<'col-sm-9'B><'col-sm-3'f>><'row'<'col-sm-12't>><i>", dom: "<'row'<'col-sm-9'B><'col-sm-3'f>><'row'<'col-sm-12't>><'row'<'col-sm-10'i><'col-sm-2'<'#serverTime'>>>",
bPaginate: false, bPaginate: false,
ajax: { ajax: {
url: "/admin/getClientStatusList", url: "/admin/getClientStatusList",
@ -125,6 +131,7 @@
text: '<i class="fa fa-download"> Pull miner config</i>', text: '<i class="fa fa-download"> Pull miner config</i>',
className: 'btn-default', className: 'btn-default',
enabled: false, enabled: false,
enabled: false,
action: function () { action: function () {
table.rows({selected: true}).eq(0).each(function (index) { table.rows({selected: true}).eq(0).each(function (index) {
var row = table.row(index); var row = table.row(index);
@ -292,27 +299,34 @@
$(api.column(10).footer()).html(avgTimeTotal); $(api.column(10).footer()).html(avgTimeTotal);
$(api.column(11).footer()).html(sumSharesGood); $(api.column(11).footer()).html(sumSharesGood);
$(api.column(12).footer()).html(sumSharedTotal); $(api.column(12).footer()).html(sumSharedTotal);
// check version
if (latestRelease === "" && $(api).context[0].json !== undefined) {
$.ajax({
url: "https://api.github.com/repos/Bendr0id/xmrigCC/releases/latest",
type: 'GET',
dataType: "json",
success: function (release) {
latestRelease = release.tag_name;
if (latestRelease !== $(api).context[0].json.current_version) {
$("#updateNotificationBar").html('<div class="alert alert-info alert-dismissable fade in">' +
'<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>' +
'<a href="https://github.com/Bendr0id/xmrigCC/releases/latest"><strong>Update!</strong> XMRigCC v' + latestRelease + ' is available for download\n</a>' +
'</div>');
}
}
});
}
} }
}); });
table.on('xhr.dt', function ( e, settings, json, xhr ) {
// check version
if (latestRelease === "" && json !== undefined) {
$.ajax({
url: "https://api.github.com/repos/Bendr0id/xmrigCC/releases/latest",
type: 'GET',
dataType: "json",
success: function (release) {
latestRelease = release.tag_name;
if (latestRelease !== json.current_version) {
$("#updateNotificationBar").html('<div class="alert alert-info alert-dismissable fade in">' +
'<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>' +
'<a href="https://github.com/Bendr0id/xmrigCC/releases/latest"><strong>Update!</strong> XMRigCC v' + latestRelease + ' is available for download\n</a>' +
'</div>');
}
}
});
}
currentServerTime = settings.json.current_server_time * 1000;
clockDrift = new Date().getTime() - currentServerTime;
$('#serverTime').html("<div class='dataTables_info'>" + new Date(currentServerTime) + "</div>");
});
table.on('select', function () { table.on('select', function () {
var selectedRows = table.rows({selected: true}).count(); var selectedRows = table.rows({selected: true}).count();
@ -437,7 +451,7 @@
function laststatus( data, type, row ) { function laststatus( data, type, row ) {
if (type !== 'sort') { if (type !== 'sort') {
var date = new Date(data*1000); var date = new Date(data*1000 - clockDrift);
return '<span data-toggle="tooltip" title="' + date + '">' + jQuery.timeago(date) + '</span>'; return '<span data-toggle="tooltip" title="' + date + '">' + jQuery.timeago(date) + '</span>';
} }
@ -466,6 +480,7 @@
tooltip += "Status: "; tooltip += "Status: ";
var lastStatus = row.client_status.last_status_update * 1000; var lastStatus = row.client_status.last_status_update * 1000;
if (isOnline(lastStatus)) { if (isOnline(lastStatus)) {
tooltip += "Online"; tooltip += "Online";
return '<span data-toggle="tooltip" title="'+ tooltip + '"><div class="online">' + data + '</div></span>'; return '<span data-toggle="tooltip" title="'+ tooltip + '"><div class="online">' + data + '</div></span>';
@ -484,7 +499,7 @@
} }
function isOnline(lastStatus) { function isOnline(lastStatus) {
var threshold = new Date().getTime() - TRESHOLD_IN_MS; var threshold = currentServerTime - TRESHOLD_IN_MS;
if (lastStatus > threshold) { if (lastStatus > threshold) {
return true; return true;
} else { } else {
@ -601,7 +616,6 @@
</tfoot> </tfoot>
</table> </table>
<br/> <br/>
<div class="modal fade" id="minerEditor" role="dialog"> <div class="modal fade" id="minerEditor" role="dialog">
<div class="modal-dialog modal-lg"> <div class="modal-dialog modal-lg">

View file

@ -41,6 +41,8 @@
#include "Summary.h" #include "Summary.h"
#include "workers/Workers.h" #include "workers/Workers.h"
#include "cc/CCClient.h" #include "cc/CCClient.h"
#include "net/Url.h"
#ifdef HAVE_SYSLOG_H #ifdef HAVE_SYSLOG_H
# include "log/SysLog.h" # include "log/SysLog.h"
@ -157,6 +159,10 @@ int App::start()
uv_async_init(uv_default_loop(), &m_async, App::onCommandReceived); uv_async_init(uv_default_loop(), &m_async, App::onCommandReceived);
m_ccclient = new CCClient(m_options, &m_async); m_ccclient = new CCClient(m_options, &m_async);
if (! m_options->pools().front()->isValid()) {
LOG_WARN("No pool URL supplied, but CC server configured. Trying.");
}
} else { } else {
LOG_WARN("Please configure CC-Url and restart. CC feature is now deactivated."); LOG_WARN("Please configure CC-Url and restart. CC feature is now deactivated.");
} }
@ -164,7 +170,9 @@ int App::start()
Workers::start(m_options->affinity(), m_options->priority()); Workers::start(m_options->affinity(), m_options->priority());
m_network->connect(); if (m_options->pools().front()->isValid()) {
m_network->connect();
}
const int r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); const int r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
uv_loop_close(uv_default_loop()); uv_loop_close(uv_default_loop());

View file

@ -41,4 +41,4 @@ void App::background()
: "\nBackground mode is not supported by %s on *nix Systems. Please use screen/tmux or systemd service instead.\n", : "\nBackground mode is not supported by %s on *nix Systems. Please use screen/tmux or systemd service instead.\n",
APP_NAME); APP_NAME);
} }
} }

View file

@ -328,8 +328,8 @@ Options::Options(int argc, char **argv) :
parseConfig(Platform::defaultConfigName()); parseConfig(Platform::defaultConfigName());
} }
if (!m_pools[0]->isValid()) { if (!m_pools[0]->isValid() && (!m_ccHost || m_ccPort == 0)) {
fprintf(stderr, "No pool URL supplied. Exiting.\n"); fprintf(stderr, "Neither pool nor CCServer URL supplied. Exiting.\n");
return; return;
} }

View file

@ -22,6 +22,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <chrono>
#include <cstring> #include <cstring>
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
@ -39,6 +40,7 @@
uv_mutex_t Service::m_mutex; uv_mutex_t Service::m_mutex;
std::map<std::string, ControlCommand> Service::m_clientCommand; std::map<std::string, ControlCommand> Service::m_clientCommand;
std::map<std::string, ClientStatus> Service::m_clientStatus; std::map<std::string, ClientStatus> Service::m_clientStatus;
int Service::m_currentServerTime = 0;
bool Service::start() bool Service::start()
{ {
@ -195,6 +197,10 @@ unsigned Service::getClientStatusList(std::string& resp)
clientStatusList.PushBack(clientStatusEntry, allocator); clientStatusList.PushBack(clientStatusEntry, allocator);
} }
auto time_point = std::chrono::system_clock::now();
m_currentServerTime = std::chrono::system_clock::to_time_t(time_point);
document.AddMember("current_server_time", m_currentServerTime, allocator);
document.AddMember("current_version", rapidjson::StringRef(Version::string().c_str()), allocator); document.AddMember("current_version", rapidjson::StringRef(Version::string().c_str()), allocator);
document.AddMember("client_status_list", clientStatusList, allocator); document.AddMember("client_status_list", clientStatusList, allocator);

View file

@ -58,6 +58,8 @@ private:
static std::string getClientConfigFileName(const Options *options, const std::string &clientId); static std::string getClientConfigFileName(const Options *options, const std::string &clientId);
private: private:
static int m_currentServerTime;
static std::map<std::string, ClientStatus> m_clientStatus; static std::map<std::string, ClientStatus> m_clientStatus;
static std::map<std::string, ControlCommand> m_clientCommand; static std::map<std::string, ControlCommand> m_clientCommand;

View file

@ -32,7 +32,7 @@
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#else #else
#include <sys/wait.h> #include <sys/wait.h>
#endif #endif
int main(int argc, char **argv) { int main(int argc, char **argv) {
@ -49,7 +49,7 @@ int main(int argc, char **argv) {
std::string xmrigMinerPath = ownPath.substr(0, pos+1) + xmrigMiner; std::string xmrigMinerPath = ownPath.substr(0, pos+1) + xmrigMiner;
#ifdef WIN32 #if defined(_WIN32) || defined(WIN32)
xmrigMinerPath = "\"" + xmrigMinerPath + "\""; xmrigMinerPath = "\"" + xmrigMinerPath + "\"";
#endif #endif
@ -64,7 +64,7 @@ int main(int argc, char **argv) {
do { do {
status = system(xmrigMinerPath.c_str()); status = system(xmrigMinerPath.c_str());
#ifdef WIN32 #if defined(_WIN32) || defined(WIN32)
} while (status == EINTR); } while (status == EINTR);
if (status == EINVAL) { if (status == EINVAL) {