NAME

CrowdSec::Client - CrowdSec client

SYNOPSIS

# Bouncer
use CrowdSec::Client;
my $client = CrowdSec::Client->new({
  apiKey => "myApiKey",
  baseUrl   => "http://127.0.0.1:8080",
});
if ( $client->testIp('1.2.3.4') ) {
  print STDERR "IP banned by crowdsec\n";
}

# Watcher
use CrowdSec::Client;
my $client = CrowdSec::Client->new({
  machineId => "myid",
  password  => "mypass",
  baseUrl   => "http://127.0.0.1:8080",
  autoLogin => 1;
});
$client->banIp({
  ip       => '1.2.3.4',
  duration => '5h',            # default 4h
  reason   => 'Ban by my app', # default: 'Banned by CrowdSec::Client'
}) or die( $client->error );

DESCRIPTION

CrowdSec::Client is a simple CrowdSec Client. It permits one to query Crowdsec database or to ban an IP.

Constructor

CrowdSec::Client requires a hashref as argument with the following keys:

Methods

banIp()

banIp adds the given IP into decisions. Usage:

$client->banIp( { %parameters } );

Parameters:

Enrollment

Bouncer

To get a Crowdsec API key, you can use:

$ sudo cscli bouncers add myBouncerName

Watcher

To get a Watcher password, you can use:

$ sudo cscli machines add MyId --password myPassword

SEE ALSO

CrowdSec

AUTHOR

Xavier Guimard xguimard@linagora.mu

COPYRIGHT AND LICENSE

Copyright (C) 2023 by Linagora

License: AGPL-3.0 (see LICENSE file)