plugins

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPMeta

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

func NewIPMeta

func NewIPMeta(asndb *asndb.DB, geodb *geoip.DB) *IPMeta

func (*IPMeta) APIHooks

func (i *IPMeta) APIHooks(r *gin.Engine)

func (*IPMeta) HandleRequest

func (i *IPMeta) HandleRequest(r *data.Request)

func (*IPMeta) IsWhitelisted

func (i *IPMeta) IsWhitelisted(ip net.IP) bool

func (*IPMeta) SetBlocker

func (i *IPMeta) SetBlocker(b data.Blocker)

func (*IPMeta) ShouldBeBlocked

func (i *IPMeta) ShouldBeBlocked(stats data.IPStats) (blocked bool, reason string)

type NetworkData

type NetworkData struct {
	Network   *net.IPNet `json:"network"`
	Total     int        `json:"total"`
	App       int        `json:"app"`
	Other     int        `json:"other"`
	Ratio     float64    `json:"ratio"`
	IPCount   int        `json:"ipcount"`
	UpdatedAt time.Time  `json:"updatedat"`
	ASN       *asndb.ASN `json:"asn"`
	// contains filtered or unexported fields
}

NetworkData contains request statistics for one network

func NewNetworkData

func NewNetworkData(ctx context.Context, ipnet *net.IPNet, removeChan chan *net.IPNet, config *config.Config) *NetworkData

NewNetworkData creates a new NetworkData instance

func (*NetworkData) HandleRequest

func (nd *NetworkData) HandleRequest(r *data.Request)

HandleRequest adds an item to the NetworkData instance

func (*NetworkData) NumberOfIPs

func (nd *NetworkData) NumberOfIPs() uint32

type NetworkStats

type NetworkStats struct {
	data.Stats
}

type Networks

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

Networks contains requests statistics for all networks

func NewNetworks

func NewNetworks(ctx context.Context, config *config.Config) *Networks

NewNetworks creates a new Networks instance

func (*Networks) APIHooks

func (n *Networks) APIHooks(r *gin.Engine)

func (*Networks) ASNStats

func (n *Networks) ASNStats(asn int) (st *data.Stats, found bool)

ASNStats returns the metadata and statistics for an autonomous system

func (*Networks) All

func (n *Networks) All() []*NetworkData

All returns data about all networks it currently holds

func (*Networks) Averages

func (n *Networks) Averages() data.NetworkStats

Averages returns the average of requests across all networks

func (*Networks) Count

func (n *Networks) Count() int

Count returns the number of networks

func (*Networks) HandleRequest

func (n *Networks) HandleRequest(r *data.Request)

HandleRequest handles a request and saves it into the network data

func (*Networks) IsWhitelisted

func (n *Networks) IsWhitelisted(ip net.IP) bool

IsWhitelisted determines whether an IP is whitelisted This plugin doesn't whitelist and always returns false

func (*Networks) NetworkStats

func (n *Networks) NetworkStats(ipn *net.IPNet) (nd *NetworkData, found bool)

NetworkStats returns the metadata and statistics for one network

func (*Networks) Remove

func (n *Networks) Remove(network *net.IPNet)

Remove deletes a network from the list of networks, e.g. when all its requests have expired

func (*Networks) SetBlocker

func (n *Networks) SetBlocker(b data.Blocker)

SetBlocker sets the instance through which it can block networks

func (*Networks) ShouldBeBlocked

func (n *Networks) ShouldBeBlocked(stats data.IPStats) (blocked bool, reason string)

ShouldBeBlocked decides whether an IP should be blocked based on its network and/or ASN being blocked

Jump to

Keyboard shortcuts

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