banmgr

package
v0.0.0-...-dfc2b99 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: ISC Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Halflife defines the time (in seconds) by which the transient part
	// of the ban score decays to one half of it's original value.
	Halflife = 60

	// Lifetime defines the maximum age of the transient part of the ban
	// score to be considered a non-zero score (in seconds).
	Lifetime = 1800
)

Variables

This section is empty.

Functions

func TrimAddress

func TrimAddress(host string) string

Types

type BanInfo

type BanInfo struct {
	Addr           string
	Reason         string
	BanScore       int32
	BanExpiresTime time.Time
}

type BanMgr

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

func New

func New(config *Config) *BanMgr

func (*BanMgr) AddBanScore

func (b *BanMgr) AddBanScore(host string, persistent, transient uint32, reason string) bool

func (*BanMgr) ForEachIp

func (b *BanMgr) ForEachIp(f func(bi BanInfo) er.R) er.R

func (*BanMgr) IsBanned

func (b *BanMgr) IsBanned(ip string) bool

type BannedPeers

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

type Config

type Config struct {
	DisableBanning bool
	IpWhiteList    []string
	BanThreashold  uint32
}

type DynamicBanScore

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

DynamicBanScore provides dynamic ban scores consisting of a persistent and a decaying component. The persistent score could be utilized to create simple additive banning policies similar to those found in other bitcoin node implementations.

The decaying score enables the creation of evasive logic which handles misbehaving peers (especially application layer DoS attacks) gracefully by disconnecting and banning peers attempting various kinds of flooding. DynamicBanScore allows these two approaches to be used in tandem.

Zero value: Values of type DynamicBanScore are immediately ready for use upon declaration.

func (*DynamicBanScore) Increase

func (s *DynamicBanScore) Increase(persistent, transient uint32) uint32

Increase increases both the persistent and decaying scores by the values passed as parameters. The resulting score is returned.

This function is safe for concurrent access.

func (*DynamicBanScore) Int

func (s *DynamicBanScore) Int() uint32

Int returns the current ban score, the sum of the persistent and decaying scores.

This function is safe for concurrent access.

func (*DynamicBanScore) Reset

func (s *DynamicBanScore) Reset()

Reset set both persistent and decaying scores to zero.

This function is safe for concurrent access.

func (*DynamicBanScore) String

func (s *DynamicBanScore) String() string

String returns the ban score as a human-readable string.

type SuspiciousPeers

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

Jump to

Keyboard shortcuts

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