Move the RealIpResolver plugin to the PreRouting join point (#1904)

This commit is contained in:
An Tao 2024-01-16 11:18:13 +08:00 committed by GitHub
parent 6b36b3a4f9
commit d745cfe765
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,7 +106,7 @@ void RealIpResolver::initAndStart(const Json::Value &config)
trustCIDRs_.emplace_back(ipOrCidr);
}
drogon::app().registerPreHandlingAdvice([this](const HttpRequestPtr &req) {
drogon::app().registerPreRoutingAdvice([this](const HttpRequestPtr &req) {
const std::string &ipHeader = req->getHeader(fromHeader_);
const trantor::InetAddress &peerAddr = req->getPeerAddr();
if (ipHeader.empty() || !matchCidr(peerAddr))