Documentation ¶
Index ¶
- type IPMeta
- type NetworkData
- type NetworkStats
- type Networks
- func (n *Networks) APIHooks(r *gin.Engine)
- func (n *Networks) ASNStats(asn int) (st *data.Stats, found bool)
- func (n *Networks) All() []*NetworkData
- func (n *Networks) Averages() data.NetworkStats
- func (n *Networks) Count() int
- func (n *Networks) HandleRequest(r *data.Request)
- func (n *Networks) IsWhitelisted(ip net.IP) bool
- func (n *Networks) NetworkStats(ipn *net.IPNet) (nd *NetworkData, found bool)
- func (n *Networks) Remove(network *net.IPNet)
- func (n *Networks) SetBlocker(b data.Blocker)
- func (n *Networks) ShouldBeBlocked(stats data.IPStats) (blocked bool, reason string)
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 (*IPMeta) HandleRequest ¶
func (*IPMeta) SetBlocker ¶
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 Networks ¶
type Networks struct {
// contains filtered or unexported fields
}
Networks contains requests statistics for all networks
func NewNetworks ¶
NewNetworks creates a new Networks instance
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) HandleRequest ¶
HandleRequest handles a request and saves it into the network data
func (*Networks) IsWhitelisted ¶
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 ¶
Remove deletes a network from the list of networks, e.g. when all its requests have expired
func (*Networks) SetBlocker ¶
SetBlocker sets the instance through which it can block networks