mirror of
https://git.wownero.com/wownero/onion-wownero-blockchain-explorer.git
synced 2024-08-15 00:33:12 +00:00
does_header_has added to block tor scanner
This commit is contained in:
parent
e20d4e113b
commit
4a856bc6f2
2 changed files with 18 additions and 6 deletions
14
main.cpp
14
main.cpp
|
@ -115,8 +115,16 @@ int main(int ac, const char* av[]) {
|
||||||
});
|
});
|
||||||
|
|
||||||
CROW_ROUTE(app, "/block/<uint>")
|
CROW_ROUTE(app, "/block/<uint>")
|
||||||
([&](size_t block_height) {
|
([&](const crow::request& req, size_t block_height) {
|
||||||
return xmrblocks.show_block(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>")
|
CROW_ROUTE(app, "/block/<string>")
|
||||||
|
@ -129,8 +137,6 @@ int main(int ac, const char* av[]) {
|
||||||
return crow::response(400);;
|
return crow::response(400);;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return crow::response(xmrblocks.show_block(block_hash));
|
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
|
string
|
||||||
does_header_has(const crow::request& req,
|
does_header_has(const crow::request& req,
|
||||||
const string& field = "Accept",
|
const string& field = "Accept",
|
||||||
|
@ -71,8 +79,6 @@ namespace xmreg {
|
||||||
{
|
{
|
||||||
if (accept.find(value) != std::string::npos)
|
if (accept.find(value) != std::string::npos)
|
||||||
{
|
{
|
||||||
cout << value << " found" << endl;
|
|
||||||
|
|
||||||
return accept;
|
return accept;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue