Short-time ban for unauthorized miners to prevent potential validateaddress RPC DDos
@@ -122,10 +122,23 @@ namespace MiningCore.Blockchain.Bitcoin
// respond
client.Respond(context.IsAuthorized, request.Id);
+ if (context.IsAuthorized)
+ {
// log association
logger.Info(() => $"[{LogCat}] [{client.ConnectionId}] = {workerValue} = {client.RemoteEndpoint.Address}");
}
+ else
+ {
+ // issue short-time ban if unauthorized to prevent DDos on daemon (validateaddress RPC)
+ logger.Info(() => $"[{LogCat}] [{client.ConnectionId}] Banning unauthorized worker for 60 sec");
+
+ banManager.Ban(client.RemoteEndpoint.Address, TimeSpan.FromSeconds(60));
+
+ DisconnectClient(client);
+ }
+ }
+
protected virtual async Task OnSubmitAsync(StratumClient client, Timestamped<JsonRpcRequest> tsRequest)
{
var request = tsRequest.Value;
