Documentation
¶
Overview ¶
SPDX-License-Identifier: MPL-2.0 Copyright (c) 2025 Antonios Voulvoulis <contact@nftban.com>
Package banlog provides centralized ban logging for NFTBan All ban actions (from any source) should log here for stats tracking
meta:name="banlog" meta:type="package" meta:version="1.41.0" meta:owner="Antonios Voulvoulis <contact@nftban.com>" meta:description="Central ban logging with audit trail support" meta:inventory.files="/var/log/nftban/bans.log" meta:inventory.binaries="" meta:inventory.env_vars="" meta:inventory.config_files="/etc/nftban/nftban.conf" meta:inventory.systemd_units="" meta:inventory.network="" meta:inventory.privileges="write:/var/log/nftban/"
Index ¶
- Constants
- func GenerateBanID() string
- func LogBan(ip, source, country string) error
- func LogBanWithID(ip, source, country, reason, banID string) error
- func LogBanWithReason(ip, source, country, reason string) error
- func LogUnban(ip, source, country string) error
- func LogUnbanWithID(ip, source, country, reason, banID string) error
- func LogUnbanWithReason(ip, source, country, reason string) error
Constants ¶
const ( SourceManual = "manual" SourceLogin = "login" SourcePortscan = "portscan" SourceDDoS = "ddos" SourceFeeds = "feeds" SourceSuricata = "suricata" SourceFail2ban = "fail2ban" // Legacy compatibility )
Source constants for ban log entries
const ( StatusBanned = "BANNED" StatusUnbanned = "UNBANNED" )
Status constants
Variables ¶
This section is empty.
Functions ¶
func GenerateBanID ¶ added in v1.41.0
func GenerateBanID() string
GenerateBanID creates a unique 16-char hex ban correlation ID
func LogBan ¶
LogBan writes a ban entry to the central ban.log Parameters:
- ip: IP address being banned
- source: Ban source (manual, login, portscan, ddos, feeds, suricata)
- country: Country code (e.g., "US", "CN", "UNK" if unknown)
Format: DATE|TIME|SOURCE|IP|COUNTRY|BANNED|REASON (reason empty for this func) Use LogBanWithReason for audit trail with reason
func LogBanWithID ¶ added in v1.41.0
LogBanWithID writes a ban entry with a reason and correlation ID (v1.41.0) The banID links this BAN entry to a future UNBAN entry for the same incident Format: DATE|TIME|SOURCE|IP|COUNTRY|BANNED|REASON|BAN_ID
func LogBanWithReason ¶
LogBanWithReason writes a ban entry with a reason for audit trail Format: DATE|TIME|SOURCE|IP|COUNTRY|BANNED|REASON
func LogUnban ¶
LogUnban writes an unban entry to the central ban.log Parameters:
- ip: IP address being unbanned
- source: Unban source (usually "manual")
- country: Country code
Format: DATE|TIME|SOURCE|IP|COUNTRY|UNBANNED
func LogUnbanWithID ¶ added in v1.41.0
LogUnbanWithID writes an unban entry with a correlation ID (v1.41.0) The banID should match the ID from the original ban entry Format: DATE|TIME|SOURCE|IP|COUNTRY|UNBANNED|REASON|BAN_ID
func LogUnbanWithReason ¶
LogUnbanWithReason writes an unban entry with a reason for audit trail Format: DATE|TIME|SOURCE|IP|COUNTRY|UNBANNED|REASON
Types ¶
This section is empty.