ban

package
v1.54.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBanItemNotFound = errors.New("ban item not found")

Functions

This section is empty.

Types

type Item

type Item struct {
	IP       net.IP    `json:"ip"`
	Until    time.Time `json:"up_to"`
	ByUserID int64     `json:"by_user_id"`
	Reason   string    `json:"reason"`
}

Item Item.

type Repository

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

Repository Main Object.

func NewRepository

func NewRepository(db *goqu.Database) (*Repository, error)

NewRepository constructor.

func (*Repository) Add

func (s *Repository) Add(ctx context.Context, ip net.IP, duration time.Duration, byUserID int64, reason string) error

Add IP to list of banned.

func (*Repository) Clear

func (s *Repository) Clear(ctx context.Context) error

Clear removes all collected data.

func (*Repository) Exists

func (s *Repository) Exists(ctx context.Context, ip net.IP) (bool, error)

Exists ban list already contains IP.

func (*Repository) GC

func (s *Repository) GC(ctx context.Context) (int64, error)

GC Garbage Collect.

func (*Repository) Get

func (s *Repository) Get(ctx context.Context, ip net.IP) (*Item, error)

Get ban info.

func (*Repository) Remove

func (s *Repository) Remove(ctx context.Context, ip net.IP) error

Remove IP from list of banned.

Jump to

Keyboard shortcuts

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