diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2011-12-01 13:01:59 -0800 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2011-12-01 13:01:59 -0800 |
commit | 173efb1865e271dede53bcdff7ee2e189df07aa4 (patch) | |
tree | 7a208a6826d127f130656a6538e69a4e7228543a /src | |
parent | 43f20bb3c2b2d0e6888f534ef339eada1affb3f9 (diff) | |
parent | f81ce5bd6d1008f245a57cb4a1b3c102bacaf530 (diff) |
Merge pull request #670 from gavinandresen/rpcauth_speedup
Speed up RPC authentication (reworked pull from Joel Katz)
Diffstat (limited to 'src')
-rw-r--r-- | src/bitcoinrpc.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 317f6e66dc..bb8d8e2d77 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<string, rpcfn_type> mapCallTable; +static std::string strRPCUserColonPass; + static int64 nWalletUnlockTime; static CCriticalSection cs_nWalletUnlockTime; @@ -2023,12 +2025,7 @@ bool HTTPAuthorized(map<string, string>& 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")) |