policy

package
v0.0.0-...-cb72cfb Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Banning

type Banning struct {
	Enabled        bool    `json:"enabled"`
	IPSet          string  `json:"ipset"`
	Timeout        int64   `json:"timeout"`
	InvalidPercent float32 `json:"invalidPercent"`
	CheckThreshold int32   `json:"checkThreshold"`
	MalformedLimit int32   `json:"malformedLimit"`
}

type Config

type Config struct {
	Workers         int       `json:"workers"`
	Banning         Banning   `json:"banning"`
	Limits          Limits    `json:"limits"`
	Whitemode       Whitemode `json:"whitemode"`
	ResetInterval   string    `json:"resetInterval"`
	RefreshInterval string    `json:"refreshInterval"`
	Walletblacklist string    `json:"blacklist_file"`
	Walletwhitelist string    `json:"whitelist_file"`
}

type Limits

type Limits struct {
	Enabled   bool   `json:"enabled"`
	Limit     int32  `json:"limit"`
	Grace     string `json:"grace"`
	LimitJump int32  `json:"limitJump"`
}

type PolicyServer

type PolicyServer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func Start

func Start(cfg *Config, storage *storage.RedisClient) *PolicyServer

func (*PolicyServer) ApplyLimitPolicy

func (s *PolicyServer) ApplyLimitPolicy(ip string) bool

func (*PolicyServer) ApplyLoginPolicy

func (s *PolicyServer) ApplyLoginPolicy(addy, ip string) bool

func (*PolicyServer) ApplyLoginWalletPolicy

func (s *PolicyServer) ApplyLoginWalletPolicy(login string) bool

func (*PolicyServer) ApplyMalformedPolicy

func (s *PolicyServer) ApplyMalformedPolicy(ip string) bool

func (*PolicyServer) ApplySharePolicy

func (s *PolicyServer) ApplySharePolicy(ip string, validShare bool) bool

func (*PolicyServer) BanClient

func (s *PolicyServer) BanClient(ip string)

func (*PolicyServer) Get

func (s *PolicyServer) Get(ip string) *Stats

func (*PolicyServer) GetWalletBlacklist

func (s *PolicyServer) GetWalletBlacklist() ([]string, error)

loads up blacklist of wallets if file is present

func (*PolicyServer) GetWalletWhitelist

func (s *PolicyServer) GetWalletWhitelist() ([]string, error)

loads up whitelist of wallets if file is present

func (*PolicyServer) InBlackList

func (s *PolicyServer) InBlackList(addy string) bool

func (*PolicyServer) InWalletBlackList

func (s *PolicyServer) InWalletBlackList(addy string) bool

func (*PolicyServer) InWalletWhiteList

func (s *PolicyServer) InWalletWhiteList(addy string) bool

func (*PolicyServer) InWhiteList

func (s *PolicyServer) InWhiteList(ip string) bool

func (*PolicyServer) IsBanned

func (s *PolicyServer) IsBanned(ip string) bool

func (*PolicyServer) NewStats

func (s *PolicyServer) NewStats() *Stats

type Stats

type Stats struct {
	sync.Mutex
	// We are using atomic with LastBeat,
	// so moving it before the rest in order to avoid alignment issue
	LastBeat      int64
	BannedAt      int64
	ValidShares   int32
	InvalidShares int32
	Malformed     int32
	ConnLimit     int32
	Banned        int32
}

type Whitemode

type Whitemode struct {
	Enabled bool `json:"enabled"`
}

Jump to

Keyboard shortcuts

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