test
This commit is contained in:
@@ -33,6 +33,7 @@ COPY --from=build-stage /app/cs-custom-bouncer/crowdsec-custom-bouncer \
|
|||||||
/usr/bin/crowdsec-custom-bouncer
|
/usr/bin/crowdsec-custom-bouncer
|
||||||
COPY --from=build-stage /app/cs-custom-bouncer/config/crowdsec-custom-bouncer.yaml \
|
COPY --from=build-stage /app/cs-custom-bouncer/config/crowdsec-custom-bouncer.yaml \
|
||||||
/crowdsec-custom-bouncer.yaml
|
/crowdsec-custom-bouncer.yaml
|
||||||
|
RUN sed -i "s/total_retries: .*/total_retries: 1/g" /crowdsec-custom-bouncer.yaml
|
||||||
ADD --chmod=770 bouncer.sh /bouncer.sh
|
ADD --chmod=770 bouncer.sh /bouncer.sh
|
||||||
ENV BINARY_PATH=/bouncer.sh
|
ENV BINARY_PATH=/bouncer.sh
|
||||||
LABEL me.ar2000.gitea.buildargs.iptablesmode="${IPTABLES_MODE}"
|
LABEL me.ar2000.gitea.buildargs.iptablesmode="${IPTABLES_MODE}"
|
||||||
|
56
bouncer.sh
56
bouncer.sh
@@ -1,52 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
echo test >> /bouncer.stdin.out
|
||||||
# Script to add /remove IPs to iptables
|
while read line
|
||||||
|
do
|
||||||
[[ -n "${IPTABLES_COMMENT}" ]] && comment="-m comment --comment \"$4\"" || comment=""
|
echo "$line" >> /bouncer.stdin.out
|
||||||
: ${IPTABLES_CHAIN:=INPUT}
|
done
|
||||||
|
|
||||||
function iptableAdd () {
|
|
||||||
if [[ -z "${IPTABLES_INSERT}" ]]; then
|
|
||||||
iptables $comment -A $IPTABLES_CHAIN -s "$1" -j DROP
|
|
||||||
|
|
||||||
else
|
|
||||||
iptables $comment -I $IPTABLES_CHAIN "$IPTABLES_INSERT" -s "$1" -j DROP
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function iptableDel () {
|
|
||||||
iptables $comment -D $IPTABLES_CHAIN -s "$1" -j DROP
|
|
||||||
}
|
|
||||||
|
|
||||||
function ip6tableAdd () {
|
|
||||||
if [[ -z "${IPTABLES_INSERT}" ]]; then
|
|
||||||
ip6tables $comment -A $IPTABLES_CHAIN -s "$1" -j DROP
|
|
||||||
else
|
|
||||||
ip6tables $comment -I $IPTABLES_CHAIN "$IPTABLES_INSERT" -s "$1" -j DROP
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function ip6tableDel () {
|
|
||||||
ip6tables $comment -D $IPTABLES_CHAIN -s "$1" -j DROP
|
|
||||||
}
|
|
||||||
|
|
||||||
#determine action
|
|
||||||
if [ "$1" = "add" ]; then #add
|
|
||||||
if [[ "$2" =~ .*[.].* ]]; then #ipv4
|
|
||||||
echo "add $2 for $3 with $4"
|
|
||||||
iptableAdd "$2"
|
|
||||||
elif [[ "$2" =~ .*[:].* ]]; then #ipv6
|
|
||||||
echo "IPV6 : add $2 for $3 with $4"
|
|
||||||
ip6tableAdd "$2"
|
|
||||||
fi
|
|
||||||
elif [ "$1" = "del" ]; then #del
|
|
||||||
if [[ "$2" =~ .*[.].* ]]; then #ipv4
|
|
||||||
echo "del $2 for $3 with $4"
|
|
||||||
iptableDel "$2"
|
|
||||||
elif [[ "$2" =~ .*[:].* ]]; then #ipv6
|
|
||||||
echo "IPV6 : add $2 for $3 with $4"
|
|
||||||
ip6tableDel "$2"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "unknown action"
|
|
||||||
fi
|
|
3
publish-dev.sh
Executable file
3
publish-dev.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
docker image tag gitea.ar2000.me/ar2000/crowdsec-legacy-firewall-bouncer:legacy gitea.ar2000.me/ar2000/crowdsec-legacy-firewall-bouncer:dev
|
||||||
|
docker push gitea.ar2000.me/ar2000/crowdsec-legacy-firewall-bouncer:dev
|
Reference in New Issue
Block a user