Be a bit more robust when bots are hitting us
This commit is contained in:
parent
02551ac093
commit
08a7017fa7
1 changed files with 10 additions and 1 deletions
11
bbs_math.lua
11
bbs_math.lua
|
|
@ -109,7 +109,16 @@ end
|
|||
-- string.find(): %d+ represents 'digits, one or more'.
|
||||
-- Wrapping that in (..) captures the first instance into the 'res'
|
||||
-- variable (the two '_' variables are throwaways).
|
||||
local _,_,res = string.find(data, "(%d+)")
|
||||
local res, _
|
||||
if data ~= nil then
|
||||
-- Only do all this if there are actual data to be read.
|
||||
_,_,res = string.find(data, "(%d+)")
|
||||
else
|
||||
-- Not sure if we should be polite here; it'll usually either be
|
||||
-- network scans (benign or not) or script kiddies hitting..
|
||||
ngx.say("\r\n\rSomething went wrong and no data was received.\r\n\r")
|
||||
ngx.exit(400)
|
||||
end
|
||||
|
||||
-- Compare the given answer to our precomputed one. Make sure the answer is
|
||||
-- cast into a number, otherwise the comparison will fail.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue