database

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultCleanupInterval to remove old entries
	DefaultCleanupInterval = 10 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IPDatabase

type IPDatabase struct {
	// contains filtered or unexported fields
}

IPDatabase manages IP information persistence in SQLite

func NewIPDatabase

func NewIPDatabase(dbPath string, ttl time.Duration) (*IPDatabase, error)

NewIPDatabase creates a new database instance

func (*IPDatabase) Close

func (db *IPDatabase) Close() error

func (*IPDatabase) Delete

func (db *IPDatabase) Delete(ip string) error

func (*IPDatabase) Get

func (db *IPDatabase) Get(ip string) (*domain.IPInfo, bool)

func (*IPDatabase) GetAllIPs

func (db *IPDatabase) GetAllIPs() ([]*domain.IPInfo, error)

GetAllIPs returns all IP entries from the database

func (*IPDatabase) GetStats

func (db *IPDatabase) GetStats() (Stats, error)

func (*IPDatabase) MarkBlocked

func (db *IPDatabase) MarkBlocked(ip string) error

func (*IPDatabase) Set

func (db *IPDatabase) Set(info *domain.IPInfo) error

func (*IPDatabase) Vacuum

func (db *IPDatabase) Vacuum() error

type Stats

type Stats struct {
	TotalEntries   int64
	ActiveEntries  int64
	BlockedEntries int64
	DBSize         int64
}

Stats contains database statistics

Jump to

Keyboard shortcuts

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