mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 13:32:33 +02:00
Merge #12778: RPC: Add username and ip logging for RPC method requests
4d74c78
Add username and ip logging for RPC method requests (Gabriel Davidian)
Pull request description:
Adds username and IP logging (if enabled via -logips command) to RPC method request logging.
This closes #12223
Tree-SHA512: a441228e80ea6884ec379c66e949d86df3689770f1b3c3608015cf5a36d2dfb38051298a7f6ea6dfdfbf0b3b6c896e414c8dc54e9833bb73dd65bdb1832f4395
This commit is contained in:
commit
b648974cc3
@ -158,8 +158,9 @@ static bool HTTPReq_JSONRPC(HTTPRequest* req, const std::string &)
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSONRPCRequest jreq;
|
JSONRPCRequest jreq;
|
||||||
|
jreq.peerAddr = req->GetPeer().ToString();
|
||||||
if (!RPCAuthorized(authHeader.second, jreq.authUser)) {
|
if (!RPCAuthorized(authHeader.second, jreq.authUser)) {
|
||||||
LogPrintf("ThreadRPCServer incorrect password attempt from %s\n", req->GetPeer().ToString());
|
LogPrintf("ThreadRPCServer incorrect password attempt from %s\n", jreq.peerAddr);
|
||||||
|
|
||||||
/* Deter brute-forcing
|
/* Deter brute-forcing
|
||||||
If this results in a DoS the user really
|
If this results in a DoS the user really
|
||||||
|
@ -367,7 +367,11 @@ void JSONRPCRequest::parse(const UniValue& valRequest)
|
|||||||
if (!valMethod.isStr())
|
if (!valMethod.isStr())
|
||||||
throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string");
|
throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string");
|
||||||
strMethod = valMethod.get_str();
|
strMethod = valMethod.get_str();
|
||||||
LogPrint(BCLog::RPC, "ThreadRPCServer method=%s\n", SanitizeString(strMethod));
|
if (fLogIPs)
|
||||||
|
LogPrint(BCLog::RPC, "ThreadRPCServer method=%s user=%s peeraddr=%s\n", SanitizeString(strMethod),
|
||||||
|
this->authUser, this->peerAddr);
|
||||||
|
else
|
||||||
|
LogPrint(BCLog::RPC, "ThreadRPCServer method=%s user=%s\n", SanitizeString(strMethod), this->authUser);
|
||||||
|
|
||||||
// Parse params
|
// Parse params
|
||||||
UniValue valParams = find_value(request, "params");
|
UniValue valParams = find_value(request, "params");
|
||||||
|
@ -45,6 +45,7 @@ public:
|
|||||||
bool fHelp;
|
bool fHelp;
|
||||||
std::string URI;
|
std::string URI;
|
||||||
std::string authUser;
|
std::string authUser;
|
||||||
|
std::string peerAddr;
|
||||||
|
|
||||||
JSONRPCRequest() : id(NullUniValue), params(NullUniValue), fHelp(false) {}
|
JSONRPCRequest() : id(NullUniValue), params(NullUniValue), fHelp(false) {}
|
||||||
void parse(const UniValue& valRequest);
|
void parse(const UniValue& valRequest);
|
||||||
|
Loading…
Reference in New Issue
Block a user