evilnode

package
v0.0.0-...-27cef4d Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: LGPL-3.0 Imports: 9 Imported by: 7

Documentation

Index

Constants

View Source
const (
	EvilScoreTableDialFail        uint16 = 40
	EvilScoreTableReducePerMinute uint16 = 1
)

evilScoreTable

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	StorePath    string
	BanEvilScore uint16
}

Config is router config

type ConnList

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

ConnList stores information for peers even connected at least once.

func NewConnList

func NewConnList(dbpath string) (*ConnList, error)

NewConnList is creator of physical Connection list

func (*ConnList) Get

func (pl *ConnList) Get(addr string) (p ConnectionInfo, err error)

Get is returned strored ConnectionInfo

func (*ConnList) Store

func (pl *ConnList) Store(v ConnectionInfo) error

Store is strore the ConnectionInfo

type ConnectionInfo

type ConnectionInfo struct {
	Addr      string
	EvilScore uint16
	Time      time.Time
}

ConnectionInfo is struct for manage evel scroe

func (*ConnectionInfo) ReadFrom

func (pi *ConnectionInfo) ReadFrom(r io.Reader) (int64, error)

ReadFrom is a deserialization function

func (*ConnectionInfo) WriteTo

func (pi *ConnectionInfo) WriteTo(w io.Writer) (int64, error)

WriteTo is a serialization function

type KindOfEvil

type KindOfEvil uint16

KindOfEvil is define evil table type

const (
	BadBehaviour KindOfEvil = 40
)

evilnode evil score table

type Manager

type Manager struct {
	Config     *Config
	List       *ConnList
	NoticeList map[string]NoticeEvil
}

Manager is node evil score manager

func NewManager

func NewManager(c *Config) *Manager

NewManager is creator of evilnode Manager

func (*Manager) IsBanNode

func (r *Manager) IsBanNode(addr string) bool

IsBanNode is return true value when the target node over the base evil score

func (*Manager) RegisterNoticeEvilNode

func (r *Manager) RegisterNoticeEvilNode(ne NoticeEvil)

RegisterNoticeEvilNode is Registered notice EvilNode

func (*Manager) TellOn

func (r *Manager) TellOn(addr string, es KindOfEvil) error

TellOn is update nodes evil score

type NoticeEvil

type NoticeEvil interface {
	NewEvilNode(string)
}

NoticeEvil is interface for notifies the registered object when the evil node appears.

Jump to

Keyboard shortcuts

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