diff --git a/lib/plugins/crowdsec/live.lua b/lib/plugins/crowdsec/live.lua index b048f01..1eaa633 100644 --- a/lib/plugins/crowdsec/live.lua +++ b/lib/plugins/crowdsec/live.lua @@ -8,11 +8,6 @@ live.cache = ngx.shared.crowdsec_cache --- Create a new live object -- Create a new live object to query the live API --- @param api_url string: the URL of the live API --- @param cache_expiration number: the expiration time of the cache --- @param bouncing_on_type string: the type of decision to bounce on --- @param time_out number: the time out of the http lapi request --- @param api_key_header string: the header to use for the API key -- @return live: the live object function live:new() diff --git a/lib/plugins/crowdsec/stream.lua b/lib/plugins/crowdsec/stream.lua index e9feacf..962553b 100644 --- a/lib/plugins/crowdsec/stream.lua +++ b/lib/plugins/crowdsec/stream.lua @@ -6,6 +6,8 @@ local stream = {} stream.__index = stream stream.cache = ngx.shared.crowdsec_cache +--- Get the number of decisions in the cache for each origin +--- return a table with the origin as key and the number of decisions as value local function get_decisions_count() local table_count = {} local keys = stream.cache:get_keys(0) @@ -46,6 +48,10 @@ local function set_refreshing(value) end end +--- Parse a golang duration string and return the number of seconds +--- @param duration string: the duration string to parse +--- @return number: the number of seconds +--- @return string: the error message if any local function parse_duration(duration) local match, err = ngx.re.match(duration, "^((?<hours>[0-9]+)h)?((?<minutes>[0-9]+)m)?(?<seconds>[0-9]+)") local ttl = 0