Skip to content

Commit

Permalink
Merge pull request #670 from gavinandresen/rpcauth_speedup
Browse files Browse the repository at this point in the history
Speed up RPC authentication (reworked pull from Joel Katz)
  • Loading branch information
gavinandresen committed Dec 1, 2011
2 parents 43f20bb + f81ce5b commit 173efb1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/bitcoinrpc.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

//
Expand Down Expand Up @@ -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"))
Expand Down

0 comments on commit 173efb1

Please sign in to comment.