1.0.2 • Published 1 year ago

fail2ban_json v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

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
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago