aboutsummaryrefslogtreecommitdiff
path: root/src/rpc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpc.cpp')
-rw-r--r--src/rpc.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/rpc.cpp b/src/rpc.cpp
index f2a0db0fc4..6f951b7431 100644
--- a/src/rpc.cpp
+++ b/src/rpc.cpp
@@ -1537,7 +1537,7 @@ string rfc1123Time()
return string(buffer);
}
-string HTTPReply(int nStatus, const string& strMsg)
+static string HTTPReply(int nStatus, const string& strMsg)
{
if (nStatus == 401)
return strprintf("HTTP/1.0 401 Authorization Required\r\n"
@@ -1559,6 +1559,7 @@ string HTTPReply(int nStatus, const string& strMsg)
string strStatus;
if (nStatus == 200) strStatus = "OK";
else if (nStatus == 400) strStatus = "Bad Request";
+ else if (nStatus == 403) strStatus = "Forbidden";
else if (nStatus == 404) strStatus = "Not Found";
else if (nStatus == 500) strStatus = "Internal Server Error";
return strprintf(
@@ -1892,7 +1893,12 @@ void ThreadRPCServer2(void* parg)
// Restrict callers by IP
if (!ClientAllowed(peer.address().to_string()))
+ {
+ // Only send a 403 if we're not using SSL to prevent a DoS during the SSL handshake.
+ if (!fUseSSL)
+ stream << HTTPReply(403, "") << std::flush;
continue;
+ }
map<string, string> mapHeaders;
string strRequest;