policy

package
v0.0.0-...-e6ebeba Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: GPL-3.0 Imports: 9 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"`
	ResetInterval   string  `json:"resetInterval"`
	RefreshInterval string  `json:"refreshInterval"`
}

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) 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) InBlackList

func (s *PolicyServer) InBlackList(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
}

Jump to

Keyboard shortcuts

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