Skip to content

Commit

Permalink
remote API - only do action if 403
Browse files Browse the repository at this point in the history
fl0ppy-d1sk committed Oct 24, 2021
1 parent 3850cac commit d43b82b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions confs/site/log-lua.conf
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ local use_remote_api = {% if USE_REMOTE_API == "yes" %}true{% else %}
local remoteapi = require "remoteapi"
local iputils = require "resty.iputils"

if use_remote_api and not iputils.ip_in_cidrs(ngx.var.remote_addr, cjson.decode(ngx.shared.reserved_ips:get("data"))) and ngx.shared.remote_api:get("id") ~= "empty" then
if use_remote_api and ngx.status == ngx.HTTP_FORBIDDEN and not iputils.ip_in_cidrs(ngx.var.remote_addr, cjson.decode(ngx.shared.reserved_ips:get("data"))) and ngx.shared.remote_api:get("id") ~= "empty" then
if ngx.shared.remote_api:get("ping") == "ko" then
if remoteapi.ping2() then
ngx.shared.remote_api:set("ping", "ok", 0)
@@ -32,7 +32,7 @@ if use_remote_api and not iputils.ip_in_cidrs(ngx.var.remote_addr, cjson.decode(
logger.log(ngx.ERR, "REMOTE API", "Can't contact the remote API, feature will be disabled")
end
end
if ngx.shared.remote_api:get("ping") ~= "ko" and ngx.status == ngx.HTTP_FORBIDDEN then
if ngx.shared.remote_api:get("ping") ~= "ko" then
local reason = "other"
if use_bad_behavior and new_bad_behavior_ban then
reason = "behavior"

0 comments on commit d43b82b

Please sign in to comment.