does_header_has added to block tor scanner
This commit is contained in:
parent
e20d4e113b
commit
4a856bc6f2
14
main.cpp
14
main.cpp
|
@ -115,8 +115,16 @@ int main(int ac, const char* av[]) {
|
|||
});
|
||||
|
||||
CROW_ROUTE(app, "/block/<uint>")
|
||||
([&](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/<string>")
|
||||
|
@ -129,8 +137,6 @@ int main(int ac, const char* av[]) {
|
|||
return crow::response(400);;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return crow::response(xmrblocks.show_block(block_hash));
|
||||
});
|
||||
|
||||
|
|
10
src/page.h
10
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue