antibot - fix path for templates and data
This commit is contained in:
parent
a0f8cbdac1
commit
e7ee21cbb5
@ -4,19 +4,19 @@ local base64 = require "misc.base64"
|
||||
|
||||
function M.get_challenge ()
|
||||
local cap = captcha.new()
|
||||
cap:font("/usr/local/lib/lua/misc/Vera.ttf")
|
||||
cap:font("/opt/bunkerized-nginx/lua/misc/Vera.ttf")
|
||||
cap:generate()
|
||||
return cap:jpegStr(70), cap:getStr()
|
||||
end
|
||||
|
||||
function M.get_code (img, antibot_uri)
|
||||
-- get template
|
||||
local f = io.open("/antibot/captcha.html", "r")
|
||||
local f = io.open("/opt/bunkerized-nginx/antibot/captcha.html", "r")
|
||||
local template = f:read("*all")
|
||||
f:close()
|
||||
|
||||
-- get captcha code
|
||||
f = io.open("/antibot/captcha.data", "r")
|
||||
f = io.open("/opt/bunkerized-nginx/antibot/captcha.data", "r")
|
||||
local captcha_data = f:read("*all")
|
||||
f:close()
|
||||
|
||||
|
||||
@ -15,12 +15,12 @@ end
|
||||
|
||||
function M.get_code (challenge, antibot_uri, original_uri)
|
||||
-- get template
|
||||
local f = io.open("/antibot/javascript.html", "r")
|
||||
local f = io.open("/opt/bunkerized-nginx/antibot/javascript.html", "r")
|
||||
local template = f:read("*all")
|
||||
f:close()
|
||||
|
||||
-- get JS code
|
||||
f = io.open("/antibot/javascript.data", "r")
|
||||
f = io.open("/opt/bunkerized-nginx/antibot/javascript.data", "r")
|
||||
local javascript = f:read("*all")
|
||||
f:close()
|
||||
|
||||
@ -32,14 +32,11 @@ function M.get_code (challenge, antibot_uri, original_uri)
|
||||
end
|
||||
|
||||
function M.check (challenge, user)
|
||||
ngx.log(ngx.ERR, "debug challenge = " .. challenge)
|
||||
ngx.log(ngx.ERR, "debug user = " .. user)
|
||||
local resty_sha256 = require "resty.sha256"
|
||||
local str = require "resty.string"
|
||||
local sha256 = resty_sha256:new()
|
||||
sha256:update(challenge .. user)
|
||||
local digest = sha256:final()
|
||||
ngx.log(ngx.ERR, "debug digest = " .. str.to_hex(digest))
|
||||
return str.to_hex(digest):find("^0000") ~= nil
|
||||
end
|
||||
|
||||
|
||||
@ -4,15 +4,15 @@ local cjson = require "cjson"
|
||||
|
||||
function M.get_code (antibot_uri, recaptcha_sitekey)
|
||||
-- get template
|
||||
local f = io.open("/antibot/recaptcha.html", "r")
|
||||
local f = io.open("/opt/bunkerized-nginx/antibot/recaptcha.html", "r")
|
||||
local template = f:read("*all")
|
||||
f:close()
|
||||
|
||||
-- get recaptcha code
|
||||
f = io.open("/antibot/recaptcha-head.data", "r")
|
||||
f = io.open("/opt/bunkerized-nginx/antibot/recaptcha-head.data", "r")
|
||||
local recaptcha_head = f:read("*all")
|
||||
f:close()
|
||||
f = io.open("/antibot/recaptcha-body.data", "r")
|
||||
f = io.open("/opt/bunkerized-nginx/antibot/recaptcha-body.data", "r")
|
||||
local recaptcha_body = f:read("*all")
|
||||
f:close()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user