Skip to content

Commit

Permalink
better function docuemntation
Browse files Browse the repository at this point in the history
  • Loading branch information
sabban committed Oct 7, 2024
1 parent 88b7efe commit 4349ac4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 0 additions & 5 deletions lib/plugins/crowdsec/live.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions lib/plugins/crowdsec/stream.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4349ac4

Please sign in to comment.