From: Gavin Andresen Date: Thu, 1 Dec 2011 14:07:02 +0000 (-0500) Subject: Speed up RPC authentication (reworked pull from Joel Katz) X-Git-Tag: v0.4.0-unstable~226^2~11^2 X-Git-Url: https://git.novaco.in/?a=commitdiff_plain;h=f81ce5bd6d1008f245a57cb4a1b3c102bacaf530;hp=a7120a3647b17878914da0b40655edcc5a9da59f;p=novacoin.git Speed up RPC authentication (reworked pull from Joel Katz) --- diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 317f6e6..bb8d8e2 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -36,6 +36,8 @@ void ThreadRPCServer2(void* parg); typedef Value(*rpcfn_type)(const Array& params, bool fHelp); extern map mapCallTable; +static std::string strRPCUserColonPass; + static int64 nWalletUnlockTime; static CCriticalSection cs_nWalletUnlockTime; @@ -2023,12 +2025,7 @@ bool HTTPAuthorized(map& mapHeaders) return false; string strUserPass64 = strAuth.substr(6); boost::trim(strUserPass64); string strUserPass = DecodeBase64(strUserPass64); - string::size_type nColon = strUserPass.find(":"); - if (nColon == string::npos) - return false; - string strUser = strUserPass.substr(0, nColon); - string strPassword = strUserPass.substr(nColon+1); - return (strUser == mapArgs["-rpcuser"] && strPassword == mapArgs["-rpcpassword"]); + return strUserPass == strRPCUserColonPass; } // @@ -2161,7 +2158,8 @@ void ThreadRPCServer2(void* parg) { printf("ThreadRPCServer started\n"); - if (mapArgs["-rpcuser"] == "" && mapArgs["-rpcpassword"] == "") + strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"]; + if (strRPCUserColonPass == ":") { string strWhatAmI = "To use bitcoind"; if (mapArgs.count("-server"))