banlog

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

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: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

View Source
const (
	SourceManual   = "manual"
	SourceLogin    = "login"
	SourcePortscan = "portscan"
	SourceDDoS     = "ddos"
	SourceFeeds    = "feeds"
	SourceSuricata = "suricata"
	SourceFail2ban = "fail2ban" // Legacy compatibility
)

Source constants for ban log entries

View Source
const (
	StatusBanned   = "BANNED"
	StatusUnbanned = "UNBANNED"
)

Status constants

Variables

This section is empty.

Functions

func LogBan

func LogBan(ip, source, country string) error

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 LogBanWithReason

func LogBanWithReason(ip, source, country, reason string) error

LogBanWithReason writes a ban entry with a reason for audit trail Format: DATE|TIME|SOURCE|IP|COUNTRY|BANNED|REASON

func LogUnban

func LogUnban(ip, source, country string) error

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 LogUnbanWithReason added in v1.5.0

func LogUnbanWithReason(ip, source, country, reason string) error

LogUnbanWithReason writes an unban entry with a reason for audit trail Format: DATE|TIME|SOURCE|IP|COUNTRY|UNBANNED|REASON

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL