security

package
Version: v4.8.11+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: AGPL-3.0 Imports: 9 Imported by: 3

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
)
View Source
const (
	LevelMsgIllegal = 0x01

	LevelConnException = 0x02
)

Variables

View Source
var (
	ErrConnectBannedPeer = errors.New("connect banned peer")
)

Functions

This section is empty.

Types

type Blacklist

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

func NewBlacklist

func NewBlacklist(config *cfg.Config) *Blacklist

func (*Blacklist) AddPeer

func (bl *Blacklist) AddPeer(ip string) error

AddPeer add peer to blacklist

func (*Blacklist) DoFilter

func (bl *Blacklist) DoFilter(ip string, pubKey string) error

func (*Blacklist) LoadPeers

func (bl *Blacklist) LoadPeers() error

LoadPeers load banned peers from db

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 Filter

type Filter interface {
	DoFilter(string, string) error
}

type PeerFilter

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

func NewPeerFilter

func NewPeerFilter() *PeerFilter

type PeersBanScore

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

func NewPeersScore

func NewPeersScore() *PeersBanScore

func (*PeersBanScore) DelPeer

func (ps *PeersBanScore) DelPeer(ip string)

func (*PeersBanScore) Increase

func (ps *PeersBanScore) Increase(ip string, level byte, reason string) bool

type Security

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

func NewSecurity

func NewSecurity(config *cfg.Config) *Security

func (*Security) DoFilter

func (s *Security) DoFilter(ip string, pubKey string) error

func (*Security) IsBanned

func (s *Security) IsBanned(ip string, level byte, reason string) bool

func (*Security) RegisterFilter

func (s *Security) RegisterFilter(filter Filter)

func (*Security) Start

func (s *Security) Start() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL