mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-01 17:25:02 +00:00
Fix a potential loop request bug which may cause server to overload
This commit is contained in:
2 files changed
+9
-1
No files matched your search
+1
-1
@@ -8,7 +8,7 @@
|
||||
extern bool print_debug_info;
|
||||
|
||||
//std::string user_agent_str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36";
|
||||
static std::string user_agent_str = "subconverter/latest cURL/7.xx-DEV";
|
||||
std::string user_agent_str = "subconverter/latest cURL/7.xx-DEV";
|
||||
|
||||
static int writer(char *data, size_t size, size_t nmemb, std::string *writerData)
|
||||
{
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include "webserver.h"
|
||||
#include "socket.h"
|
||||
|
||||
extern std::string user_agent_str;
|
||||
|
||||
struct responseRoute
|
||||
{
|
||||
std::string method;
|
||||
@@ -76,6 +78,12 @@ void OnReq(evhttp_request *req, void *args)
|
||||
int retVal;
|
||||
std::string postdata, content_type, return_data;
|
||||
|
||||
if(user_agent_str.compare(evhttp_find_header(req->input_headers, "User-Agent")) == 0)
|
||||
{
|
||||
evhttp_send_error(req, 500, "Loop request detected!");
|
||||
return;
|
||||
}
|
||||
|
||||
if(EVBUFFER_LENGTH(req->input_buffer) != 0)
|
||||
{
|
||||
postdata.assign((char *)EVBUFFER_DATA(req->input_buffer), EVBUFFER_LENGTH(req->input_buffer));
|
||||
|
||||
Reference in new issue
Block a user