Fix CrowdSec plugin (#2817)

This commit is contained in:
Yadd 2022-11-04 11:33:28 +01:00
parent 46eef8a41c
commit c4a5abc4e0
1 changed files with 5 additions and 2 deletions

View File

@ -33,7 +33,9 @@ has crowdsecUrl => ( is => 'rw' );
sub init {
my ($self) = @_;
if ( $self->conf->{crowdsecUrl} ) {
$self->crowdsecUrl( $self->conf->{crowdsecUrl} =~ s#/+$## );
my $tmp = $self->conf->{crowdsecUrl};
$tmp =~ s#/+$##;
$self->crowdsecUrl($tmp);
}
else {
$self->logger->warn(
@ -59,7 +61,7 @@ sub check {
return PE_ERROR;
}
my $content = $resp->decoded_content;
unless ($content) {
if ( !$content or $content eq 'null' ) {
$self->userLogger->info("$ip isn't known by CrowsSec");
return PE_OK;
}
@ -86,6 +88,7 @@ sub check {
return PE_SESSIONNOTGRANTED;
}
else {
$self->userLogger->error("$ip is banned by CrowdSec");
$req->env->{CROWDSEC_REJECT} = 1;
return PE_OK;
}