diff --git a/main.cpp b/main.cpp index 90dce8b..51eb0e0 100644 --- a/main.cpp +++ b/main.cpp @@ -115,8 +115,16 @@ int main(int ac, const char* av[]) { }); CROW_ROUTE(app, "/block/") - ([&](size_t block_height) { - return xmrblocks.show_block(block_height); + ([&](const crow::request& req, size_t block_height) { + + // there is some robot scanning everything + // on the explorer. I block it with this + if (!xmreg::does_header_has(req, "Accept", "q=.2, */*; q=.2").empty()) + { + return crow::response(400); + } + + return crow::response(xmrblocks.show_block(block_height)); }); CROW_ROUTE(app, "/block/") @@ -129,8 +137,6 @@ int main(int ac, const char* av[]) { return crow::response(400);; } - - return crow::response(xmrblocks.show_block(block_hash)); }); diff --git a/src/page.h b/src/page.h index 0469c79..3e602e8 100644 --- a/src/page.h +++ b/src/page.h @@ -60,6 +60,14 @@ namespace xmreg { + /** + * Check if a given header filed contains value string + * + * @param req + * @param field + * @param value + * @return string + */ string does_header_has(const crow::request& req, const string& field = "Accept", @@ -71,8 +79,6 @@ namespace xmreg { { if (accept.find(value) != std::string::npos) { - cout << value << " found" << endl; - return accept; } }