|
|
@ -40,6 +40,11 @@ namespace xmrig { |
|
|
|
static const char *kAuthorization = "authorization"; |
|
|
|
static const char *kContentType = "content-type"; |
|
|
|
|
|
|
|
#ifdef _WIN32 |
|
|
|
static const char *favicon = nullptr; |
|
|
|
static size_t faviconSize = 0; |
|
|
|
#endif |
|
|
|
|
|
|
|
} // namespace xmrig
|
|
|
|
|
|
|
|
|
|
|
@ -85,6 +90,17 @@ bool xmrig::Httpd::start() |
|
|
|
|
|
|
|
m_port = static_cast<uint16_t>(rc); |
|
|
|
|
|
|
|
# ifdef _WIN32 |
|
|
|
HRSRC src = FindResource(nullptr, MAKEINTRESOURCE(1), RT_ICON); |
|
|
|
if (src != nullptr) { |
|
|
|
HGLOBAL res = LoadResource(nullptr, src); |
|
|
|
if (res != nullptr) { |
|
|
|
favicon = static_cast<const char *>(LockResource(res)); |
|
|
|
faviconSize = SizeofResource(nullptr, src); |
|
|
|
} |
|
|
|
} |
|
|
|
# endif |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
@ -118,6 +134,19 @@ void xmrig::Httpd::onHttpRequest(const HttpRequest &req) |
|
|
|
return HttpApiResponse(req.id()).end(); |
|
|
|
} |
|
|
|
|
|
|
|
if (req.method == HTTP_GET && req.url == "/favicon.ico") { |
|
|
|
# ifdef _WIN32 |
|
|
|
if (favicon != nullptr) { |
|
|
|
HttpResponse response(req.id()); |
|
|
|
response.setHeader("Content-Type", "image/x-icon"); |
|
|
|
|
|
|
|
return response.end(favicon, faviconSize); |
|
|
|
} |
|
|
|
# endif |
|
|
|
|
|
|
|
return HttpResponse(req.id(), 404).end(); |
|
|
|
} |
|
|
|
|
|
|
|
if (req.method > 4) { |
|
|
|
return HttpApiResponse(req.id(), HTTP_STATUS_METHOD_NOT_ALLOWED).end(); |
|
|
|
} |
|
|
|