mirror of
https://github.com/XRPLF/clio.git
synced 2026-06-18 16:16:52 +00:00
fix: Resolve proxy ip before processing any request (#3006)
This commit is contained in:
@@ -241,6 +241,16 @@ public:
|
||||
if (ec)
|
||||
return httpFail(ec, "read");
|
||||
|
||||
if (auto resolvedIp = proxyIpResolver_->resolveClientIp(clientIp_, req_);
|
||||
resolvedIp != clientIp_) {
|
||||
LOG(log_.info()) << tag()
|
||||
<< "Detected a forwarded request from proxy. Proxy ip: " << clientIp_
|
||||
<< ". Resolved client ip: " << resolvedIp;
|
||||
dosGuard_.get().decrement(clientIp_);
|
||||
clientIp_ = std::move(resolvedIp);
|
||||
dosGuard_.get().increment(clientIp_);
|
||||
}
|
||||
|
||||
if (req_.method() == http::verb::get and req_.target() == "/health")
|
||||
return sender_(httpResponse(http::status::ok, "text/html", kHEALTH_CHECK_HTML));
|
||||
|
||||
@@ -256,16 +266,6 @@ public:
|
||||
));
|
||||
}
|
||||
|
||||
if (auto resolvedIp = proxyIpResolver_->resolveClientIp(clientIp_, req_);
|
||||
resolvedIp != clientIp_) {
|
||||
LOG(log_.info()) << tag()
|
||||
<< "Detected a forwarded request from proxy. Proxy ip: " << clientIp_
|
||||
<< ". Resolved client ip: " << resolvedIp;
|
||||
dosGuard_.get().decrement(clientIp_);
|
||||
clientIp_ = std::move(resolvedIp);
|
||||
dosGuard_.get().increment(clientIp_);
|
||||
}
|
||||
|
||||
// Update isAdmin property of the connection
|
||||
ConnectionBase::isAdmin_ = adminVerification_->isAdmin(req_, clientIp_);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user