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 ()
|
function M.get_challenge ()
|
||||||
local cap = captcha.new()
|
local cap = captcha.new()
|
||||||
cap:font("/usr/local/lib/lua/misc/Vera.ttf")
|
cap:font("/opt/bunkerized-nginx/lua/misc/Vera.ttf")
|
||||||
cap:generate()
|
cap:generate()
|
||||||
return cap:jpegStr(70), cap:getStr()
|
return cap:jpegStr(70), cap:getStr()
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.get_code (img, antibot_uri)
|
function M.get_code (img, antibot_uri)
|
||||||
-- get template
|
-- 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")
|
local template = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- get captcha code
|
-- 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")
|
local captcha_data = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
|
|||||||
@ -15,12 +15,12 @@ end
|
|||||||
|
|
||||||
function M.get_code (challenge, antibot_uri, original_uri)
|
function M.get_code (challenge, antibot_uri, original_uri)
|
||||||
-- get template
|
-- 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")
|
local template = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- get JS code
|
-- 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")
|
local javascript = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
@ -32,14 +32,11 @@ function M.get_code (challenge, antibot_uri, original_uri)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.check (challenge, user)
|
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 resty_sha256 = require "resty.sha256"
|
||||||
local str = require "resty.string"
|
local str = require "resty.string"
|
||||||
local sha256 = resty_sha256:new()
|
local sha256 = resty_sha256:new()
|
||||||
sha256:update(challenge .. user)
|
sha256:update(challenge .. user)
|
||||||
local digest = sha256:final()
|
local digest = sha256:final()
|
||||||
ngx.log(ngx.ERR, "debug digest = " .. str.to_hex(digest))
|
|
||||||
return str.to_hex(digest):find("^0000") ~= nil
|
return str.to_hex(digest):find("^0000") ~= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -4,15 +4,15 @@ local cjson = require "cjson"
|
|||||||
|
|
||||||
function M.get_code (antibot_uri, recaptcha_sitekey)
|
function M.get_code (antibot_uri, recaptcha_sitekey)
|
||||||
-- get template
|
-- 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")
|
local template = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- get recaptcha code
|
-- 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")
|
local recaptcha_head = f:read("*all")
|
||||||
f:close()
|
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")
|
local recaptcha_body = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user