"ddos challenge" style script #4

Open
luna wants to merge 20 commits from claude/ddos-protection-challenge-01CMAtrK6Dt24x9Q3v6Gz9fS into mistress
Showing only changes of commit 2cbf796aef - Show all commits

View file

@ -406,7 +406,7 @@ local function computeValidNonce(challenge, difficulty)
local str = require("resty.string") local str = require("resty.string")
local required_zeros = string.rep("0", difficulty) local required_zeros = string.rep("0", difficulty)
for nonce = 0, 1000000 do for nonce = 0, 150 do
local sha256 = resty_sha256:new() local sha256 = resty_sha256:new()
sha256:update(challenge .. tostring(nonce)) sha256:update(challenge .. tostring(nonce))
local digest = sha256:final() local digest = sha256:final()
@ -417,7 +417,7 @@ local function computeValidNonce(challenge, difficulty)
end end
end end
error("Could not find valid nonce after 1M attempts") error("Could not find valid nonce after 150 attempts")
end end
-- Tests for proof-of-work challenge type -- Tests for proof-of-work challenge type