From ecba750442ce2bbd411bcf874b4c214b6e234771 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sun, 20 Jun 2021 09:28:39 +0700 Subject: [PATCH] Add token support for online benchmark. --- src/base/net/stratum/benchmark/BenchClient.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/base/net/stratum/benchmark/BenchClient.cpp b/src/base/net/stratum/benchmark/BenchClient.cpp index b5c343cd1..c66058505 100644 --- a/src/base/net/stratum/benchmark/BenchClient.cpp +++ b/src/base/net/stratum/benchmark/BenchClient.cpp @@ -61,7 +61,8 @@ xmrig::BenchClient::BenchClient(const std::shared_ptr &benchmark, I # ifdef XMRIG_FEATURE_HTTP if (m_benchmark->isSubmit()) { - m_mode = ONLINE_BENCH; + m_mode = ONLINE_BENCH; + m_token = m_benchmark->token(); return; } @@ -350,6 +351,11 @@ void xmrig::BenchClient::send(Request request) # endif FetchRequest req(HTTP_POST, m_ip, BenchConfig::kApiPort, "/1/benchmark", doc, BenchConfig::kApiTLS, true); + + if (!m_token.isEmpty()) { + req.headers.insert({ "Authorization", fmt::format("Bearer {}", m_token)}); + } + fetch(tag(), std::move(req), m_httpListener); } break;