Files
iredmail-iRedMail/samples/fail2ban/sql/fail2ban.pgsql
T
Zhang Huangbin 2de2d0eb80 - WIP: Upgrade mlmmjadmin to 3.0, it now requires Python 3.5+.
- WIP: Upgrade iRedAPD to 4.0, it now requires Python 3.5+.
- Fixed: Add missing INDEX for SQL column `msgs.time_iso` in `amavisd` database.
- Fixed: incorrect set sql db driver to `pymysql` in iRedAPD for PostgreSQL backend.
- Fixed: script `fail2ban_banned_db` may fail if commands `geoiplookup` and
  `geoiplookup6` are not available.
- Fixed: explicitly set backend to `pooling` for Fail2ban jails.
- Fixed: not support custom adminer css file in Nginx snippet file
  `adminer.tmpl`.
- Enable SRS in iRedAPD by default. Note: it is not enabled in Postfix.
- Fail2ban: Store number of failures and matched log lines which triggered ban
  in SQL db. You can view the log lines after logged into iRedAdmin-Pro as
  global admin.
2020-06-02 12:43:02 +08:00

35 lines
1.4 KiB
PL/PgSQL

--
-- Used to store banned/unbanned clients
--
CREATE TABLE banned (
id SERIAL PRIMARY KEY,
-- Banned client IP address
ip VARCHAR(46) NOT NULL DEFAULT '',
-- A list of banned network ports, separated by comma
ports VARCHAR(255) NOT NULL DEFAULT '',
-- protocol: tcp, udp, ...
protocol VARCHAR(10) NOT NULL DEFAULT 'tcp',
-- Fail2ban jail name
jail VARCHAR(50) NOT NULL DEFAULT '',
-- The server hostname which the ban/unban happens
hostname VARCHAR(255) NOT NULL DEFAULT '',
country VARCHAR(255) NOT NULL DEFAULT '',
-- number of times the failure occurred in the log file.
-- we use Fail2ban action tag `ipjailfailures` here.
failures SMALLINT NOT NULL DEFAULT 0,
-- matched log lines.
-- we use Fail2ban action tag `ipjailmatches` here.
loglines TEXT,
-- When the ban happens
timestamp TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT (CURRENT_TIMESTAMP(0) AT TIME ZONE 'UTC'),
-- if `remove=1`, `ip` will be removed by cron job.
remove INT2 DEFAULT 0
);
CREATE UNIQUE INDEX idx_banned_ip_ports_protocol ON banned (ip, ports, protocol);
CREATE INDEX idx_banned_jail ON banned (jail);
CREATE INDEX idx_banned_hostname ON banned (hostname);
CREATE INDEX idx_banned_country ON banned (country);
CREATE INDEX idx_banned_timestamp ON banned (timestamp);
CREATE INDEX idx_banned_remove ON banned (remove);