pscore

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ConnCleanupLoopInterval indicates the loop interval for conn cleaning up
	ConnCleanupLoopInterval = 30 * time.Second
)

Variables

View Source
var (
	// PunishFactors contains factors of punishment.
	PunishFactors = newFactors(60, 1800, 64)
	// RechieveFactors contains factors of achievement.
	RechieveFactors = newFactors(600, 18000, 512)
)

Functions

This section is empty.

Types

type DynamicPeerScore

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

DynamicPeerScore provides dynamic ban scores consisting of a punishment, a achievement and a decaying component. The punished score and the achieved score could be utilized to create simple additive banning policies similar to those found in other 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. DynamicPeerScore allows these two approaches to be used in tandem.

baseScore: Values of type DynamicPeerScore are immediately ready for use upon declaration.

func NewDynamicPeerScore

func NewDynamicPeerScore(pid peer.ID) *DynamicPeerScore

NewDynamicPeerScore returns new DynamicPeerScore.

func (*DynamicPeerScore) Record

func (s *DynamicPeerScore) Record(event eventbus.BusEvent)

Record record event

func (*DynamicPeerScore) Score

func (s *DynamicPeerScore) Score(t time.Time) int64

Score returns the current peer score, the sum of the achieved and punished scores.

This function is safe for concurrent access.

func (*DynamicPeerScore) String

func (s *DynamicPeerScore) String(t time.Time) string

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

Jump to

Keyboard shortcuts

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