fail2ban_json

1.0.2 • Public • Published

Fail2ban

json based fail2ban integration for nodejs

https://www.npmjs.com/package/fail2ban_json

Functions

const f2b = require("fail2ban_json");

f2b.config({
    "bantime": {
        "mode": "m",    // s = seconds | m = minutes | h = hours | d = days
        "count": 10     // number of seconds/minutes etc.
    },
    "maxTry": 3,        // max attempts until locked
    "log": true,        // logging
    "path": "./"        // set path for the blocklist (and log if necessary)
})

f2b.check("1.2.3.4", cb => {
    console.log(cb);
});

f2b.ban("1.2.3.4", cb => {
    console.log(cb);
});

f2b.delete("1.2.3.4", cb => {
    console.log(cb);
});

Return value

Check:

// IP not listed
{
  baned: false
}

// IP listed but not locked
{
  baned: false,
  try: 1
}

// IP locked ("bantime" is the time when requests are allowed again)
{
  baned: true,
  try: 3,
  bantime: 1671273781571
}

Ban:

// IP is not locked yet
{
  baned: false,
  try: 1
}

// IP is locked ("bantime" is the time when requests are allowed again)
{
  baned: true,
  try: 3,
  bantime: 1671273781571
}

Delete:

// IP is not listed
false

// IP was deleted from list
true

Readme

Keywords

none

Package Sidebar

Install

npm i fail2ban_json

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

8.11 kB

Total Files

3

Last publish

Collaborators

  • pugpickles