Skip to content

Commit

Permalink
use lower-case
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Aug 25, 2024
1 parent 8d3b7ef commit 7ba4408
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -383,21 +383,13 @@ static void http_request_callback(ws28::HTTPRequest &req,

static const std::string realIp(ws28::HTTPRequest &req) {
std::string ip{req.ip};
req.headers.ForEach([](const std::string_view k, const std::string_view v) {
spdlog::debug("DEBUG {}:{}", k, v);
});
auto value = req.headers.Get("X-Forwarded-For");
auto value = req.headers.Get("x-forwarded-for");
if (value.has_value()) {
ip = value.value(); // possible to be multiple comma separated
} else {
value = req.headers.Get("X-Real-Ip");
value = req.headers.Get("x-real-ip");
if (value.has_value()) {
ip = value.value();
} else {
value = req.headers.Get("CF-Connecting-IP");
if (value.has_value()) {
ip = value.value();
}
}
}
return ip;
Expand Down

0 comments on commit 7ba4408

Please sign in to comment.