Skip to content

Commit

Permalink
CF-Connecting-IP
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Aug 25, 2024
1 parent bae3e91 commit d6a6bbd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -390,14 +390,19 @@ static const std::string realIp(ws28::HTTPRequest &req) {
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;
}

static void connect_callback(ws28::Client *client, ws28::HTTPRequest &req) {
auto ip = realIp(req);
char *p = new char[ip.length()+1];
char *p = new char[ip.length() + 1];
std::strcpy(p, ip.c_str());
client->SetUserData(p);
spdlog::debug("CONNECTED {}", ip);
Expand Down

0 comments on commit d6a6bbd

Please sign in to comment.