Fix bad implementation of request header forwarding

Optimize performance.
This commit is contained in:
Tindy X
2020-07-09 00:41:46 +08:00
parent 73ff6b9716
commit fe62622123
2 changed files with 5 additions and 8 deletions

View File

@@ -1919,7 +1919,7 @@ void explodeSub(std::string sub, bool sslibev, bool ssrlibev, const std::string
nodeInfo node;
//try to parse as SSD configuration
if(strFind(sub, "ssd://"))
if(startsWith(sub, "ssd://"))
{
explodeSSD(sub, sslibev, custom_port, nodes);
processed = true;

View File

@@ -32,7 +32,7 @@ struct responseRoute
std::vector<responseRoute> responses;
string_map redirect_map;
const char *request_header_whitelist[] = {"user-agent"};
const char *request_header_blacklist[] = {"host", "user-agent", "accept", "accept-encoding"};
static inline void buffer_cleanup(struct evbuffer *eb)
{
@@ -124,12 +124,9 @@ void OnReq(evhttp_request *req, void *args)
struct evkeyval* kv = req->input_headers->tqh_first;
while (kv)
{
for(auto &x : request_header_whitelist)
{
if(strcmp(kv->key, x) == 0)
request.headers.emplace(kv->key, kv->value);
kv = kv->next.tqe_next;
}
if(std::none_of(std::begin(request_header_blacklist), std::end(request_header_blacklist), [&](auto x){ return strcasecmp(kv->key, x) == 0; }))
request.headers.emplace(kv->key, kv->value);
kv = kv->next.tqe_next;
}
if(user_agent)
request.headers.emplace("X-User-Agent", user_agent);