blacklist

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: MIT Imports: 3 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IList

type IList interface {
	AddOrIncrease(uri string) IList
	IsBanned(uri string) bool
	Remove(uri string) IList
}

IList describes the user panel of a Blacklist

type IRecord

type IRecord interface {
	Increase() IRecord
	GetCount() int
	ResetCount() IRecord
	SetBanTime(*time.Time) IRecord
	GetBanTime() *time.Time
	IsBanned() bool
}

IRecord describes the user panel of BlacklistRecord

type List

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

List implements IList

func NewList

func NewList(freeAfter time.Duration, limit int) *List

NewList creates a new List instance

func (*List) AddOrIncrease

func (b *List) AddOrIncrease(uri string) IList

AddOrIncrease stores the URI as a new record or increases the inner counter

func (*List) IsBanned

func (b *List) IsBanned(uri string) bool

IsBanned returns if the given record is banned or not

func (*List) Remove

func (b *List) Remove(uri string) IList

Remove removes a given URI from the blacklist

type Record

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

Record is an element of the blacklist

func NewRecord

func NewRecord(uri string) *Record

NewRecord creates a new instance of Record

func (*Record) GetBanTime

func (r *Record) GetBanTime() *time.Time

GetBanTime returns bannedUntil property

func (*Record) GetCount

func (r *Record) GetCount() int

GetCount returns the count of the record

func (*Record) Increase

func (r *Record) Increase() IRecord

Increase increases the inner counter for the record

func (*Record) IsBanned

func (r *Record) IsBanned() bool

IsBanned is to determine if the record is currently banned or not

func (*Record) ResetCount

func (r *Record) ResetCount() IRecord

ResetCount resets the inner count

func (*Record) SetBanTime

func (r *Record) SetBanTime(t *time.Time) IRecord

SetBanTime sets the record banned for a given time

Jump to

Keyboard shortcuts

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