banner

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2019 License: Apache-2.0 Imports: 14 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrProtectedIP = errors.New("cannot ban protected IP address")

Functions

This section is empty.

Types

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

func New

func New(ctx context.Context, config Config) *Banner

func (*Banner) BanIP

func (banner *Banner) BanIP(maddr ma.Multiaddr) error

BanIP adds the IP address of the given Multiaddr to the blacklist. The node will no longer dial or accept connections from this IP address. However, if the IP address is protected, calling BanIP will not ban the IP address and will instead return errProtectedIP. BanIP does not automatically disconnect from the given multiaddress if there is currently an open connection.

func (*Banner) CheckBandwidthUsage

func (banner *Banner) CheckBandwidthUsage()

CheckBandwidthUsage checks the amount of data sent by each connected peer and bans (via IP address) any peers which have exceeded the bandwidth limit.

func (*Banner) IsAddrBanned

func (banner *Banner) IsAddrBanned(maddr ma.Multiaddr) bool

func (*Banner) ProtectIP

func (banner *Banner) ProtectIP(maddr ma.Multiaddr) error

ProtectIP permanently adds the IP address of the given Multiaddr to a list of protected IP addresses. Protected IPs can never be banned and will not be added to the blacklist. If the IP address is already on the blacklist, it will be removed.

func (*Banner) SetMaxBytesPerSecond

func (banner *Banner) SetMaxBytesPerSecond(limit float64)

func (*Banner) UnbanIP

func (banner *Banner) UnbanIP(maddr ma.Multiaddr) error

UnbanIP removes the IP address of the given Multiaddr from the blacklist. If the IP address is not currently on the blacklist this is a no-op.

type Config

type Config struct {
	Host                   host.Host
	Filters                *filter.Filters
	BandwidthCounter       *metrics.BandwidthCounter
	MaxBytesPerSecond      float64
	LogBandwidthUsageStats bool
}

Notes

Bugs

  • newViolationsTracker currently leaks goroutines due to a limitation of the caching library used under the hood.

Jump to

Keyboard shortcuts

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