From da967ced1bdf8f5ecba1b16ae6b5f7a950a3aa0d Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 22 Mar 2018 17:45:47 +0700 Subject: [PATCH] Add IP address to accepted and rejected shares in proxy output. --- CMakeLists.txt | 1 + src/log/ShareLog.cpp | 17 ++++++++-------- src/log/ShareLog.h | 4 ++-- src/proxy/events/MinerEvent.cpp | 35 +++++++++++++++++++++++++++++++++ src/proxy/events/MinerEvent.h | 7 +++++-- 5 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 src/proxy/events/MinerEvent.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e96317..665cf5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,6 +109,7 @@ set(SOURCES src/proxy/Events.cpp src/proxy/events/ConnectionEvent.h src/proxy/events/Event.cpp + src/proxy/events/MinerEvent.cpp src/proxy/JobResult.cpp src/proxy/LoginRequest.cpp src/proxy/Miner.cpp diff --git a/src/log/ShareLog.cpp b/src/log/ShareLog.cpp index 218b905..38b625f 100644 --- a/src/log/ShareLog.cpp +++ b/src/log/ShareLog.cpp @@ -4,8 +4,8 @@ * Copyright 2014 Lucas Jones * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee - * Copyright 2016-2018 XMRig - * + * Copyright 2017-2018 XMR-Stak , + * Copyright 2016-2018 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ #include "log/ShareLog.h" #include "net/SubmitResult.h" #include "proxy/events/AcceptEvent.h" +#include "proxy/Miner.h" #include "proxy/Stats.h" @@ -86,9 +87,9 @@ void ShareLog::accept(const AcceptEvent *event) return; } - LOG_INFO(isColors() ? "#%03u \x1B[01;32maccepted\x1B[0m (%" PRId64 "/%" PRId64 "+%" PRId64 ") diff \x1B[01;37m%u\x1B[0m \x1B[01;30m(%" PRIu64 " ms)" - : "#%03u accepted (%" PRId64 "/%" PRId64 "+%" PRId64 ") diff %u (%" PRIu64 " ms)", - event->mapperId(), m_stats.data().accepted, m_stats.data().rejected, m_stats.data().invalid, event->result.diff, event->result.elapsed); + LOG_INFO(isColors() ? "#%03u \x1B[01;32maccepted\x1B[0m (%" PRId64 "/%" PRId64 "+%" PRId64 ") diff \x1B[01;37m%u\x1B[0m ip \x1B[01;37m%s \x1B[01;30m(%" PRIu64 " ms)" + : "#%03u accepted (%" PRId64 "/%" PRId64 "+%" PRId64 ") diff %u ip %s (%" PRIu64 " ms)", + event->mapperId(), m_stats.data().accepted, m_stats.data().rejected, m_stats.data().invalid, event->result.diff, event->ip(), event->result.elapsed); } @@ -98,7 +99,7 @@ void ShareLog::reject(const AcceptEvent *event) return; } - LOG_INFO(isColors() ? "#%03u \x1B[01;31mrejected\x1B[0m (%" PRId64 "/%" PRId64 "+%" PRId64 ") diff \x1B[01;37m%u\x1B[0m \x1B[31m\"%s\"\x1B[0m \x1B[01;30m(%" PRId64 " ms)" - : "#%03u rejected (%" PRId64 "/%" PRId64 "+%" PRId64 ") diff %u \"%s\" (%" PRId64 " ms)", - event->mapperId(), m_stats.data().accepted, m_stats.data().rejected, m_stats.data().invalid, event->result.diff, event->error(), event->result.elapsed); + LOG_INFO(isColors() ? "#%03u \x1B[01;31mrejected\x1B[0m (%" PRId64 "/%" PRId64 "+%" PRId64 ") diff \x1B[01;37m%u\x1B[0m ip \x1B[01;37m%s \x1B[31m\"%s\"\x1B[0m \x1B[01;30m(%" PRId64 " ms)" + : "#%03u rejected (%" PRId64 "/%" PRId64 "+%" PRId64 ") diff %u ip %s \"%s\" (%" PRId64 " ms)", + event->mapperId(), m_stats.data().accepted, m_stats.data().rejected, m_stats.data().invalid, event->result.diff, event->ip(), event->error(), event->result.elapsed); } diff --git a/src/log/ShareLog.h b/src/log/ShareLog.h index 8002d77..95c29c5 100644 --- a/src/log/ShareLog.h +++ b/src/log/ShareLog.h @@ -4,8 +4,8 @@ * Copyright 2014 Lucas Jones * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee - * Copyright 2016-2018 XMRig - * + * Copyright 2017-2018 XMR-Stak , + * Copyright 2016-2018 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/proxy/events/MinerEvent.cpp b/src/proxy/events/MinerEvent.cpp new file mode 100644 index 0000000..6a8a9d7 --- /dev/null +++ b/src/proxy/events/MinerEvent.cpp @@ -0,0 +1,35 @@ +/* XMRig + * Copyright 2010 Jeff Garzik + * Copyright 2012-2014 pooler + * Copyright 2014 Lucas Jones + * Copyright 2014-2016 Wolf9466 + * Copyright 2016 Jay D Dee + * Copyright 2017-2018 XMR-Stak , + * Copyright 2016-2018 XMRig , + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +#include "proxy/events/MinerEvent.h" +#include "proxy/Miner.h" + + +static const char *kDefaultIP = "0.0.0.0"; + + +const char *MinerEvent::ip() const +{ + return m_miner ? m_miner->ip() : kDefaultIP; +} diff --git a/src/proxy/events/MinerEvent.h b/src/proxy/events/MinerEvent.h index 4a5fe5b..9c536fc 100644 --- a/src/proxy/events/MinerEvent.h +++ b/src/proxy/events/MinerEvent.h @@ -4,8 +4,8 @@ * Copyright 2014 Lucas Jones * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee - * Copyright 2016-2017 XMRig - * + * Copyright 2017-2018 XMR-Stak , + * Copyright 2016-2018 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,6 +34,9 @@ class Miner; class MinerEvent : public Event { public: + const char *ip() const; + + inline Miner *miner() const { return m_miner; }