Skip to content

Commit e15925d

Browse files
authored
Bump v1.0.9 (#69)
* update the lua lib to v1.0.7 * ensure proper initialization * bump v1.0.9 * revert formatting change
1 parent c7a29ec commit e15925d

File tree

7 files changed

+39
-7
lines changed

7 files changed

+39
-7
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ RUN luarocks install lua-resty-http
44

55
FROM with_deps as git
66
ARG BUILD_ENV=git
7-
ARG LUA_LIB_VERSION=v1.0.0
7+
ARG LUA_LIB_VERSION=v1.0.9
88
RUN if [ "$BUILD_ENV" == "git" ]; then apk add --no-cache git; fi
99
RUN if [ "$BUILD_ENV" == "git" ]; then git clone -b "${LUA_LIB_VERSION}" https://github.com/crowdsecurity/lua-cs-bouncer.git ; fi
1010

Dockerfile.lua-bouncer-plugin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ARG BUILD_ENV=git
22

33
FROM docker.io/alpine:latest as git
44
ARG BUILD_ENV=git
5-
ARG LUA_LIB_VERSION=v1.0.1
5+
ARG LUA_LIB_VERSION=v1.0.9
66
RUN if [ "$BUILD_ENV" == "git" ]; then apk add --no-cache git; fi
77
RUN if [ "$BUILD_ENV" == "git" ]; then git clone -b "${LUA_LIB_VERSION}" https://github.com/crowdsecurity/lua-cs-bouncer.git ; fi
88

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ LUA_DIR="${OUTDIR}lua"
44
CONFIG_DIR="${OUTDIR}config"
55
TEMPLATE_DIR="${OUTDIR}templates"
66
OUT_ARCHIVE="crowdsec-openresty-bouncer.tgz"
7-
LUA_BOUNCER_BRANCH?=v1.0.1
7+
LUA_BOUNCER_BRANCH?=v1.0.9
88
default: release
99
release:
1010
git clone -b "${LUA_BOUNCER_BRANCH}" https://github.com/crowdsecurity/lua-cs-bouncer.git

debian/rules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
export DEB_VERSION=$(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
44
export BUILD_VERSION=v${DEB_VERSION}-debian-pragmatic
5-
export LUA_BOUNCER_BRANCH?=v1.0.1
5+
export LUA_BOUNCER_BRANCH?=v1.0.9
66

77
%:
88
dh $@

ingress-nginx/main.lua

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,30 @@ local cs = require "plugins.crowdsec.crowdsec"
22
local ngx = ngx
33

44
local _M = {}
5-
local ok, err = cs.init("/etc/nginx/lua/plugins/crowdsec/crowdsec-bouncer.conf", "crowdsec-openresty-bouncer/v1.0.4")
5+
local ok, err = cs.init("/etc/nginx/lua/plugins/crowdsec/crowdsec-bouncer.conf", "crowdsec-openresty-bouncer/v1.1.0")
66
if ok == nil then
77
ngx.log(ngx.ERR, "[Crowdsec] " .. err)
88
error()
99
end
1010
ngx.log(ngx.ALERT, "[Crowdsec] Initialisation done")
1111

12+
function _M.init_worker()
13+
-- This function is called once per worker
14+
-- It can be used to initialize the worker
15+
-- For example, to load the configuration file
16+
local mode = cs.get_mode()
17+
if string.lower(mode) == "stream" then
18+
ngx.log(ngx.INFO, "Initializing stream mode for worker " .. tostring(ngx.worker.id()))
19+
cs.SetupStream()
20+
end
21+
22+
if ngx.worker.id() == 0 then
23+
cs.SetupMetrics()
24+
end
25+
ngx.log(ngx.INFO, "Crowdsec bouncer initialized in " .. mode .. " mode for worker " .. tostring(ngx.worker.id()))
26+
end
27+
28+
1229
function _M.rewrite()
1330
cs.Allow(ngx.var.remote_addr)
1431
end

openresty/crowdsec_openresty.conf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ lua_ssl_trusted_certificate ${SSL_CERTS_PATH};
44

55
init_by_lua_block {
66
cs = require "crowdsec"
7-
local ok, err = cs.init("/etc/crowdsec/bouncers/crowdsec-openresty-bouncer.conf", "crowdsec-openresty-bouncer/v1.0.4")
7+
local ok, err = cs.init("/etc/crowdsec/bouncers/crowdsec-openresty-bouncer.conf", "crowdsec-openresty-bouncer/v1.1.0")
88
if ok == nil then
99
ngx.log(ngx.ERR, "[Crowdsec] " .. err)
1010
error()
@@ -29,3 +29,18 @@ access_by_lua_block {
2929
cs.Allow(ngx.var.remote_addr)
3030
end
3131
}
32+
33+
34+
init_worker_by_lua_block {
35+
cs = require "crowdsec"
36+
local mode = cs.get_mode()
37+
if string.lower(mode) == "stream" then
38+
ngx.log(ngx.INFO, "Initializing stream mode for worker " .. tostring(ngx.worker.id()))
39+
cs.SetupStream()
40+
end
41+
42+
if ngx.worker.id() == 0 then
43+
ngx.log(ngx.INFO, "Initializing metrics for worker " .. tostring(ngx.worker.id()))
44+
cs.SetupMetrics()
45+
end
46+
}

rpm/SPECS/crowdsec-openresty-bouncer.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ mkdir -p %{buildroot}/usr/local/openresty/nginx/conf/conf.d/
3333
mkdir -p %{buildroot}/usr/local/openresty/lualib/plugins/crowdsec/
3434
mkdir -p %{buildroot}/var/lib/crowdsec/lua/templates/
3535
mkdir -p %{buildroot}/etc/crowdsec/bouncers/
36-
git clone -b v1.0.1 https://github.com/crowdsecurity/lua-cs-bouncer.git
36+
git clone -b v1.0.9 https://github.com/crowdsecurity/lua-cs-bouncer.git
3737
install -m 600 -D lua-cs-bouncer/config_example.conf %{buildroot}/etc/crowdsec/bouncers/%{name}.conf
3838
install -m 644 -D lua-cs-bouncer/lib/crowdsec.lua %{buildroot}/usr/local/openresty/lualib/
3939
install -m 644 -D lua-cs-bouncer/lib/plugins/crowdsec/* %{buildroot}/usr/local/openresty/lualib/plugins/crowdsec/

0 commit comments

Comments
 (0)