abuseipdb

package
v0.0.0-...-6ac2e72 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIURL     = "https://api.abuseipdb.com/api/v2/blacklist"
	ModuleName = "AbuseIPDB"
	TimeFormat = "2006-01-02T15:04:05-07:00"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Detail string `json:"detail"`
	Status int    `json:"status"`
}

type APIErrorResponse

type APIErrorResponse struct {
	Errors []APIError `json:"errors"`
}

type AbuseIPDB

type AbuseIPDB struct {
	Client            *retryablehttp.Client
	APIURL            string
	APIKey            string
	ConfidenceMinimum int
	Limit             int64
}

func New

func New() AbuseIPDB

func (*AbuseIPDB) Fetch

func (a *AbuseIPDB) Fetch() (doc Doc, err error)

func (*AbuseIPDB) FetchData

func (a *AbuseIPDB) FetchData() (data []byte, headers http.Header, status int, err error)

type Doc

type Doc struct {
	GeneratedAt time.Time
	Records     []Record
}

func Parse

func Parse(in []byte) (doc Doc, err error)

type RawBlacklistDoc

type RawBlacklistDoc struct {
	Meta struct {
		GeneratedAt string `json:"generatedAt"`
	} `json:"meta"`
	Data []struct {
		IPAddress            string `json:"ipAddress"`
		CountryCode          string `json:"countryCode"`
		AbuseConfidenceScore int    `json:"abuseConfidenceScore"`
		LastReportedAt       string `json:"LastReportedAt"`
	} `json:"data"`
}

type Record

type Record struct {
	IPAddress            netip.Addr `json:"ipAddress"`
	CountryCode          string     `json:"countryCode"`
	AbuseConfidenceScore int        `json:"abuseConfidenceScore"`
	LastReportedAt       time.Time  `json:"lastReportedAt"`
}

Jump to

Keyboard shortcuts

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